All files / example app.js

100% Statements 15/15
100% Branches 2/2
100% Functions 2/2
100% Lines 15/15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36          1x 1x             1x 1x   1x   1x 1x 1x 1x 1x     1x   1x   1x 1x       1x  
/**
 * Example of using Lark constructing a web app
 **/
'use strict';
 
const debug = require('debug')('lark.example.app');
const Lark  = require('lark');
 
/**
 * The main entry. Since lark use async methods such as app.start, it's better to use lark in an
 * async function
 **/
async function main() {
    debug('run main');
    process.mainModule = module;
 
    const app = new Lark();
 
    debug('preparing app configs');
    await app.config.use('configs');
    app.config.set('server/port', 8888);
    app.on('error', (error, ctx) => {
        ctx.logger.error(error.stack) && ctx.logger.log(error.stack);
    });
 
    let service = null;
 
    service = await app.start();
 
    app.logger.notice(`SERVER[${process.pid}] listening on ${service.port} ...`);
    return service;
}
 
// main();
module.exports = main;