Based on this template
Standard batteries-included Ackee suit for an API Core.
Built on top of express and this is all you have to change.
- Promised
listenAsync
. - Destroyable server with
.destroy()
. - Error processing with serializable
HttpJsonError
anderrorHandler
- Includes
- Sentry error reporting support
- Default request handlers (root with info, final handler)
import {
createServer,
jsonParser,
defaultFinalHandler,
defaultRootHandler,
errorHandler,
} from 'unicore';
const server = createServer(options); // Enhanced Express app
server.use(defaultRootHandler);
server.use(errorHandler);
server.use(defaultFinalHandler);
server.listenAsync(3000)
.then(() => console.log('Listening.'))
.then(() => server.destroy())
.then(() => console.log('Server shut down.'));
-> GET http://localhost:3000
<-
{
🦄: "Greetings!",
Application I am running: {
name: "your-api",
version: "1.0.0"
},
My time is: "2018-05-24T12:56:18.340Z",
I am online since: "2018-05-24T12:56:13.537Z"
}
This project is licensed under MIT.