@ptenn/webserver
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

webserver

Installation

Run yarn add @ptenn/webserver or npm add @ptenn/webserver.

Usage

To set up the server, use the following as a guideline:

import serviceRoutes from './serviceRoutes';

const app = new Server({
    ...config,
    environment: 'development',
});

app.init((server: Server, express: Express) => {
    // load custom middleware or setup extra configuration for service
});

app.loadRoutes(serviceRoutes);

return Promise.resolve()
.then(() => app.listenAndServe());

To set up routes to add using the loadRoutes() function:

export default (server: Server, express: Express) => {
    express.get('/data', server.routeHandler((req: Request) => {
        return {
            json: 'information',
        };
    }));
};

Publishing

Publish by running npm publish

Readme

Keywords

none

Package Sidebar

Install

npm i @ptenn/webserver

Weekly Downloads

5

Version

1.3.0

License

ISC

Unpacked Size

17.6 kB

Total Files

16

Last publish

Collaborators

  • blindman