-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
61 lines (50 loc) · 1.63 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
53
54
55
56
57
58
59
60
61
const fs = require('fs');
// const https = require('https');
const express = require('express');
const app = express();
const port = 3027;
//SERVIDOR
// const options = {
// key: fs.readFileSync(
// "/home/ubuntu/Certificados/genesyscloudapps.coddera.com_key.txt"
// ),
// cert: fs.readFileSync(
// "/home/ubuntu/Certificados/genesyscloudapps.coddera.com.crt"
// ),
// ca: [
// fs.readFileSync(
// "/home/ubuntu/Certificados/genesyscloudapps.coddera.com.ca-bundle"
// ),
// ],
// };
// const options = {
// key: fs.readFileSync('/Users/gabri/Documents/NOTECODDERA/certificate/genesyscloudapps.coddera.com_key.txt'),
// cert: fs.readFileSync('/Users/gabri/Documents/NOTECODDERA/certificate/genesyscloudapps.coddera.com.crt'),
// ca: [
// fs.readFileSync('/Users/gabri/Documents/NOTECODDERA/certificate/genesyscloudapps.coddera.com.ca-bundle')
// ]
// };
// Middlewares para parse de JSON e URL-encoded data
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
// Rotas
app.get('/api/1', (req, res) => {
res.send('GET request to the homepages');
});
app.post('/api/2', (req, res) => {
res.send('POST request to the homepage');
});
app.put('/', (req, res) => {
res.send('PUT request to the homepage');
});
app.delete('/', (req, res) => {
res.send('DELETE request to the homepage');
});
// Rodar o servidor com HTTPS
// https.createServer(options, app).listen(port, () => {
// console.log('Server HTTPS Listen port: ' + port);
// });
//RODAR O PROJETO COM HTTP
app.listen(port, () => {
console.log(`🌏 Server is listening in port: ${port}`);
});