unicore

Standard batteries-included Ackee suit for an API Core.

Usage no npm install needed!

<script type="module">
  import unicore from 'https://cdn.skypack.dev/unicore';
</script>

README

Unicore

Based on this template

Build Status Coverage Maintainability Vulnerabilities Dependency Status Dev Dependency Status

Standard batteries-included Ackee suit for an API Core.

Built on top of express and this is all you have to change.

Features

  • Promised listenAsync.
  • Destroyable server with .destroy().
  • Error processing with serializable HttpJsonError and errorHandler
  • Includes
  • Sentry error reporting support
  • Default request handlers (root with info, final handler)

Quickstart

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"
}

License

This project is licensed under MIT.