From 212214ed11d9f9cb0303978b6443dd2a2ef846b0 Mon Sep 17 00:00:00 2001 From: Iniyal Palanisamy <123928113+IniyalPalanisamy@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:00:34 +0530 Subject: [PATCH] Update index.js --- server/index.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/server/index.js b/server/index.js index a630bedb..5607bbd5 100644 --- a/server/index.js +++ b/server/index.js @@ -5,33 +5,34 @@ const cors = require('cors'); const helmet = require('helmet'); const keys = require('./config/keys'); -const routes = require('./routes'); +const routes = require('./routes'); const socket = require('./socket'); const setupDB = require('./utils/db'); const { port } = keys; const app = express(); +// Middleware setup app.use(express.urlencoded({ extended: true })); app.use(express.json()); -app.use( - helmet({ - contentSecurityPolicy: false, - frameguard: true - }) -); +app.use(helmet({ contentSecurityPolicy: false, frameguard: true })); app.use(cors()); +// Database setup setupDB(); + +// Passport configuration require('./config/passport')(app); + +// Routes setup app.use(routes); +// Start server const server = app.listen(port, () => { console.log( - `${chalk.green('✓')} ${chalk.blue( - `Listening on port ${port}. Visit http://localhost:${port}/ in your browser.` - )}` + `${chalk.green('✓')} ${chalk.blue(`Listening on port ${port}. Visit http://localhost:${port}/ in your browser.`)}` ); }); +// Setup WebSocket socket(server);