-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
29 lines (23 loc) · 851 Bytes
/
index.js
File metadata and controls
29 lines (23 loc) · 851 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
const PORT = process.env.PORT ?? 5000;
const user = {
name: process.env.username ?? 'test',
password: process.env.password ?? 'test',
}
const Application = require('./framework/Application');
const userRouter = require('./src/user-router');
const jsonParser = require('./framework/parseJson');
const urlParser = require('./framework/parseUrl');
const mongoose = require('mongoose');
const app = new Application();
app.use(jsonParser);
app.use(urlParser('http://localhost:5000'));
app.addRouter(userRouter);
const start = async () => {
try {
await mongoose.connect(`mongodb+srv://${user.name}:${user.password}@cluster0.gvmkmuc.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0`);
app.listen(PORT, () => console.log(`Server started on PORT=${PORT}`));
} catch (e) {
console.log(e);
}
}
start();