Updated directory structure
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import prologue, nanoid, json
|
||||
import sequtils, strutils, times
|
||||
|
||||
import ./agentApi
|
||||
import ./handlers
|
||||
import ../../types
|
||||
|
||||
proc error404*(ctx: Context) {.async.} =
|
||||
@@ -1,7 +1,7 @@
|
||||
import terminal, strformat, strutils, sequtils, tables, json, times, base64, system, osproc, streams
|
||||
|
||||
import ./taskDispatcher
|
||||
import ../utils
|
||||
import ../task/dispatcher
|
||||
import ../db/database
|
||||
import ../../types
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import strformat, strutils, sequtils, nanoid, terminal
|
||||
import prologue
|
||||
|
||||
import ./endpoints
|
||||
import ../utils
|
||||
import ../api/routes
|
||||
import ../db/database
|
||||
import ../../types
|
||||
|
||||
@@ -47,10 +47,10 @@ proc listenerStart*(cq: Conquest, host: string, portStr: string) =
|
||||
var listener = newApp(settings = listenerSettings)
|
||||
|
||||
# Define API endpoints
|
||||
listener.post("{listener}/register", endpoints.register)
|
||||
listener.get("{listener}/{agent}/tasks", endpoints.getTasks)
|
||||
listener.post("{listener}/{agent}/{task}/results", endpoints.postResults)
|
||||
listener.registerErrorHandler(Http404, endpoints.error404)
|
||||
listener.post("{listener}/register", routes.register)
|
||||
listener.get("{listener}/{agent}/tasks", routes.getTasks)
|
||||
listener.post("{listener}/{agent}/{task}/results", routes.postResults)
|
||||
listener.registerErrorHandler(Http404, routes.error404)
|
||||
|
||||
# Store listener in database
|
||||
var listenerInstance = newListener(name, host, port)
|
||||
@@ -80,10 +80,10 @@ proc restartListeners*(cq: Conquest) =
|
||||
listener = newApp(settings = settings)
|
||||
|
||||
# Define API endpoints
|
||||
listener.post("{listener}/register", endpoints.register)
|
||||
listener.get("{listener}/{agent}/tasks", endpoints.getTasks)
|
||||
listener.post("{listener}/{agent}/{task}/results", endpoints.postResults)
|
||||
listener.registerErrorHandler(Http404, endpoints.error404)
|
||||
listener.post("{listener}/register", routes.register)
|
||||
listener.get("{listener}/{agent}/tasks", routes.getTasks)
|
||||
listener.post("{listener}/{agent}/{task}/results", routes.postResults)
|
||||
listener.registerErrorHandler(Http404, routes.error404)
|
||||
|
||||
try:
|
||||
discard listener.runAsync()
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import prompt, terminal, argparse
|
||||
import strutils, strformat, times, system, tables
|
||||
|
||||
import ./globals
|
||||
import core/agent, core/listener, db/database
|
||||
import ../types
|
||||
import ./[agent, listener]
|
||||
import ../db/database
|
||||
import ../globals
|
||||
import ../../types
|
||||
|
||||
#[
|
||||
Argument parsing
|
||||
@@ -61,7 +62,7 @@ var parser = newParser:
|
||||
command("exit"):
|
||||
nohelpflag()
|
||||
|
||||
proc handleConsoleCommand*(cq: Conquest, args: string) =
|
||||
proc handleConsoleCommand(cq: Conquest, args: string) =
|
||||
|
||||
# Return if no command (or just whitespace) is entered
|
||||
if args.replace(" ", "").len == 0: return
|
||||
@@ -125,11 +126,8 @@ proc header(cq: Conquest) =
|
||||
cq.writeLine(" ┗ @jakobfriedl")
|
||||
cq.writeLine("─".repeat(21))
|
||||
cq.writeLine("")
|
||||
|
||||
#[
|
||||
Conquest framework entry point
|
||||
]#
|
||||
proc main() =
|
||||
|
||||
proc startServer*() =
|
||||
# Handle CTRL+C,
|
||||
proc exit() {.noconv.} =
|
||||
echo "Received CTRL+C. Type \"exit\" to close the application.\n"
|
||||
@@ -137,7 +135,7 @@ proc main() =
|
||||
setControlCHook(exit)
|
||||
|
||||
# Initialize framework
|
||||
let dbPath: string = "../src/server/db/conquest.db"
|
||||
let dbPath: string = "../data/conquest.db"
|
||||
cq = initConquest(dbPath)
|
||||
|
||||
# Print header
|
||||
@@ -156,6 +154,3 @@ proc main() =
|
||||
|
||||
var command: string = cq.readLine()
|
||||
cq.withOutput(handleConsoleCommand, command)
|
||||
|
||||
when isMainModule:
|
||||
main()
|
||||
@@ -1,9 +1,4 @@
|
||||
import ../types
|
||||
|
||||
# Global variable for handling listeners, agents and console output
|
||||
var cq*: Conquest
|
||||
|
||||
# Colors
|
||||
# https://colors.sh/
|
||||
const red* = "\e[210;66;79m"
|
||||
const resetColor* = "\e[0m"
|
||||
var cq*: Conquest
|
||||
8
src/server/main.nim
Normal file
8
src/server/main.nim
Normal file
@@ -0,0 +1,8 @@
|
||||
import prompt, terminal, argparse
|
||||
import strutils, strformat, times, system, tables
|
||||
|
||||
import core/server
|
||||
|
||||
# Conquest framework entry point
|
||||
when isMainModule:
|
||||
startServer()
|
||||
@@ -1,4 +1,5 @@
|
||||
# Compiler flags
|
||||
--threads:on
|
||||
-d:httpxServerName="nginx"
|
||||
--outdir:"../bin"
|
||||
--outdir:"../bin"
|
||||
--out:"server"
|
||||
0
src/server/task/packer.nim
Normal file
0
src/server/task/packer.nim
Normal file
0
src/server/task/parser.nim
Normal file
0
src/server/task/parser.nim
Normal file
Reference in New Issue
Block a user