chore: Bumps dependencies, rewrites development environment system.
This commit is contained in:
parent
c0a12f53d1
commit
0965c56547
12 changed files with 1146 additions and 1265 deletions
|
@ -1,4 +1,4 @@
|
|||
FROM node:20.11.1-bookworm
|
||||
FROM node:22.11.0-bookworm
|
||||
LABEL org.opencontainers.image.source="https://github.com/greysoh/nextnet"
|
||||
WORKDIR /app/
|
||||
COPY src /app/src
|
||||
|
|
32
api/init.sh
32
api/init.sh
|
@ -1,32 +0,0 @@
|
|||
if [ ! -d ".tmp" ]; then
|
||||
echo "Please wait while I initialize the backend source 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
|
1331
api/package-lock.json
generated
1331
api/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -14,25 +14,25 @@
|
|||
"author": "greysoh",
|
||||
"license": "BSD-3-Clause",
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.2.0",
|
||||
"@eslint/js": "^9.16.0",
|
||||
"@types/bcrypt": "^5.0.2",
|
||||
"@types/node": "^20.12.7",
|
||||
"@types/ssh2": "^1.15.0",
|
||||
"@types/ws": "^8.5.10",
|
||||
"eslint": "^8.57.0",
|
||||
"globals": "^15.2.0",
|
||||
"nodemon": "^3.0.3",
|
||||
"pino-pretty": "^11.0.0",
|
||||
"prettier": "^3.2.5",
|
||||
"prisma": "^5.13.0",
|
||||
"typescript": "^5.3.3",
|
||||
"typescript-eslint": "^7.8.0"
|
||||
"@types/node": "^22.10.1",
|
||||
"@types/ssh2": "^1.15.1",
|
||||
"@types/ws": "^8.5.13",
|
||||
"eslint": "^9.16.0",
|
||||
"globals": "^15.12.0",
|
||||
"nodemon": "^3.1.7",
|
||||
"pino-pretty": "^13.0.0",
|
||||
"prettier": "^3.4.1",
|
||||
"prisma": "^5.22.0",
|
||||
"typescript": "^5.7.2",
|
||||
"typescript-eslint": "^8.16.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fastify/websocket": "^10.0.1",
|
||||
"@prisma/client": "^5.13.0",
|
||||
"@fastify/websocket": "^11.0.1",
|
||||
"@prisma/client": "^6.0.0",
|
||||
"bcrypt": "^5.1.1",
|
||||
"fastify": "^4.26.2",
|
||||
"fastify": "^5.1.0",
|
||||
"node-ssh": "^13.2.0"
|
||||
}
|
||||
}
|
||||
|
|
20
dev-docker-compose.yml
Normal file
20
dev-docker-compose.yml
Normal file
|
@ -0,0 +1,20 @@
|
|||
# This WILL NOT work for production deployments
|
||||
# This file only contains dependencies for the backend and frontend,
|
||||
# excluding the actual backend and frontend.
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:17.2
|
||||
container_name: nextnet-postgres
|
||||
restart: always
|
||||
environment:
|
||||
POSTGRES_DB: nextnet
|
||||
POSTGRES_PASSWORD: nextnet
|
||||
POSTGRES_USER: nextnet
|
||||
ports:
|
||||
- 5432:5432
|
||||
volumes:
|
||||
- nextnet_dev_postgres_data:/var/lib/postgresql/data
|
||||
|
||||
volumes:
|
||||
nextnet_dev_postgres_data:
|
|
@ -24,7 +24,7 @@ services:
|
|||
- ssh_key_data:/app/keys
|
||||
|
||||
db:
|
||||
image: postgres:15.4
|
||||
image: postgres:17.2
|
||||
container_name: nextnet-postgres
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
|
|
38
init.sh
38
init.sh
|
@ -1,5 +1,35 @@
|
|||
pushd api > /dev/null 2> /dev/null
|
||||
source init.sh
|
||||
#!/usr/bin/env bash
|
||||
owned_docker=1
|
||||
|
||||
git config --local include.path .gitconfig
|
||||
popd > /dev/null 2> /dev/null
|
||||
# Test if Postgres is up
|
||||
lsof -i:5432 2> /dev/null > /dev/null
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
owned_docker=0
|
||||
docker compose -f dev-docker-compose.yml up -d
|
||||
fi
|
||||
|
||||
if [ ! -f "api/.env" ]; then
|
||||
cp api/dev.env api/.env
|
||||
fi
|
||||
|
||||
if [ ! -d "api/node_modules" ]; then
|
||||
pushd api > /dev/null
|
||||
npm install --save-dev
|
||||
npx prisma migrate dev
|
||||
popd > /dev/null
|
||||
fi
|
||||
|
||||
source api/.env
|
||||
|
||||
on_exit() {
|
||||
cd $(git rev-parse --show-toplevel)
|
||||
|
||||
if [ $owned_docker -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
docker compose -f dev-docker-compose.yml down
|
||||
}
|
||||
|
||||
trap "on_exit" exit
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FROM node:20.11.1-bookworm
|
||||
FROM node:22.11.0-bookworm
|
||||
LABEL org.opencontainers.image.source="https://github.com/greysoh/nextnet"
|
||||
WORKDIR /app/
|
||||
COPY src /app/src
|
||||
|
|
149
lom/diff.diff
149
lom/diff.diff
|
@ -1,149 +0,0 @@
|
|||
diff --git a/api/src/backendimpl/passyfire-reimpl/routes.ts b/api/src/backendimpl/passyfire-reimpl/routes.ts
|
||||
index 2961483..4519a87 100644
|
||||
--- a/api/src/backendimpl/passyfire-reimpl/routes.ts
|
||||
+++ b/api/src/backendimpl/passyfire-reimpl/routes.ts
|
||||
@@ -47,25 +47,6 @@ export function route(instance: PassyFireBackendProvider) {
|
||||
|
||||
for (const spoofedRoute of unsupportedSpoofedRoutes) {
|
||||
fastify.post(spoofedRoute, (req, res) => {
|
||||
- if (typeof req.body != "string")
|
||||
- return res.status(400).send({
|
||||
- error: "Invalid token",
|
||||
- });
|
||||
-
|
||||
- try {
|
||||
- JSON.parse(req.body);
|
||||
- } catch (e) {
|
||||
- return res.status(400).send({
|
||||
- error: "Invalid token",
|
||||
- });
|
||||
- }
|
||||
-
|
||||
- // @ts-expect-error
|
||||
- if (!req.body.token)
|
||||
- return res.status(400).send({
|
||||
- error: "Invalid token",
|
||||
- });
|
||||
-
|
||||
return res.status(403).send({
|
||||
error: "Invalid scope(s)",
|
||||
});
|
||||
diff --git a/lom/src/commands/backends.ts b/lom/src/commands/backends.ts
|
||||
index baba3d1..d16cac1 100644
|
||||
--- a/lom/src/commands/backends.ts
|
||||
+++ b/lom/src/commands/backends.ts
|
||||
@@ -16,6 +16,18 @@ type BackendLookupSuccess = {
|
||||
}[];
|
||||
};
|
||||
|
||||
+const addRequiredOptions = {
|
||||
+ ssh: [
|
||||
+ "sshKey",
|
||||
+ "username",
|
||||
+ "host",
|
||||
+ ],
|
||||
+
|
||||
+ passyfire: [
|
||||
+ "host"
|
||||
+ ]
|
||||
+};
|
||||
+
|
||||
export async function run(
|
||||
argv: string[],
|
||||
println: PrintLine,
|
||||
@@ -58,12 +70,12 @@ export async function run(
|
||||
);
|
||||
|
||||
addBackend.option(
|
||||
- "-u, --username",
|
||||
+ "-u, --username <user>",
|
||||
"(SSH, PassyFire) Username to authenticate with. With PassyFire, it's the username you create",
|
||||
);
|
||||
|
||||
addBackend.option(
|
||||
- "-h, --host",
|
||||
+ "-h, --host <host>",
|
||||
"(SSH, PassyFire) Host to connect to. With PassyFire, it's what you listen on",
|
||||
);
|
||||
|
||||
@@ -86,10 +98,70 @@ export async function run(
|
||||
);
|
||||
|
||||
addBackend.option(
|
||||
- "-p, --password",
|
||||
+ "-p, --password <password>",
|
||||
"(PassyFire) What password you want to use for the primary user",
|
||||
);
|
||||
|
||||
+ addBackend.action(async(name: string, provider: string, options: {
|
||||
+ description?: string,
|
||||
+ forceCustomParameters?: boolean,
|
||||
+ customParameters?: string,
|
||||
+
|
||||
+ // SSH (mostly)
|
||||
+ sshKey?: string,
|
||||
+ username?: string,
|
||||
+ host?: string,
|
||||
+
|
||||
+ // PassyFire (mostly)
|
||||
+ isProxied?: boolean,
|
||||
+ proxiedPortStr?: number,
|
||||
+ guest?: boolean,
|
||||
+ userAsk?: boolean,
|
||||
+ password?: string
|
||||
+ }) => {
|
||||
+ // Yes it can index for what we need it to do.
|
||||
+ // @ts-expect-error
|
||||
+ const isUnsupportedPlatform: boolean = !addRequiredOptions[provider];
|
||||
+
|
||||
+ if (isUnsupportedPlatform) {
|
||||
+ println("WARNING: Platform is not natively supported by the LOM yet!\n");
|
||||
+ }
|
||||
+
|
||||
+ let connectionDetails: string = "";
|
||||
+
|
||||
+ if (options.forceCustomParameters || isUnsupportedPlatform) {
|
||||
+ if (typeof options.customParameters != "string") {
|
||||
+ return println("ERROR: You are missing the custom parameters option!\n");
|
||||
+ }
|
||||
+
|
||||
+ connectionDetails = options.customParameters;
|
||||
+ } else if (provider == "ssh") {
|
||||
+ for (const argument of addRequiredOptions["ssh"]) {
|
||||
+ // No.
|
||||
+ // @ts-expect-error
|
||||
+ const hasArgument = options[argument] as any;
|
||||
+
|
||||
+ if (!hasArgument) {
|
||||
+ return println("ERROR: Missing argument '%s'\n", hasArgument);
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ // todo!
|
||||
+ } else if (provider == "passyfire") {
|
||||
+ for (const argument of addRequiredOptions["passyfire"]) {
|
||||
+ // No.
|
||||
+ // @ts-expect-error
|
||||
+ const hasArgument = options[argument];
|
||||
+
|
||||
+ if (!hasArgument) {
|
||||
+ return println("ERROR: Missing argument '%s'\n", hasArgument);
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ // todo!
|
||||
+ }
|
||||
+ });
|
||||
+
|
||||
const removeBackend = new SSHCommand(println, "rm");
|
||||
removeBackend.description("Removes a backend");
|
||||
removeBackend.argument("<id>", "ID of the backend");
|
||||
@@ -269,7 +341,7 @@ export async function run(
|
||||
|
||||
// It would make sense to check this, then parse argv, however this causes issues with
|
||||
// the application name not displaying correctly.
|
||||
-
|
||||
+
|
||||
if (argv.length == 1) {
|
||||
println("No arguments specified!\n\n");
|
||||
program.help();
|
763
lom/package-lock.json
generated
763
lom/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -14,21 +14,21 @@
|
|||
"author": "greysoh",
|
||||
"license": "BSD-3-Clause",
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.2.0",
|
||||
"@types/node": "^20.12.8",
|
||||
"@types/ssh2": "^1.15.0",
|
||||
"@types/yargs": "^17.0.32",
|
||||
"eslint": "^8.57.0",
|
||||
"globals": "^15.2.0",
|
||||
"nodemon": "^3.0.3",
|
||||
"typescript": "^5.3.3",
|
||||
"typescript-eslint": "^7.8.0"
|
||||
"@eslint/js": "^9.16.0",
|
||||
"@types/node": "^22.10.1",
|
||||
"@types/ssh2": "^1.15.1",
|
||||
"@types/yargs": "^17.0.33",
|
||||
"eslint": "^9.16.0",
|
||||
"globals": "^15.12.0",
|
||||
"nodemon": "^3.1.7",
|
||||
"typescript": "^5.7.2",
|
||||
"typescript-eslint": "^8.16.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.7.4",
|
||||
"commander": "^12.0.0",
|
||||
"axios": "^1.7.8",
|
||||
"commander": "^12.1.0",
|
||||
"patch-package": "^8.0.0",
|
||||
"ssh2": "^1.15.0",
|
||||
"ssh2": "^1.16.0",
|
||||
"string-argv": "^0.3.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,9 @@
|
|||
# api/
|
||||
nodejs
|
||||
openssl
|
||||
postgresql
|
||||
lsof
|
||||
go
|
||||
gopls
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
|
@ -14,11 +15,6 @@
|
|||
export PRISMA_QUERY_ENGINE_LIBRARY=${pkgs.prisma-engines}/lib/libquery_engine.node
|
||||
export PRISMA_SCHEMA_ENGINE_BINARY=${pkgs.prisma-engines}/bin/schema-engine
|
||||
|
||||
if [ ! -d ".tmp" ]; then
|
||||
echo "Hello and welcome to the NextNet project!"
|
||||
mkdir .tmp
|
||||
fi
|
||||
|
||||
source init.sh
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue