-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathapp.js
More file actions
34 lines (25 loc) · 810 Bytes
/
app.js
File metadata and controls
34 lines (25 loc) · 810 Bytes
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
import express from 'express';
import bodyParser from 'body-parser';
import mongoose from 'mongoose';
import cors from 'cors';
mongoose.set('useFindAndModify', false);
import crud from "./crud";
const app = express();
app.use(cors({
origins: ["*"],
methods: ["GET", "POST", "PUT", "DELETE"],
allowedHeaders: ["Content-Type"]
}))
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
mongoose.set('useCreateIndex', true)
mongoose.connect('mongodb://192.168.99.100:27017/trekodb', { useNewUrlParser: true });
app.get('/task', crud.list)
app.get('/task/:id', crud.get)
app.delete('/task/:id', crud.remove)
app.post('/task', crud.create)
app.put('/task/:id', crud.update)
app.listen(3000, () => {
console.log("Treko API está no AR!");
});
module.exports = app;