make it better
This commit is contained in:
1 parent
ed9b244f8a
commit
ad73f5e27a
2 files changed
+8
-2
No files matched your search
+1
-1
@@ -17,7 +17,7 @@ import TravelData from "../models/TravelData.js";
|
|||||||
import TravelPreventionData from "../models/TravelPreventionData.js";
|
import TravelPreventionData from "../models/TravelPreventionData.js";
|
||||||
|
|
||||||
// Get China Data method
|
// Get China Data method
|
||||||
schedule.scheduleJob('fetchChinaData', '0 0 * * *', () => {
|
schedule.scheduleJob('fetchChinaData', '* * * * *', () => {
|
||||||
// 导入环境变量
|
// 导入环境变量
|
||||||
const { tianapiKey } = process.env;
|
const { tianapiKey } = process.env;
|
||||||
const ncovChinaUrl = `https://api.tianapi.com/ncov/index?key=${tianapiKey}`;
|
const ncovChinaUrl = `https://api.tianapi.com/ncov/index?key=${tianapiKey}`;
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ import bodyParser from "body-parser";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import dotenv from "dotenv";
|
import dotenv from "dotenv";
|
||||||
|
|
||||||
|
// Import files
|
||||||
|
import ncov from './controller/ncov.js';
|
||||||
|
|
||||||
// Initialize dotenv
|
// Initialize dotenv
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@@ -30,6 +33,9 @@ app.use(express.static(path.join(__dirname, "./public")));
|
|||||||
app.use(bodyParser.json({ limit: "30mb", extended: true }));
|
app.use(bodyParser.json({ limit: "30mb", extended: true }));
|
||||||
app.use(bodyParser.urlencoded({ limit: "30mb", extended: true }));
|
app.use(bodyParser.urlencoded({ limit: "30mb", extended: true }));
|
||||||
|
|
||||||
|
// Use ncov
|
||||||
|
ncov.use('fetchChinaData');
|
||||||
|
|
||||||
// Connecting to MongoDB
|
// Connecting to MongoDB
|
||||||
mongoose
|
mongoose
|
||||||
.connect(process.env.connectionString, {
|
.connect(process.env.connectionString, {
|
||||||
@@ -40,4 +46,4 @@ mongoose
|
|||||||
.catch((error) => console.log(error));
|
.catch((error) => console.log(error));
|
||||||
|
|
||||||
// // Allow us to change the port easily by setting an environment variable
|
// // Allow us to change the port easily by setting an environment variable
|
||||||
const PORT = process.env.PORT || 8000;
|
const PORT = process.env.PORT || 8000;
|
||||||
Reference in new issue
Block a user