-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.js
37 lines (28 loc) · 848 Bytes
/
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
const express = require('express');
const moe = express();
const mongoose = require('mongoose');
const port = process.env.PORT || 5000
const vanitas = require('./models/User');
const cors = require('cors')
const NodeCache = require('node-cache')
const host = process.env.host
const db = process.env.db
mongoose.connect('mongodb://' + host + '/' + db);
moe.use(cors())
moe.use(express.json())
moe.use(express.urlencoded({ extended: false }))
moe.get("/home", (req, res) => {
res.status(200).json({
"api": "getinfo/{userid}",
});
});
moe.get("/getinfo/:id", async(req, res) =>{
const id = request.params.id
const user = await vanitas.findOne({ user: id })
res
.status(200)
.json(user);
});
moe.listen( port, () => {
console.log(`Connected to port ${port}`)
} )