openvibers/openvibe.markets serverindex.js

index.js

main 1.1 KB · 18 lines · javascript

1'use strict';
2/**
3 * OpenVibe.Markets' process: the app on 127.0.0.1:PORT (5294), searching Deals over loopback (DEALS_URL). No database,
4 * no sign-in, nothing kept. SIGTERM closes the server.
5 */
6const { createApp } = require('./app');
7const { createDeals } = require('./deals');
8const { createVision } = require('./vision');
9
10const env = process.env;
11const port = Number(env.PORT || 5294);
12const deals = createDeals({ baseUrl: env.DEALS_URL || 'http://127.0.0.1:4840', timeoutMs: Number(env.DEALS_TIMEOUT_MS || 5000) });
13// Search by photo: OpenVibe Vision's ask with Markets' own token (Network #1118); off without a client secret.
14const vision = createVision({ visionUrl: env.VISION_URL || 'http://127.0.0.1:5130', networkUrl: env.OV_NETWORK_INTERNAL_URL || 'http://127.0.0.1:4000',
15 clientId: env.OV_OAUTH_CLIENT_ID || 'markets', clientSecret: env.OV_OAUTH_CLIENT_SECRET || '' });
16const server = createApp({ deals, vision }).listen(port, env.HOST || '127.0.0.1', () => console.log(`[markets] listening on ${env.HOST || '127.0.0.1'}:${port}`));
17process.on('SIGTERM', () => server.close(() => process.exit(0)));
18