Files
parcer/server/src/server.ts

38 lines
1.0 KiB
TypeScript
Raw Normal View History

2024-05-30 04:49:38 +05:30
import express from 'express';
import http from 'http';
import cors from 'cors';
import 'dotenv/config';
2024-09-15 17:57:45 +05:30
import { record, workflow, storage, auth } from './routes';
2024-05-30 04:49:38 +05:30
import { BrowserPool } from "./browser-management/classes/BrowserPool";
import logger from './logger'
import { SERVER_PORT } from "./constants/config";
2024-09-11 13:21:16 +05:30
import { Server } from "socket.io";
2024-05-30 04:49:38 +05:30
const app = express();
app.use(cors());
app.use(express.json());
const server = http.createServer(app);
/**
* Globally exported singleton instance of socket.io for socket communication with the client.
* @type {Server}
*/
export const io = new Server(server);
/**
* {@link BrowserPool} globally exported singleton instance for managing browsers.
*/
export const browserPool = new BrowserPool();
app.use('/record', record);
app.use('/workflow', workflow);
app.use('/storage', storage);
2024-09-15 17:57:45 +05:30
app.use('/auth', auth);
2024-05-30 04:49:38 +05:30
app.get('/', function (req, res) {
2024-09-09 05:17:37 +05:30
return res.send('Maxun server started 🚀');
2024-05-30 04:49:38 +05:30
});
2024-09-11 13:21:16 +05:30
server.listen(SERVER_PORT, () => logger.log('info', `Server listening on port ${SERVER_PORT}`));