This is a clone of the Express.js framework. It is a lightweight framework that allows you to create a server and handle requests. It is a very simple framework that is easy to use and understand.
- Creates a new instance of the Express framework.
const express = new Express()
- Adds middleware to the middleware stack. Middleware is called in the order it is added.
express.use((req, res, next) => {
console.log('Middleware 1')
next()
})
- Adds a route to the server that only responds to GET requests.
express.get('/', (req, res) => {
res.send('Hello World!')
})
- Adds a route to the server that only responds to POST requests.
express.post('/', (req, res) => {
res.send('Hello World!')
})
- Adds a route to the server that only responds to PUT requests.
express.put('/', (req, res) => {
res.send('Hello World!')
})
- Adds a route to the server that only responds to DELETE requests.
express.delete('/', (req, res) => {
res.send('Hello World!')
})
- Starts the server on the specified port.
express.listen(3000, () => {
console.log('Server is listening on port 3000')
})