-
Notifications
You must be signed in to change notification settings - Fork 7
/
server.js
41 lines (35 loc) · 1.21 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const express = require("express");
const bodyParser = require("body-parser");
const cors = require("cors");
require("dotenv").config();
require("app-module-path").addPath(__dirname);
// middleware
const middleware = require("./src/middleware");
// db sync
const db = require("./src/db/models");
db.sequelize.sync();
// cron
const githubCronJob = require("./src/crons/github.cron").findSolanaReposCron;
const fetchSolanaDevelopers =
require("./src/crons/github.cron").fetchSolanaDevelopers;
githubCronJob.start();
fetchSolanaDevelopers.start();
const enableFetchSolanaReposCronJob =
require("./src/crons/github.cron").enableFetchSolanaRepos;
enableFetchSolanaReposCronJob.start();
const solanaResponseCacheCronJob =
require("./src/crons/solanaResponseCache.cron").solanaResponseCache;
solanaResponseCacheCronJob.start();
const port = 8080;
const app = express();
app.use(bodyParser.json());
app.use(require("morgan")("dev"));
app.use(cors());
app.use(middleware.githubError);
app.use(middleware.postgresError);
app.use(middleware.unknownError);
const server = app.listen(port, function () {
const host = server.address().address;
const port = server.address().port;
console.log("App listening at //%s%s", host, port);
});