-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
32 lines (27 loc) · 780 Bytes
/
app.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
const express = require('express');
const http = require('http');
const path = require('path');
const { OpenApiValidator } = require('express-openapi-validator');
const app = express();
const server = http.createServer(app);
const PORT = 3333;
app.use((req, res, next) => {
console.log(req.method, req.url);
next();
});
new OpenApiValidator({
apiSpecPath: path.resolve(__dirname, './openapi.yml'),
}).install(app);
app.get('/music', (req, res, next) => {
res.status(200).json({});
});
app.use((err, req, res, next) => {
res
.status(err.status)
.json({
status: err.status,
message: err.message,
name: err.name
});
});
server.listen(3333, () => console.log(`musical-enigma @ localhost:${PORT}`));