An enhanced HTTP createServer module for Node.js.
It provides a decorated version of IncomingMessage
and ServerResponse
objects.
The API is mostly similar to Koa
Installation
npm add aldo-http
Example
const { createServer } = require('aldo-http')
const server = createServer((request, response) => {
response.send('Hello world!')
})
server.listen(3000)
The above code is similar to the following
const { createServer } = require('http')
const server = createServer((request, response) => {
let content = 'Hello world!'
response.setHeader('Content-Type', 'text/plain; charset=utf-8')
response.setHeader('Content-Length', Buffer.byteLength(content))
response.end(content)
})
server.listen(3000)
Testing
npm test