forked from JJUNGTABLE/Back
76 lines
1.7 KiB
JavaScript
Executable File
76 lines
1.7 KiB
JavaScript
Executable File
// index.js
|
|
|
|
import express from 'express';
|
|
import bodyParser from 'body-parser';
|
|
import swaggerJSDoc from 'swagger-jsdoc';
|
|
import swaggerUi from 'swagger-ui-express';
|
|
import path from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
import cookieParser from 'cookie-parser';
|
|
import cors from 'cors';
|
|
|
|
import { serverURL, serverPort } from './private/config.js';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
console.log(__dirname);
|
|
console.log(process.cwd());
|
|
|
|
const app = express();
|
|
|
|
|
|
|
|
|
|
app.use(cors());
|
|
app.use(bodyParser.json()); // For parsing application/json
|
|
app.use(cookieParser()); // For parsing cookies
|
|
app.use(express.static(path.join(__dirname, 'Front'))); // Serve static files from Pront directory
|
|
|
|
// Swagger setup
|
|
const swaggerDefinition = {
|
|
openapi: '3.0.0',
|
|
info: {
|
|
title: 'My API',
|
|
version: '1.0.0',
|
|
description: 'API documentation',
|
|
},
|
|
servers: [
|
|
{
|
|
url: serverURL,
|
|
description: 'JJ server',
|
|
},
|
|
],
|
|
};
|
|
|
|
const options = {
|
|
swaggerDefinition,
|
|
apis: ['./back/apps/push.js'],
|
|
};
|
|
|
|
const swaggerSpec = swaggerJSDoc(options);
|
|
|
|
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec));
|
|
|
|
app.use((req, res, next) => {
|
|
const host = req.headers.host;
|
|
console.log(`Client connected to host: ${host}`);
|
|
next();
|
|
});
|
|
|
|
|
|
|
|
// Start the server
|
|
|
|
//JJUNGTABLE 서버 연결
|
|
const jjungTable_server = express();
|
|
jjungTable_server.use(jjungTableApp);
|
|
jjungTable_server.listen(serverPort, () => {
|
|
console.log(`Server running`);
|
|
});
|
|
|
|
// const sManagement_server = express();
|
|
// sManagement_server.use(sManagementApp);
|
|
// sManagement_server.listen(6004, () => {
|
|
// console.log(`Server running at https://localhost:6004/`);
|
|
// });
|