Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,7 @@ Thumbs.db
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
!.yarn/versions

# PGLite storage
pglite-storage
8 changes: 7 additions & 1 deletion autoadmin-ws-server/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
node_modules
npm-debug.log
dist
.env
*.log
.git
.gitignore
*.md
.env.*
10 changes: 10 additions & 0 deletions autoadmin-ws-server/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
HTTP_PORT=8008
WS_PORT=8009
HOST=0.0.0.0

JWT_SECRET=MySuperSecretJwtSecret
PRIVATE_KEY=MySuperSecretEncryptionPrivateKey

CHECK_CONNECTION_TOKEN_URL=http://backend:3000/connection/token

LOG_LEVEL=info
127 changes: 11 additions & 116 deletions autoadmin-ws-server/.gitignore
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,119 +1,14 @@

# Created by https://www.gitignore.io/api/node
# Edit at https://www.gitignore.io/?templates=node

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm
.yarn/*
# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.test.env
.encryption.env

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# rollup.js default build output
dist/
.env
*.log
.DS_Store

# Uncomment the public line if your project uses Gatsby
# https://nextjs.org/blog/next-9-1#public-directory-support
# https://create-react-app.dev/docs/using-the-public-folder/#docsNav
# public

# Storybook build outputs
.out
.storybook-out

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# Temporary folders
tmp/
temp/

#IDE integration files
.idea

#private data
.env.dev
.amazon.env
.development.env
# End of https://www.gitignore.io/api/node
# Yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.pnp.*
4 changes: 0 additions & 4 deletions autoadmin-ws-server/.prettierrc

This file was deleted.

12 changes: 8 additions & 4 deletions autoadmin-ws-server/.ws-server-development.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
JWT_SECRET=MySuperSecretJwtSecret
HTTP_PORT=
WS_PORT=
HTTP_PORT=8008
WS_PORT=8009
HOST=0.0.0.0

JWT_SECRET=MySuperSecretJwtSecret
PRIVATE_KEY=MySuperSecretEncryptionPrivateKey
CHECK_CONNECTION_TOKEN_URL=http://backend:3000/connection/token

CHECK_CONNECTION_TOKEN_URL=http://backend:3000/connection/token

LOG_LEVEL=info
34 changes: 28 additions & 6 deletions autoadmin-ws-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
FROM node:22-slim
FROM node:22-alpine AS builder

WORKDIR /app
COPY package.json yarn.lock /app/
RUN yarn install --network-timeout 1000000
COPY . /app
EXPOSE 8008
CMD ["yarn", "start"]

COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile

COPY tsconfig.json ./
COPY src ./src

RUN yarn build

FROM node:22-alpine

WORKDIR /app

RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001

COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile --production && yarn cache clean

COPY --from=builder /app/dist ./dist

USER nodejs

EXPOSE 8008 8009

CMD ["node", "dist/index.js"]
1 change: 0 additions & 1 deletion autoadmin-ws-server/README.md

This file was deleted.

40 changes: 0 additions & 40 deletions autoadmin-ws-server/buildspec.yml

This file was deleted.

29 changes: 21 additions & 8 deletions autoadmin-ws-server/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
{
"name": "autoadmin-ws-server",
"name": "rocketadmin-ws-server",
"version": "1.0.0",
"main": "src/index.js",
"license": "MIT",
"type": "module",
"license": "UNLICENSED",
"scripts": {
"start": "node src/index.js"
"dev": "tsx watch src/index.ts",
"build": "tsc",
"start": "node dist/index.js",
"lint": "biome check src/",
"lint:fix": "biome check --write src/"
},
"dependencies": {
"axios": "^1.13.2",
"express": "^5.2.1",
"@hono/node-server": "^1.19.9",
"hono": "^4.11.7",
"jsonwebtoken": "^9.0.3",
"lru-cache": "^11.2.4",
"lru-cache": "^11.2.5",
"nanoid": "^5.1.6",
"ws": "^8.18.3"
"pino": "^10.3.0",
"ws": "^8.19.0",
"zod": "^4.3.6"
},
"devDependencies": {
"@biomejs/biome": "2.3.13",
"@types/jsonwebtoken": "^9.0.10",
"@types/node": "^22.10.2",
"@types/ws": "^8.18.1",
"tsx": "^4.21.0",
"typescript": "^5.9.3"
}
}
42 changes: 42 additions & 0 deletions autoadmin-ws-server/src/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Hono } from 'hono';
import { cors } from 'hono/cors';
import { logger as honoLogger } from 'hono/logger';
import { CONSTANTS } from './constants/index.js';
import { executeCommand } from './handlers/command.js';
import { authMiddleware } from './middleware/auth.js';
import { getConnectionsCount } from './services/connections-cache.js';

export function createApp(): Hono {
const app = new Hono();

app.use('*', cors());
app.use('*', honoLogger());

app.get('/', (c) => {
return c.json({ status: CONSTANTS.API_IS_RUNNING });
});

app.get('/health', (c) => {
return c.json({
status: 'healthy',
connections: getConnectionsCount(),
uptime: process.uptime(),
timestamp: new Date().toISOString(),
});
});

app.post('/', authMiddleware, executeCommand);

app.onError((err, c) => {
const status = 'status' in err ? (err.status as number) : 500;
const message = err.message || 'Internal Server Error';

return c.json({ error: message }, status as 400);
});

app.notFound((c) => {
return c.json({ error: 'Not Found' }, 404);
});

return app;
}
19 changes: 19 additions & 0 deletions autoadmin-ws-server/src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export const config = {
httpPort: Number(process.env.HTTP_PORT) || 8008,
wsPort: Number(process.env.WS_PORT) || 8009,
host: process.env.HOST || '0.0.0.0',
jwtSecret: process.env.JWT_SECRET || '',
privateKey: process.env.PRIVATE_KEY || '',
checkConnectionTokenUrl:
process.env.CHECK_CONNECTION_TOKEN_URL || 'http://autoadmin-internal-auth.local:3000/connection/token',
logLevel: process.env.LOG_LEVEL || 'silent',
} as const;

export function validateConfig(): void {
if (!config.jwtSecret) {
throw new Error('JWT_SECRET environment variable is required');
}
if (!config.privateKey) {
throw new Error('PRIVATE_KEY environment variable is required');
}
}
18 changes: 0 additions & 18 deletions autoadmin-ws-server/src/constants/command-type.js

This file was deleted.

Loading
Loading