Total Complexity | 6 |
Complexity/F | 1.5 |
Lines of Code | 29 |
Function Count | 4 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | 'use strict' |
||
2 | |||
3 | import server from './server' |
||
4 | import chalk from 'chalk' |
||
5 | import logger from 'winston' |
||
6 | import config from '../config' |
||
7 | import databaseConnection, { databaseValidate } from './database' |
||
8 | import beforeServerListen from './cluster' |
||
9 | import endpoints from './helpers/endpoints' |
||
10 | |||
11 | // Verify `cluster` need |
||
12 | beforeServerListen(() => { |
||
13 | if (config.isDevelop) { |
||
14 | console.log(endpoints.listAll(server)) |
||
15 | } |
||
16 | server.listen(config.server.port, () => databaseConnection(config.uri.db)) |
||
17 | }) |
||
18 | |||
19 | Promise.all([databaseValidate]) |
||
20 | .then(() => { |
||
21 | logger.info('[app]', `Restify started in ${chalk.bold(config.env)}` + |
||
22 | ` mode on ${chalk.cyan(server.url)}` + |
||
23 | '; press Ctrl-C to terminate.') |
||
24 | }) |
||
25 | .catch((error) => { |
||
26 | if (error instanceof Error) { |
||
27 | logger.error('[app]', error.stack) |
||
28 | } |
||
29 | }) |
||
30 |