diff --git a/.gitignore b/.gitignore index b512c09..be12cc6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +.now \ No newline at end of file diff --git a/app.js b/app.js index d489378..4f2cf7d 100644 --- a/app.js +++ b/app.js @@ -2,18 +2,11 @@ const express = require('express'), app = express(), util = require('./bin/util'), - fs = require('fs'), axios = require('axios'), - covid19 = require('./lib/cli'); - -// set port -const port = process.env.port || 7070; - -// package.json info -const pkg = JSON.parse(fs.readFileSync('package.json')); - -// api base url -const apiBaseURL = "https://corona.lmao.ninja"; + covid19 = require('./lib/cli'), + pkg = require('./package.json'), // package.json info + apiBaseURL= "https://corona.lmao.ninja", // api base url + port = process.env.port || 7070 // set port // global route for covid19 tracker app.get('/', async (req, res, next) => { diff --git a/lib/cli/index.js b/lib/cli/index.js index 7726f7b..9b88511 100644 --- a/lib/cli/index.js +++ b/lib/cli/index.js @@ -1,9 +1,10 @@ /* eslint-disable no-await-in-loop */ const color = require('ansi-styles'), - fs = require('fs'), table3 = require('cli-table3'), - chart = require('./chart'); + chart = require('./chart'), + pkg = require('../../package.json'), // package.json info + say = require('../sayings/threads.json') // sayings // ansi colors const @@ -30,11 +31,6 @@ const space = ' ', br = '\n'; - -// package.json information -const pkg = JSON.parse(fs.readFileSync('package.json')); -const say = JSON.parse(fs.readFileSync('./lib/sayings/threads.json')); - // random sayings const randomSay = () => { let random = Math.floor(Math.random() * say.length); diff --git a/now.json b/now.json new file mode 100644 index 0000000..a1d3599 --- /dev/null +++ b/now.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "builds": [{ + "src": "app.js", + "use": "@now/node-server" + }], + "routes": [{ + "headers": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS", + "Access-Control-Allow-Headers": "X-Requested-With, Content-Type, Accept" + }, + "src": "/.*", + "dest": "/app.js" + }], + "env": { + "VERSION": "1" + } +}