Skip to content

Commit

Permalink
Merge pull request #243 from samyak-aditya/sam_backend
Browse files Browse the repository at this point in the history
Add Helmet Middleware for Enhanced Security in the Backend
  • Loading branch information
Anuj3553 authored Oct 25, 2024
2 parents 6feebdc + 9a2db71 commit efef0cb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 4 additions & 1 deletion server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ const express = require("express");
const { Server } = require("socket.io");
const connectToMongo = require("./db");
const cors = require("cors");
const helmet = require("helmet");
const Avatar = require("./Models/Avatar");
require('dotenv').config(); // Load environment variables from .env file

// Connect to MongoDB
connectToMongo();

const app = express();
const app = express();

const httpServer = require("http").createServer(app);
const io = new Server(httpServer, {
cors: {
Expand All @@ -35,6 +37,7 @@ app.use(cors({

// Middleware to parse JSON requests
app.use(express.json());
app.use(helmet());

// Available routes
app.use("/api/auth", require("./routes/auth"));
Expand Down
10 changes: 10 additions & 0 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"express-validator": "^7.0.1",
"firebase": "^10.10.0",
"google-auth-library": "^9.7.0",
"helmet": "^8.0.0",
"jotai": "^2.10.0",
"jsonwebtoken": "^9.0.2",
"mongodb": "^6.10.0",
Expand All @@ -38,4 +39,4 @@
"devDependencies": {
"nodemon": "^3.1.7"
}
}
}

0 comments on commit efef0cb

Please sign in to comment.