build stuff
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import express from "express";
|
import express from "express";
|
||||||
import { setupRoutes } from "./src/routes/routeHandler.js";
|
import { setupRoutes } from "@/src/routes/routeHandler.js";
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,34 @@
|
|||||||
|
import { apiReference } from "@scalar/express-api-reference";
|
||||||
import type { Express, Response } from "express";
|
import type { Express, Response } from "express";
|
||||||
|
import { openApiSpec } from "../scaler/config.js";
|
||||||
|
|
||||||
export const setupRoutes = (app: Express) => {
|
export const setupRoutes = (app: Express) => {
|
||||||
|
/**
|
||||||
|
* @openapi
|
||||||
|
* /:
|
||||||
|
* get:
|
||||||
|
* summary: Health check
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: Success
|
||||||
|
*/
|
||||||
app.get("/", (_, res: Response) => {
|
app.get("/", (_, res: Response) => {
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
message: "This is just an example of this working",
|
message: "This is just an example of this working",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get("/api/docs.json", (_, res) => {
|
||||||
|
res.json(openApiSpec);
|
||||||
|
});
|
||||||
|
|
||||||
|
app.use(
|
||||||
|
"/api/dos",
|
||||||
|
apiReference({
|
||||||
|
// Put your OpenAPI url here:
|
||||||
|
url: "/openapi.json",
|
||||||
|
theme: "purple",
|
||||||
|
}),
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
38
backend/src/scaler/config.ts
Normal file
38
backend/src/scaler/config.ts
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
//import path from "node:path";
|
||||||
|
//import { fileURLToPath } from "node:url";
|
||||||
|
import type { OpenAPIV3_1 } from "openapi-types";
|
||||||
|
|
||||||
|
//const __filename = fileURLToPath(import.meta.url);
|
||||||
|
// const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
|
// const port = 3000;
|
||||||
|
export const openApiSpec: OpenAPIV3_1.Document = {
|
||||||
|
openapi: "3.1.0",
|
||||||
|
info: {
|
||||||
|
title: "LST API",
|
||||||
|
version: "3.0.0",
|
||||||
|
description: "Label System Tracking API",
|
||||||
|
},
|
||||||
|
servers: [
|
||||||
|
{
|
||||||
|
url: "http://localhost:3000",
|
||||||
|
description: "Development server",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
components: {
|
||||||
|
securitySchemes: {
|
||||||
|
bearerAuth: {
|
||||||
|
type: "http",
|
||||||
|
scheme: "bearer",
|
||||||
|
bearerFormat: "JWT",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
paths: {},
|
||||||
|
tags: [
|
||||||
|
{ name: "Health", description: "Health check endpoints" },
|
||||||
|
{ name: "Printing", description: "Label printing operations" },
|
||||||
|
{ name: "Silo", description: "Silo management" },
|
||||||
|
{ name: "TMS", description: "TMS integration" },
|
||||||
|
],
|
||||||
|
};
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
import { build } from "esbuild";
|
|
||||||
|
|
||||||
await build({
|
|
||||||
entryPoints: ["backend/app.ts"],
|
|
||||||
outfile: "dist/index.cjs",
|
|
||||||
bundle: true,
|
|
||||||
platform: "node",
|
|
||||||
target: ["node24"],
|
|
||||||
minify: true,
|
|
||||||
legalComments: "none",
|
|
||||||
format: "esm",
|
|
||||||
});
|
|
||||||
1140
package-lock.json
generated
1140
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@@ -5,9 +5,11 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"dev:app": "cd backend && node --watch app.ts",
|
"dev:app": "cd backend && tsx watch app.ts",
|
||||||
"build": "esbuild backend/app.ts --bundle --platform=node --minify --outfile=dist/index.cjs --format=esm --external:node:* --legal-comments=none",
|
"build": "esbuild backend/app.ts --bundle --platform=node --minify --outfile=dist/index.js --format=esm --packages=external",
|
||||||
"lint": "tsc"
|
"build:app": "ncc build backend/app.ts -o dist -m -s -e swagger-ui-express -e swagger-ui-dist -e swagger-jsdoc",
|
||||||
|
"lint": "tsc",
|
||||||
|
"start": "node dist/index.js"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -20,9 +22,19 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "2.3.8",
|
"@biomejs/biome": "2.3.8",
|
||||||
"@types/express": "^5.0.6",
|
"@types/express": "^5.0.6",
|
||||||
"esbuild": "0.27.1"
|
"@types/node": "^24.10.1",
|
||||||
|
"@types/swagger-jsdoc": "^6.0.4",
|
||||||
|
"@types/swagger-ui-express": "^4.1.8",
|
||||||
|
"@vercel/ncc": "^0.38.4",
|
||||||
|
"openapi-types": "^12.1.3",
|
||||||
|
"ts-node-dev": "^2.0.0",
|
||||||
|
"tsx": "^4.21.0",
|
||||||
|
"typescript": "^5.9.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "^5.2.1"
|
"@scalar/express-api-reference": "^0.8.28",
|
||||||
|
"better-auth": "^1.4.6",
|
||||||
|
"express": "^5.2.1",
|
||||||
|
"npm-check-updates": "^19.1.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
42
tsconfig.json
Normal file
42
tsconfig.json
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ESNext",
|
||||||
|
"module": "NodeNext",
|
||||||
|
"moduleResolution": "nodenext",
|
||||||
|
"strict": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
"types": ["node", "better-auth"],
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"outDir": "./dist",
|
||||||
|
"removeComments": true,
|
||||||
|
"allowJs": false,
|
||||||
|
"rootDir": "./",
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noUnusedParameters": true,
|
||||||
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
"noUncheckedIndexedAccess": true,
|
||||||
|
"exactOptionalPropertyTypes": true,
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["backend/*"],
|
||||||
|
"@features/*": ["backend/features/*"],
|
||||||
|
"@shared/*": ["backend/shared/*"],
|
||||||
|
"@config/*": ["backend/config/*"]
|
||||||
|
},
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
//"allowImportingTsExtensions": true,
|
||||||
|
"noEmit": false
|
||||||
|
},
|
||||||
|
"include": ["backend/**/*"],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"frontend",
|
||||||
|
"dist",
|
||||||
|
"lstDocs",
|
||||||
|
"database/testFiles",
|
||||||
|
"scripts"
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user