This commit is contained in:
2025-09-11 17:05:56 +02:00
parent 5b1a528748
commit 7b604df87c
3 changed files with 235 additions and 101 deletions

View File

@@ -1,4 +1,6 @@
import fs from 'fs';
import swaggerJsdoc from "swagger-jsdoc";
import swaggerUi from "swagger-ui-express";
import https from 'https';
import express from 'express';
import cors from 'cors';
@@ -10,6 +12,16 @@ import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.join(path.dirname(__filename), ".."); // going back a dir cuz code is in src/
const app = express();
const specs = swaggerJsdoc({
definition: {
openapi: "3.0.0",
info: {
title: "Analogue Game Assistent API",
version: "1.0.0",
},
},
apis: ["./src/api.js"],
});
initDB();
@@ -19,13 +31,12 @@ app.use(express.urlencoded({ extended: true }))
app.use(express.static(path.join(__dirname, "public"), {
dotfiles: "ignore"
}));
app.use("/api/docs", swaggerUi.serve, swaggerUi.setup(specs));
app.use("/api", apiRouter);
const options = {
const server = https.createServer({
key: fs.readFileSync('server.key'),
cert: fs.readFileSync('server.cert')
};
const server = https.createServer(options, app).listen(5555, () => {
}, app).listen(5555, () => {
console.log(`Server running on http://localhost:${server.address().port}`);
});