1 /* eslint-disable capitalized-comments */
4 const http
= require('http');
6 const DB
= require('./src/db');
7 const Logger
= require('./src/logger');
8 const Service
= require('./src/service');
9 const { fileScope
} = require('./src/common');
10 const { version
} = require('./package.json');
12 const _fileScope
= fileScope(__filename
)('main');
14 const PORT
= process
.env
.PORT
|| 3001;
15 const ADDR
= process
.env
.LISTEN_ADDR
|| '127.0.0.1';
17 const logger
= new Logger({
18 // ignoreBelowLevel: 'info',
20 const db
= new DB(logger
, {
21 connectionString: 'postgresql://%2Fhome%2Ffek%2Fprojects%2Fhubl%2Fnodejs%2Fpostgres_dev-13/urlittler',
22 // connectionString: 'sqlite://',
24 const service
= new Service(logger
, db
, {
25 proxyPrefix: process
.env
.PROXY_PREFIX
|| '', // '/lil',
27 selfBaseUrl: process
.env
.BASE_URL
|| '',
31 http
.createServer((req
, res
) => {
32 service
.dispatch(req
, res
);
33 }).listen(PORT
, ADDR
, (err
) => {
35 logger
.error(_fileScope
, 'error starting server:', err
);
38 logger
.info(_fileScope
, `server (version ${version}) started on ${ADDR}:${PORT}`);