2024-05-30 04:49:38 +05:30
|
|
|
import express from 'express';
|
|
|
|
|
import http from 'http';
|
|
|
|
|
import cors from 'cors';
|
|
|
|
|
import 'dotenv/config';
|
|
|
|
|
|
|
|
|
|
import { record, workflow, storage } from './routes';
|
|
|
|
|
import { BrowserPool } from "./browser-management/classes/BrowserPool";
|
|
|
|
|
import logger from './logger'
|
|
|
|
|
import { SERVER_PORT } from "./constants/config";
|
|
|
|
|
import {Server} from "socket.io";
|
2024-09-11 13:20:48 +05:30
|
|
|
import { worker } from './workflow-management/scheduler';
|
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();
|
|
|
|
|
|
2024-05-30 04:50:30 +05:30
|
|
|
app.use('/record', record);
|
|
|
|
|
app.use('/workflow', workflow);
|
|
|
|
|
app.use('/storage', storage);
|
|
|
|
|
|
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:20:48 +05:30
|
|
|
/**
|
|
|
|
|
* Starts the worker for the workflow queue.
|
|
|
|
|
*/
|
|
|
|
|
worker.run();
|
|
|
|
|
|
2024-05-30 04:49:38 +05:30
|
|
|
server.listen(SERVER_PORT, () => logger.log('info',`Server listening on port ${SERVER_PORT}`));
|