Steps to Create a Server
Step 1: Create a server in your terminal using the following command.
npm init -v
Step 2: Install the following package in your server using the following command.
npm install express express-rate-limit
Example: Below is an example of security basic in MERN application.
Javascript
const express = require( 'express' ); const rateLimit = require( 'express-rate-limit' ); // Create the Express app const app = express(); // Define rate limit configuration const limiter = rateLimit({ windowMs: 1 * 60 * 1000, // 1 minutes window max: 10, // Allow 100 requests per window message: `Too many requests from this IP, please try again later`, }); // Apply rate limiter to all routes app.use(limiter); // Sample route handler app.get( '/' , (req, res) => { res.send( 'Hello World!' ); }); // Start the server const port = process.env.PORT || 3000; app.listen(port, () => { console.log(`Server listening on port ${port}`); }); |
Start your server using the following command.
node server.js
Output:
Security Basics in MERN
Web development refers to the creating, building, and maintaining of websites. It includes aspects such as web design, web publishing, web programming, and database management. One of the most famous stacks that is used for Web Development is the MERN stack. This stack provides an end-to-end framework for the users to work in and each of these technologies plays a big part in the development of web applications.