-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp_test.js
38 lines (31 loc) · 906 Bytes
/
app_test.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
const express = require('express');
let mongoose = require('mongoose');
require('dotenv').config()
require('express-async-errors');
const app = express();
app.use(express.json());
let uri;
uri = process.env.Mongo_URI_TEST;
mongoose.connect(uri, { useNewUrlParser: true, useUnifiedTopology: true, useFindAndModify: false })
.then(data => {
// do not thing
})
.catch(err => {
throw err;
});
app.get('/', (req, res) => {
res.status(200).json({ message: "Hello Hooman!!!" });
});
app.use(`/api/v1/linked`, require('./routes/linked_bank.route'));
app.use((req, res, next) => {
res.status(404).send('Not found');
});
app.use((err, req, res, next) => {
console.log(err.stack);
const statusCode = err.status || 500;
res.status(statusCode).send({ "message": err.message });
});
const disconnect = async () => {
await mongoose.disconnect();
}
module.exports = { app, disconnect };