Neutral Point Measurement

    @skazka/server-init

    0.0.11 • Public • Published

    Server Init

    Pack of useful packages:

    NPM

    How to install

    npm i @skazka/server @skazka/server-init
    

    With yarn:

    yarn add @skazka/server @skazka/server-init
    

    Optionally you can add http server and router:

    npm i @skazka/server-http @skazka/server-router
    

    With yarn:

    yarn add @skazka/server-http @skazka/server-router
    

    How to use

    const App = require('@skazka/server');
    const Router = require('@skazka/server-router');
    
    const init = require('@skazka/server-init');
            
    const server = require('@skazka/server-http');
            
    const app = new App();
    const router = new Router();
            
    app.then(init());
        
    app.then(async (ctx) => {
      // it works for each request
    });
        
    router.get('/data').then(async (ctx) => {
      return ctx.response('data'); 
    });
            
    app.then(router.resolve());
            
    server.createHttpServer(app);

    Configuration

    To enable or disable any module:

    app.then(init({ moduleName: true }));

    Or

    app.then(init({ moduleName: false }));

    By default all modules are enabled.

    Fo example, to disable cookies:

    app.then(init({ cookies: false }));

    Modules error, logger and helmet have own options. You can set this option by setting "object" instead of "true":

    app.then(init({ error: { hasUserError: false } }));

    To see more info check each module documentation.

    Install

    npm i @skazka/server-init

    DownloadsWeekly Downloads

    0

    Version

    0.0.11

    License

    MIT

    Unpacked Size

    4.35 kB

    Total Files

    3

    Last publish

    Collaborators

    • evheniy.bystrov
    • skazkajs