Skip to content

Commit f13b746

Browse files
committed
Now.sh Support
1 parent 1271ec8 commit f13b746

File tree

4 files changed

+28
-18
lines changed

4 files changed

+28
-18
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
node_modules
1+
node_modules
2+
.now

app.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,10 @@ const express = require('express'),
44
util = require('./bin/util'),
55
fs = require('fs'),
66
axios = require('axios'),
7-
covid19 = require('./lib/cli');
8-
9-
// set port
10-
const port = process.env.port || 7070;
11-
12-
// package.json info
13-
const pkg = JSON.parse(fs.readFileSync('package.json'));
14-
15-
// api base url
16-
const apiBaseURL = "https://corona.lmao.ninja";
7+
covid19 = require('./lib/cli'),
8+
pkg = require('./package.json'), // package.json info
9+
apiBaseURL= "https://corona.lmao.ninja", // api base url
10+
port = process.env.port || 7070 // set port
1711

1812
// global route for covid19 tracker
1913
app.get('/', async (req, res, next) => {

lib/cli/index.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/* eslint-disable no-await-in-loop */
22

33
const color = require('ansi-styles'),
4-
fs = require('fs'),
54
table3 = require('cli-table3'),
6-
chart = require('./chart');
5+
chart = require('./chart'),
6+
pkg = require('../../package.json'), // package.json info
7+
say = require('../sayings/threads.json') // sayings
78

89
// ansi colors
910
const
@@ -30,11 +31,6 @@ const
3031
space = ' ',
3132
br = '\n';
3233

33-
34-
// package.json information
35-
const pkg = JSON.parse(fs.readFileSync('package.json'));
36-
const say = JSON.parse(fs.readFileSync('./lib/sayings/threads.json'));
37-
3834
// random sayings
3935
const randomSay = () => {
4036
let random = Math.floor(Math.random() * say.length);

now.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": 2,
3+
"builds": [{
4+
"src": "app.js",
5+
"use": "@now/node-server"
6+
}],
7+
"routes": [{
8+
"headers": {
9+
"Access-Control-Allow-Origin": "*",
10+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
11+
"Access-Control-Allow-Headers": "X-Requested-With, Content-Type, Accept"
12+
},
13+
"src": "/.*",
14+
"dest": "/app.js"
15+
}],
16+
"env": {
17+
"VERSION": "1"
18+
}
19+
}

0 commit comments

Comments
 (0)