server.app-builder
TypeScript icon, indicating that this package has built-in type declarations

5.0.1 • Public • Published

server.app-builder

install: npm install server.app-builder

An abstraction over the http.Server class that uses promise-based middleware

import { Server } from 'server.app-builder'
 
const app = new Server()
 
app.use(async (env, next) => {
  let start = Date.now()
  await next()
  env.res.end('Hello World')
  console.log(`request took ${Date.now() - start} milliseconds`)
})
 
app.listen(8080)
  .then(() => console.log('Listening on port 8080'))

The argument passed to the middleware functions includes req and res properties. Which are instances of http.IncomingMessage and http.ServerResponse respectively. The argument can be modified arbitrarily by the middleware functions and is created per request.

The module has two named exports: Server and Context; and the default export -- a factory for creating Server instances

Readme

Keywords

Package Sidebar

Install

npm i server.app-builder

Weekly Downloads

2

Version

5.0.1

License

MIT

Last publish

Collaborators

  • calebboyd