-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
25 lines (17 loc) · 856 Bytes
/
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
const http = require('http');
const app = require('./app');
const swapiPeople = require('./api/swapi/swapi_people');
const swapiStarships = require('./api/swapi/swapi_starships');
// Initialize server
const port = process.env.PORT || 3000;
const server = http.createServer(app);
//Function that populates database for the first time
//TODO: comment the functions when database is populated and server is going to reset several times.
server.listen(port, () => {
swapiPeople.initLoadPeopleDB('https://swapi.dev/api/people/?page=1');
swapiStarships.initLoadStarshipsDB('https://swapi.dev/api/starships/?page=1');
setTimeout(() => {
swapiPeople.initLoadStarshipsRefs('https://swapi.dev/api/people/?page=1');
swapiStarships.initLoadPilotsRefs('https://swapi.dev/api/starships/?page=1');
}, 5000);
});