Improved app start

- now showing real address
- unix socket support
- string corrections
pull/1/head
Angel Garcia 5 years ago
parent 31f34a7c5f
commit 97a6c81341

@ -1,6 +1,6 @@
{ {
"name": "aruppi", "name": "aruppi",
"version": "2.0.0", "version": "2.0.1",
"description": "Aruppi is a custom API to obtain data from the Japanese culture for the mobile app", "description": "Aruppi is a custom API to obtain data from the Japanese culture for the mobile app",
"main": "./src/api/api.js", "main": "./src/api/api.js",
"scripts": { "scripts": {

@ -26,7 +26,7 @@ app.get('/api/', (req, res) => {
app.get('/api/v1', (req, res) => { app.get('/api/v1', (req, res) => {
res.json({ res.json({
message: 'Sorry, version (api/v1) is deprecated, if you want to see content go to api/v2' message: 'Sorry, version v1 is deprecated, if you want to see content go to v2'
}); });
}); });

@ -1,8 +1,20 @@
const app = require('./app'); const app = require('./app');
const port = process.env.PORT || 5000; const port = process.env.PORT || 5000;
const addr = isNaN(port) ?
'' :
(process.env.ADDR || '0.0.0.0');
app.listen(port, () => { server = app.listen(port, addr, () => {
/* eslint-disable no-console */ /* eslint-disable no-console */
console.log(`\n🚀 ... Listening: http://localhost:${port}/api/v2`); console.log(`\n🚀 ... Listening: ${addr}${addr ? '\:' : 'unix://'}${port}`);
/* eslint-enable no-console */ /* eslint-enable no-console */
}); });
function shutdown() {
server.close(); // socket file is automatically removed here
process.exit();
}
process.on('SIGINT', shutdown);
process.on('SIGQUIT', shutdown);
process.on('SIGTERM', shutdown);

Loading…
Cancel
Save