-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
140 lines (130 loc) · 2.69 KB
/
app.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
const express = require("express");
const app = express();
const uploadUser = require("./middlewares/uploadimage");
const path = require("path");
const cors = require('cors')
const PORT = process.env.PORT || 8877;
app.use(cors())
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use("/uploads", express.static(path.join("./public/uploads/series")));
app.listen(PORT, () => {
console.log("escutando na porta" + PORT);
});
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "http://localhost:4200");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
app.post("/upload-image", uploadUser.single("image"), async (req, res) => {
if (req.file) {
console.log(req.file);
return res.json({
url: `localhost:8877/uploads/${req.file.filename}`,
error: false,
msg: "Upload image works",
});
}
return res.status(400).json({
error: true,
msg: "Erro: upload image request don't works, necessary to send an image in png, jpeg or jpg format",
});
});
app.get("/titulos", (req, res) => {
res.json({
titulos: [
{
titulo: "Orphan Black"
},
{
titulo: "Prison Break"
},
{
titulo: "Ponto Cego"
},
{
titulo: "Hanna"
},
{
titulo: "Good Girls"
},
{
titulo: "O Inocente"
},
{
titulo: "The 100"
},
{
titulo: "Vikings"
},
{
titulo: "The Cursed"
},
{
titulo: "The Vampire Diaries"
},
{
titulo: "The OA"
},
{
titulo: "Dark"
},
{
titulo: "The Office"
},
{
titulo: "Bates Motel"
},
{
titulo: "Glitch"
},
{
titulo: "Expresso Do Amanhã"
},
{
titulo: "Behind her Eyes"
},
{
titulo: "Inacreditável"
},
{
titulo: "Colony"
},
{
titulo: "Warrior Nun"
},
{
titulo: "Vis a Vis"
},
],
});
return res.status(400).json({
error: true,
msg: "not working",
});
});
app.get("/about", (req, res) => {
res.json({
name: "Gabriela Clemente",
email: "gabeclementej@gmail.com",
urls: [
{
type: "github",
urlink: "https://github.com/gabrielajc",
},
{
type: "linkedin",
urlink: "https://www.linkedin.com/in/gabeclemente",
},
],
});
}),
app.get("/", (req, res) => {
res.json({
msg: "Working",
});
return res.status(400).json({
error: true,
msg: "not working",
});
});