-
Notifications
You must be signed in to change notification settings - Fork 22
/
index.js
52 lines (45 loc) · 1.17 KB
/
index.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
42
43
44
45
46
47
48
49
50
51
52
require("dotenv").config();
const express = require("express");
const bodyParser = require("body-parser");
const low = require("lowdb");
const FileSync = require("lowdb/adapters/FileSync");
const app = express();
const routes = require("./routes");
const port = process.env.PORT || 3002;
app.use(bodyParser.json({ extended: true }));
app.use("/api", routes);
const adapter = new FileSync("db.json");
const db = low(adapter);
const defaultSerie = {
1: {
name: "La casa de papel",
status: "WATCHED",
genre_id: 1,
comments: "",
poster: "//image.tmdb.org/t/p/original/yVUAfbrP5HDJugXraB7KQS0yz6Z.jpg",
background: "//image.tmdb.org/t/p/original/piuRhGiQBYWgW668eSNJ2ug5uAO.jpg",
},
};
const defaultGenre = {
1: { name: "Ação" },
2: { name: "Comédia" },
};
db.defaults({
series: defaultSerie,
genres: defaultGenre,
count: 0,
}).write();
app.get("/", (req, res) =>
res.send({
info: "Minhas Séries Server",
datetime: new Date(),
})
);
app
.listen(port, () => {
console.log("Minhas Séries server running on port", port);
})
.on("error", (err) => {
console.log("Error running Minhas Séries server");
console.log(err);
});