build stuff
This commit is contained in:
@@ -1,10 +1,34 @@
|
||||
import { apiReference } from "@scalar/express-api-reference";
|
||||
import type { Express, Response } from "express";
|
||||
import { openApiSpec } from "../scaler/config.js";
|
||||
|
||||
export const setupRoutes = (app: Express) => {
|
||||
/**
|
||||
* @openapi
|
||||
* /:
|
||||
* get:
|
||||
* summary: Health check
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Success
|
||||
*/
|
||||
app.get("/", (_, res: Response) => {
|
||||
res.status(200).json({
|
||||
success: true,
|
||||
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" },
|
||||
],
|
||||
};
|
||||
Reference in New Issue
Block a user