move to src

This commit is contained in:
Alex Holliday
2025-07-25 15:33:48 -07:00
parent acc910cbc0
commit 1c47c8ce2c
127 changed files with 71 additions and 19 deletions

View File

@@ -10,4 +10,4 @@ COPY ./server/ ./
EXPOSE 52345
CMD ["node", "index.js"]
CMD ["node", "src/index.js"]

View File

@@ -22,4 +22,4 @@ RUN chmod +x ./scripts/inject-vars.sh
EXPOSE 52345
CMD ./scripts/inject-vars.sh && node ./index.js
CMD ./scripts/inject-vars.sh && node ./src/index.js

View File

@@ -22,4 +22,4 @@ RUN chmod +x ./scripts/inject-vars.sh
EXPOSE 52345
CMD ./scripts/inject-vars.sh && node ./index.js
CMD ./scripts/inject-vars.sh && node ./src/index.js

View File

@@ -12,10 +12,10 @@ declare -A services=(
)
for service in "${!services[@]}"; do
docker buildx build \
--platform linux/amd64,linux/arm64 \
docker build \
-f "${services[$service]}" \
-t "$service" \
.
if [ $? -ne 0 ]; then
echo "Error building $service image. Exiting..."

View File

@@ -10,4 +10,4 @@ COPY ./server/ ./
EXPOSE 52345
CMD ["node", "index.js"]
CMD ["node", "src/index.js"]

View File

@@ -12,4 +12,4 @@ COPY ./server ./
EXPOSE 52345
CMD ["node", "index.js"]
CMD ["node", "src/index.js"]

View File

@@ -12,4 +12,4 @@ COPY ./server ./
EXPOSE 52345
CMD ["node", "index.js"]
CMD ["node", "src/index.js"]

10
server/index.js Executable file → Normal file
View File

@@ -1,14 +1,14 @@
import { initializeServices } from "./config/services.js";
import { initializeControllers } from "./config/controllers.js";
import { createApp } from "./app.js";
import { initializeServices } from "./src/config/services.js";
import { initializeControllers } from "./src/config/controllers.js";
import { createApp } from "./src/app.js";
import { initShutdownListener } from "./shutdown.js";
import logger from "./utils/logger.js";
import { fileURLToPath } from "url";
import path from "path";
import fs from "fs";
import SettingsService from "./service/system/settingsService.js";
import AppSettings from "./db/models/AppSettings.js";
import SettingsService from "./src/service/system/settingsService.js";
import AppSettings from "./src/db/models/AppSettings.js";
const SERVICE_NAME = "Server";

View File

@@ -1,5 +1,5 @@
{
"ignore": ["locales/*", "*.log", "node_modules/*"],
"watch": ["*.js", "*.json"],
"ignore": ["src/locales/*", "*.log", "node_modules/*"],
"watch": ["src/**/*.js", "*.json"],
"ext": "js,json"
}

View File

@@ -6,7 +6,7 @@
"type": "module",
"scripts": {
"test": "c8 mocha",
"dev": "nodemon index.js",
"dev": "nodemon src/index.js",
"lint": "eslint .",
"lint-fix": "eslint --fix .",
"format": "prettier --write .",

View File

@@ -1 +0,0 @@
export const startServer = () => {};

View File

@@ -1,7 +1,5 @@
import mongoose from "mongoose";
import { BaseCheckSchema } from "./Check.js";
import logger from "../../utils/logger.js";
import { time } from "console";
const AuditSchema = mongoose.Schema({
id: { type: String, required: true },
title: { type: String, required: true },

55
server/src/index.js Executable file
View File

@@ -0,0 +1,55 @@
import { initializeServices } from "./config/services.js";
import { initializeControllers } from "./config/controllers.js";
import { createApp } from "./app.js";
import { initShutdownListener } from "./shutdown.js";
import logger from "./utils/logger.js";
import { fileURLToPath } from "url";
import path from "path";
import fs from "fs";
import SettingsService from "./service/system/settingsService.js";
import AppSettings from "./db/models/AppSettings.js";
const SERVICE_NAME = "Server";
const startApp = async () => {
// FE path
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const openApiSpec = JSON.parse(fs.readFileSync(path.join(__dirname, "../openapi.json"), "utf8"));
const frontendPath = path.join(__dirname, "public");
// Create services
const settingsService = new SettingsService(AppSettings);
const appSettings = settingsService.loadSettings();
// Initialize services
const services = await initializeServices(appSettings, settingsService);
// Initialize controllers
const controllers = initializeControllers(services);
const app = createApp({
services,
controllers,
appSettings,
frontendPath,
openApiSpec,
});
const port = appSettings.port || 52345;
const server = app.listen(port, () => {
logger.info({ message: `Server started on port:${port}` });
});
initShutdownListener(server, services);
};
startApp().catch((error) => {
logger.error({
message: error.message,
service: SERVICE_NAME,
method: "startApp",
stack: error.stack,
});
process.exit(1);
});

Some files were not shown because too many files have changed in this diff Show More