-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
28 lines (25 loc) · 796 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
const sql = require('mssql/msnodesqlv8');
const { app, port } = require('./init-express');
const config = require('./const');
app.listen(port, async () => {
try {
const conn = new sql.ConnectionPool(config);
sqlServer = await conn.connect();
}
catch (err) {
// eslint-disable-next-line no-console
console.log('Failed to listen 8000...', err);
}
});
app.use((req, res, next) => {
process.stdout.write(`Middleware tiggered: ${req.url}\n`);
next();
});
require('./end-points/api-get-all');
require('./end-points/api-get-one');
require('./end-points/api-post-one');
require('./end-points/api-delete-one');
sql.on('error', (err) => {
res.statusMessage = `Unable to connect SQL Server. Error Details: ${err}`;
res.sendStatus(400);
});