72 lines
1.8 KiB
JavaScript
Executable File
72 lines
1.8 KiB
JavaScript
Executable File
// npm install express body-parser swagger-jsdoc swagger-ui-express cookie-parser cors
|
|
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 jjungTableApp from './back/apps/jjungTable_index.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: `http://localhost:7002`,
|
|
description: 'Local 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(7002, () => {
|
|
console.log(`Server running at http://localhost:7002/`);
|
|
});
|
|
|
|
// const sManagement_server = express();
|
|
// sManagement_server.use(sManagementApp);
|
|
// sManagement_server.listen(6004, () => {
|
|
// console.log(`Server running at https://localhost:6004/`);
|
|
// });
|