Initialized Project with default middlewares and helpers, connected to Atlas Instance and created Swagger Setup. Created necessary DB models and authentication-authorization logic
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
import upload from "./upload.js";
|
||||
import user from "./user.js";
|
||||
import profile from "./profile.js";
|
||||
import admin from "./admin.js";
|
||||
|
||||
const GENERAL_CONFIG = {
|
||||
openapi: "3.0.1",
|
||||
info: {
|
||||
title: "Attica Server Application v1",
|
||||
description: "Version 1 of Attica Server Application API",
|
||||
license: {
|
||||
name: "MIT",
|
||||
url: "https://opensource.org/licenses/MIT",
|
||||
},
|
||||
version: "1.0.0",
|
||||
},
|
||||
servers: [
|
||||
{
|
||||
url: "http://localhost:3000/v0/",
|
||||
},
|
||||
{
|
||||
url: "https://erp-server.triadkube.com/v0/",
|
||||
},
|
||||
],
|
||||
security: [
|
||||
{
|
||||
bearerAuth: [],
|
||||
},
|
||||
],
|
||||
components: {
|
||||
securitySchemes: {
|
||||
bearerAuth: {
|
||||
type: "http",
|
||||
scheme: "bearer",
|
||||
bearerFormat: "JWT",
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
let paths = {
|
||||
...user,
|
||||
...profile,
|
||||
...upload,
|
||||
...admin,
|
||||
};
|
||||
|
||||
const getSwaggerDocument = () => {
|
||||
const swaggerDocument = {
|
||||
...GENERAL_CONFIG,
|
||||
paths,
|
||||
};
|
||||
const fileContent = JSON.stringify(swaggerDocument, null, 2);
|
||||
const docPath = path.resolve(path.join(__dirname, "documentation.json"));
|
||||
const existingContent = fs.readFileSync(docPath, "utf8");
|
||||
|
||||
if (existingContent !== fileContent) {
|
||||
console.log("Swagger documentation updated");
|
||||
fs.writeFileSync(docPath, fileContent);
|
||||
}
|
||||
};
|
||||
|
||||
export default getSwaggerDocument;
|
||||
Reference in New Issue
Block a user