79 lines
2.0 KiB
JavaScript
Executable File
79 lines
2.0 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 session from 'express-session'; // express-session 추가
|
|
import routes from './apps/app.js'; // ./apps/app.js에서 라우트를 가져옴
|
|
|
|
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/app.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();
|
|
});
|
|
|
|
app.use('/', routes);
|
|
|
|
app.listen(serverPort, () => {
|
|
console.log(`Server running`);
|
|
});
|
|
|
|
// 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/`);
|
|
// });
|