-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
89 lines (59 loc) · 1.73 KB
/
Copy pathapp.js
File metadata and controls
89 lines (59 loc) · 1.73 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
const express = require('express');
const router = express.Router();
const path = require('path');
const url = require('url');
const cors = require('cors');
const { response } = require('express');
const config = require('./config/default.json');
const testsRouter = require('./routes/tests')
const swaggerJsdoc = require('swagger-jsdoc');
const swaggerUi = require('swagger-ui-express');
const daltest = require('./dal/test_repo');
const port = config.express.port;
// const logger = require('./logger/my_logger');
// logger.debug('test1');
const app = express();
app.use(express.json())
app.use(express.urlencoded({
extended: true
}));
app.use(express.static(path.join(__dirname, 'static')));
app.use(express.static(path.join(__dirname, 'script')));
app.set('view engine', 'ejs');
app.get('*', async (req, res, next) => {
// logger.debug(`URL LOG ------------- ${req.url}`)
next()
})
app.get('/my_ejs', async (req, res) => res.render('my_ejs', {
tests: await daltest.get_all_test()
}))
// ============================================
// == move all REST API to routes/tests.js
// ============================================
app.listen(port, () => {
console.log(`Listening to port ${port}`);
});
const options = {
definition: {
openapi: "3.0.0",
info: {
title: "Library API",
version: "1.0.0",
description: "A simple Express Library API",
},
servers: [
{
url: "http://localhost:8080/",
},
],
},
apis: ["./routes/*.js"],
};
const specs = swaggerJsdoc(options);
app.use(
"/api-docs",
swaggerUi.serve,
swaggerUi.setup(specs)
);
app.use('/test', testsRouter);
module.exports = app;