diff --git a/README.md b/README.md
index a546a02..a1d5fac 100644
--- a/README.md
+++ b/README.md
@@ -18,9 +18,11 @@
2. Run `nix-shell`, or alternatively `source init.sh` if you're not using Nix.
-3. After that, run the project in development mode: `npm run dev`.
+
API Development
-4. If you want to explore your database, run `npx prisma studio` to open the database editor.
+1. After that, run the project in development mode: `npm run dev`.
+
+2. If you want to explore your database, run `npx prisma studio` to open the database editor.
Production Deployment
@@ -36,7 +38,7 @@
3. Build the docker stack: `docker compose --env-file .env up -d`
-Troubleshooting
+Troubleshooting
* I'm using the SSH tunneling, and I can't reach any of the tunnels publicly.
- Be sure to enable GatewayPorts in your sshd config (in `/etc/ssh/sshd_config` on most systems). Also, be sure to check your firewall rules on your system and your network.
\ No newline at end of file
diff --git a/.devcontainer/Dockerfile b/api/.devcontainer/Dockerfile
similarity index 100%
rename from .devcontainer/Dockerfile
rename to api/.devcontainer/Dockerfile
diff --git a/.devcontainer/devcontainer.json b/api/.devcontainer/devcontainer.json
similarity index 100%
rename from .devcontainer/devcontainer.json
rename to api/.devcontainer/devcontainer.json
diff --git a/.gitignore b/api/.gitignore
similarity index 100%
rename from .gitignore
rename to api/.gitignore
diff --git a/Dockerfile b/api/Dockerfile
similarity index 100%
rename from Dockerfile
rename to api/Dockerfile
diff --git a/dev.env b/api/dev.env
similarity index 100%
rename from dev.env
rename to api/dev.env
diff --git a/docker-entrypoint.sh b/api/docker-entrypoint.sh
similarity index 100%
rename from docker-entrypoint.sh
rename to api/docker-entrypoint.sh
diff --git a/api/init.sh b/api/init.sh
new file mode 100755
index 0000000..6df21b5
--- /dev/null
+++ b/api/init.sh
@@ -0,0 +1,32 @@
+if [ ! -d ".tmp" ]; then
+ echo "Hello and welcome to the NextNet (backend) project! Please wait while I initialize things for you..."
+ cp dev.env .env
+ mkdir .tmp
+fi
+
+lsof -i:5432 | grep postgres 2> /dev/null > /dev/null
+IS_PG_RUNNING=$?
+
+if [ ! -f ".tmp/ispginit" ]; then
+ if [[ "$IS_PG_RUNNING" == 0 ]]; then
+ kill -9 $(lsof -t -i:5432) > /dev/null 2> /dev/null
+ fi
+
+ echo " - Database not initialized! Initializing database..."
+ mkdir .tmp/pglock
+
+ initdb -D .tmp/db
+ pg_ctl -D .tmp/db -l .tmp/logfile -o "--unix_socket_directories='$PWD/.tmp/pglock/'" start
+ createdb -h localhost -p 5432 nextnet
+
+ psql -h localhost -p 5432 nextnet -c "CREATE ROLE nextnet WITH LOGIN SUPERUSER PASSWORD 'nextnet';"
+
+ npm install --save-dev
+ npx prisma migrate dev
+
+ touch .tmp/ispginit
+elif [[ "$IS_PG_RUNNING" == 1 ]]; then
+ pg_ctl -D .tmp/db -l .tmp/logfile -o "--unix_socket_directories='$PWD/.tmp/pglock/'" start
+fi
+
+source .env # Make sure we actually load correctly
\ No newline at end of file
diff --git a/package-lock.json b/api/package-lock.json
similarity index 100%
rename from package-lock.json
rename to api/package-lock.json
diff --git a/package.json b/api/package.json
similarity index 100%
rename from package.json
rename to api/package.json
diff --git a/prisma/migrations/20240421200334_init/migration.sql b/api/prisma/migrations/20240421200334_init/migration.sql
similarity index 100%
rename from prisma/migrations/20240421200334_init/migration.sql
rename to api/prisma/migrations/20240421200334_init/migration.sql
diff --git a/prisma/migrations/20240421210417_fix_remove_destip/migration.sql b/api/prisma/migrations/20240421210417_fix_remove_destip/migration.sql
similarity index 100%
rename from prisma/migrations/20240421210417_fix_remove_destip/migration.sql
rename to api/prisma/migrations/20240421210417_fix_remove_destip/migration.sql
diff --git a/prisma/migrations/20240425125737_fix_adds_protocol_field/migration.sql b/api/prisma/migrations/20240425125737_fix_adds_protocol_field/migration.sql
similarity index 100%
rename from prisma/migrations/20240425125737_fix_adds_protocol_field/migration.sql
rename to api/prisma/migrations/20240425125737_fix_adds_protocol_field/migration.sql
diff --git a/prisma/migrations/migration_lock.toml b/api/prisma/migrations/migration_lock.toml
similarity index 100%
rename from prisma/migrations/migration_lock.toml
rename to api/prisma/migrations/migration_lock.toml
diff --git a/prisma/schema.prisma b/api/prisma/schema.prisma
similarity index 100%
rename from prisma/schema.prisma
rename to api/prisma/schema.prisma
diff --git a/prod-docker.env b/api/prod-docker.env
similarity index 100%
rename from prod-docker.env
rename to api/prod-docker.env
diff --git a/routes/NextNet API/Backend/Create.bru b/api/routes/NextNet API/Backend/Create.bru
similarity index 100%
rename from routes/NextNet API/Backend/Create.bru
rename to api/routes/NextNet API/Backend/Create.bru
diff --git a/routes/NextNet API/Backend/Lookup.bru b/api/routes/NextNet API/Backend/Lookup.bru
similarity index 100%
rename from routes/NextNet API/Backend/Lookup.bru
rename to api/routes/NextNet API/Backend/Lookup.bru
diff --git a/routes/NextNet API/Backend/Remove.bru b/api/routes/NextNet API/Backend/Remove.bru
similarity index 100%
rename from routes/NextNet API/Backend/Remove.bru
rename to api/routes/NextNet API/Backend/Remove.bru
diff --git a/routes/NextNet API/Forward/Create.bru b/api/routes/NextNet API/Forward/Create.bru
similarity index 100%
rename from routes/NextNet API/Forward/Create.bru
rename to api/routes/NextNet API/Forward/Create.bru
diff --git a/routes/NextNet API/Forward/Get Inbound Connections.bru b/api/routes/NextNet API/Forward/Get Inbound Connections.bru
similarity index 100%
rename from routes/NextNet API/Forward/Get Inbound Connections.bru
rename to api/routes/NextNet API/Forward/Get Inbound Connections.bru
diff --git a/routes/NextNet API/Forward/Lookup.bru b/api/routes/NextNet API/Forward/Lookup.bru
similarity index 100%
rename from routes/NextNet API/Forward/Lookup.bru
rename to api/routes/NextNet API/Forward/Lookup.bru
diff --git a/routes/NextNet API/Forward/Remove.bru b/api/routes/NextNet API/Forward/Remove.bru
similarity index 100%
rename from routes/NextNet API/Forward/Remove.bru
rename to api/routes/NextNet API/Forward/Remove.bru
diff --git a/routes/NextNet API/Forward/Start.bru b/api/routes/NextNet API/Forward/Start.bru
similarity index 100%
rename from routes/NextNet API/Forward/Start.bru
rename to api/routes/NextNet API/Forward/Start.bru
diff --git a/routes/NextNet API/Forward/Stop.bru b/api/routes/NextNet API/Forward/Stop.bru
similarity index 100%
rename from routes/NextNet API/Forward/Stop.bru
rename to api/routes/NextNet API/Forward/Stop.bru
diff --git a/routes/NextNet API/Get Permissions.bru b/api/routes/NextNet API/Get Permissions.bru
similarity index 100%
rename from routes/NextNet API/Get Permissions.bru
rename to api/routes/NextNet API/Get Permissions.bru
diff --git a/routes/NextNet API/Users/Create.bru b/api/routes/NextNet API/Users/Create.bru
similarity index 100%
rename from routes/NextNet API/Users/Create.bru
rename to api/routes/NextNet API/Users/Create.bru
diff --git a/routes/NextNet API/Users/Log In.bru b/api/routes/NextNet API/Users/Log In.bru
similarity index 100%
rename from routes/NextNet API/Users/Log In.bru
rename to api/routes/NextNet API/Users/Log In.bru
diff --git a/routes/NextNet API/Users/Lookup.bru b/api/routes/NextNet API/Users/Lookup.bru
similarity index 100%
rename from routes/NextNet API/Users/Lookup.bru
rename to api/routes/NextNet API/Users/Lookup.bru
diff --git a/routes/NextNet API/Users/Remove.bru b/api/routes/NextNet API/Users/Remove.bru
similarity index 100%
rename from routes/NextNet API/Users/Remove.bru
rename to api/routes/NextNet API/Users/Remove.bru
diff --git a/routes/NextNet API/bruno.json b/api/routes/NextNet API/bruno.json
similarity index 100%
rename from routes/NextNet API/bruno.json
rename to api/routes/NextNet API/bruno.json
diff --git a/routes/NextNet API/runroute.sh b/api/routes/NextNet API/runroute.sh
similarity index 100%
rename from routes/NextNet API/runroute.sh
rename to api/routes/NextNet API/runroute.sh
diff --git a/src/backendimpl/base.ts b/api/src/backendimpl/base.ts
similarity index 100%
rename from src/backendimpl/base.ts
rename to api/src/backendimpl/base.ts
diff --git a/src/backendimpl/index.ts b/api/src/backendimpl/index.ts
similarity index 100%
rename from src/backendimpl/index.ts
rename to api/src/backendimpl/index.ts
diff --git a/src/backendimpl/ssh.ts b/api/src/backendimpl/ssh.ts
similarity index 100%
rename from src/backendimpl/ssh.ts
rename to api/src/backendimpl/ssh.ts
diff --git a/src/index.ts b/api/src/index.ts
similarity index 100%
rename from src/index.ts
rename to api/src/index.ts
diff --git a/src/libs/backendInit.ts b/api/src/libs/backendInit.ts
similarity index 100%
rename from src/libs/backendInit.ts
rename to api/src/libs/backendInit.ts
diff --git a/src/libs/generateToken.ts b/api/src/libs/generateToken.ts
similarity index 100%
rename from src/libs/generateToken.ts
rename to api/src/libs/generateToken.ts
diff --git a/src/libs/permissions.ts b/api/src/libs/permissions.ts
similarity index 100%
rename from src/libs/permissions.ts
rename to api/src/libs/permissions.ts
diff --git a/src/libs/types.ts b/api/src/libs/types.ts
similarity index 100%
rename from src/libs/types.ts
rename to api/src/libs/types.ts
diff --git a/src/routes/ROUTE_PLAN.md b/api/src/routes/ROUTE_PLAN.md
similarity index 100%
rename from src/routes/ROUTE_PLAN.md
rename to api/src/routes/ROUTE_PLAN.md
diff --git a/src/routes/backends/create.ts b/api/src/routes/backends/create.ts
similarity index 100%
rename from src/routes/backends/create.ts
rename to api/src/routes/backends/create.ts
diff --git a/src/routes/backends/lookup.ts b/api/src/routes/backends/lookup.ts
similarity index 100%
rename from src/routes/backends/lookup.ts
rename to api/src/routes/backends/lookup.ts
diff --git a/src/routes/backends/remove.ts b/api/src/routes/backends/remove.ts
similarity index 100%
rename from src/routes/backends/remove.ts
rename to api/src/routes/backends/remove.ts
diff --git a/src/routes/forward/connections.ts b/api/src/routes/forward/connections.ts
similarity index 100%
rename from src/routes/forward/connections.ts
rename to api/src/routes/forward/connections.ts
diff --git a/src/routes/forward/create.ts b/api/src/routes/forward/create.ts
similarity index 100%
rename from src/routes/forward/create.ts
rename to api/src/routes/forward/create.ts
diff --git a/src/routes/forward/lookup.ts b/api/src/routes/forward/lookup.ts
similarity index 100%
rename from src/routes/forward/lookup.ts
rename to api/src/routes/forward/lookup.ts
diff --git a/src/routes/forward/remove.ts b/api/src/routes/forward/remove.ts
similarity index 100%
rename from src/routes/forward/remove.ts
rename to api/src/routes/forward/remove.ts
diff --git a/src/routes/forward/start.ts b/api/src/routes/forward/start.ts
similarity index 100%
rename from src/routes/forward/start.ts
rename to api/src/routes/forward/start.ts
diff --git a/src/routes/forward/stop.ts b/api/src/routes/forward/stop.ts
similarity index 100%
rename from src/routes/forward/stop.ts
rename to api/src/routes/forward/stop.ts
diff --git a/src/routes/getPermissions.ts b/api/src/routes/getPermissions.ts
similarity index 100%
rename from src/routes/getPermissions.ts
rename to api/src/routes/getPermissions.ts
diff --git a/src/routes/user/create.ts b/api/src/routes/user/create.ts
similarity index 100%
rename from src/routes/user/create.ts
rename to api/src/routes/user/create.ts
diff --git a/src/routes/user/login.ts b/api/src/routes/user/login.ts
similarity index 100%
rename from src/routes/user/login.ts
rename to api/src/routes/user/login.ts
diff --git a/src/routes/user/lookup.ts b/api/src/routes/user/lookup.ts
similarity index 100%
rename from src/routes/user/lookup.ts
rename to api/src/routes/user/lookup.ts
diff --git a/src/routes/user/remove.ts b/api/src/routes/user/remove.ts
similarity index 100%
rename from src/routes/user/remove.ts
rename to api/src/routes/user/remove.ts
diff --git a/srcpatch.sh b/api/srcpatch.sh
similarity index 100%
rename from srcpatch.sh
rename to api/srcpatch.sh
diff --git a/tsconfig.json b/api/tsconfig.json
similarity index 100%
rename from tsconfig.json
rename to api/tsconfig.json
diff --git a/docker-compose.yml b/docker-compose.yml
index 9ec9e23..fd26c5f 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,9 +1,9 @@
services:
- nextnet:
+ nextnet-api:
build:
- context: "."
+ context: "./api"
dockerfile: Dockerfile
- image: nextnet/latest
+ image: nextnet-api/latest
container_name: nextnet-api
restart: always
ports:
diff --git a/init.sh b/init.sh
old mode 100755
new mode 100644
index da99489..e4586ef
--- a/init.sh
+++ b/init.sh
@@ -1,32 +1,3 @@
-if [ ! -d ".tmp" ]; then
- echo "Hello and welcome to the NextNet project! Please wait while I initialize things for you..."
- cp dev.env .env
- mkdir .tmp
-fi
-
-lsof -i:5432 | grep postgres 2> /dev/null > /dev/null
-IS_PG_RUNNING=$?
-
-if [ ! -f ".tmp/ispginit" ]; then
- if [[ "$IS_PG_RUNNING" == 0 ]]; then
- kill -9 $(lsof -t -i:5432) > /dev/null 2> /dev/null
- fi
-
- echo " - Database not initialized! Initializing database..."
- mkdir .tmp/pglock
-
- initdb -D .tmp/db
- pg_ctl -D .tmp/db -l .tmp/logfile -o "--unix_socket_directories='$PWD/.tmp/pglock/'" start
- createdb -h localhost -p 5432 nextnet
-
- psql -h localhost -p 5432 nextnet -c "CREATE ROLE nextnet WITH LOGIN SUPERUSER PASSWORD 'nextnet';"
-
- npm install --save-dev
- npx prisma migrate dev
-
- touch .tmp/ispginit
-elif [[ "$IS_PG_RUNNING" == 1 ]]; then
- pg_ctl -D .tmp/db -l .tmp/logfile -o "--unix_socket_directories='$PWD/.tmp/pglock/'" start
-fi
-
-source .env # Make sure we actually load correctly
\ No newline at end of file
+pushd api > /dev/null 2> /dev/null
+source init.sh
+popd > /dev/null 2> /dev/null
\ No newline at end of file