Node.js HTTP server with a slick router used by AdonisJs. Think of it as an ExpressJs style server written in Typescript.
Install the package from npm registry as follows:
npm i @adonisjs/http-server
# yarn
yarn add @adonisjs/http-server
and then use it as follows:
import proxyaddr from 'proxy-addr'
import { createServer } from 'http'
import { Logger } from '@adonisjs/logger/build/standalone'
import { Profiler } from '@adonisjs/profiler/build/standalone'
import { Server } from '@adonisjs/http-server/build/standalone'
const logger = new Logger({ enabled: false, level: 'trace', name: 'adonis' })
const profiler = new Profiler({})
const config = {
etag: false,
jsonpCallbackName: 'callback',
cookie: {},
subdomainOffset: 2,
generateRequestId: false,
secret: Math.random().toFixed(36).substring(2, 38),
trustProxy: proxyaddr.compile('loopback'),
allowMethodSpoofing: false,
}
const server = new Server({} as any, logger, profiler, config)
server.optimize()
createServer(server.handle.bind(server)).listen(3000)
AdonisJs has one of the most advanced and fast router. It has support for Route groups
, Resourceful resources
and many more.
router.group(() => {
router.get('/', async () => {
})
}).prefix('v1')
Following is the list of actions profiled during an HTTP request
- http:request
- http:before:hooks
- http:route:match
- http:route:stack
- http:after:hooks
- http:route:handler
We recommend you to check the API docs to get a complete reference of all the classes.
Following are the autogenerated files via Typedoc