Compare View

switch
from
...
to
 
Commits (2)

Changes

Showing 2 changed files Inline Diff

1 node_modules 1 node_modules
2 config.json
3 pid.txt 2 config.json
3 pid.txt
lib/http-server/index.js
1 const MODULE_NAME = 'HTTP-SERVER'; 1 const MODULE_NAME = 'HTTP-SERVER';
2 2
3 const express = require('express'); 3 const express = require('express');
4 const uniqid = require('uniqid'); 4 const uniqid = require('uniqid');
5 const logger = require('tektrans-logger'); 5 const logger = require('tektrans-logger');
6 6
7 const config = require('../config'); 7 const config = require('../config');
8 const matrix = require('../matrix'); 8 const matrix = require('../matrix');
9 const checkApikey = require('./middlewares/check-apikey'); 9 const checkApikey = require('./middlewares/check-apikey');
10 10
11 const routerMatrix = require('./routers/matrix'); 11 const routerMatrix = require('./routers/matrix');
12 const routerUpdates = require('./routers/updates'); 12 const routerUpdates = require('./routers/updates');
13 const routerProducts = require('./routers/products'); 13 const routerProducts = require('./routers/products');
14 const routerPostpaidProducts = require('./routers/postpaid-products');
15 14
16 const app = express(); 15 const app = express();
17 16
18 app.use((req, res, next) => { 17 app.use((req, res, next) => {
19 matrix.httpServer.requestCounter += 1; 18 matrix.httpServer.requestCounter += 1;
20 res.locals.xid = uniqid(); 19 res.locals.xid = uniqid();
21 20
22 next(); 21 next();
23 }); 22 });
24 23
25 app.use('/matrix', routerMatrix); 24 app.use('/matrix', routerMatrix);
26 app.use('/apikey/:apikey/updates', [checkApikey], routerUpdates); 25 app.use('/apikey/:apikey/updates', [checkApikey], routerUpdates);
27 app.use('/apikey/:apikey/products', [checkApikey], routerProducts); 26 app.use('/apikey/:apikey/products', [checkApikey], routerProducts);
28 app.use('/apikey/:apikey/postpaid/products', [checkApikey], routerPostpaidProducts);
29 27
30 app.use((req, res) => { 28 app.use((req, res) => {
31 res.status(404).json({ 29 res.status(404).json({
32 error: true, 30 error: true,
33 message: 'Method/service not found', 31 message: 'Method/service not found',
34 }); 32 });
35 }); 33 });
36 34
37 const { port } = config; 35 const { port } = config;
38 app.listen(port, () => { 36 app.listen(port, () => {
39 logger.info(`${MODULE_NAME} 35069698: Listening`, { port }); 37 logger.info(`${MODULE_NAME} 35069698: Listening`, { port });
40 }); 38 });
41 39