forked from nessy126/fullstack-team-project-back
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
32 lines (23 loc) · 871 Bytes
/
app.js
File metadata and controls
32 lines (23 loc) · 871 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
29
30
31
32
const express = require('express');
const cors = require('cors');
require('dotenv').config();
const app = express();
const authRouter = require('./routes/api/auth');
const booksRouter = require('./routes/api/books');
const trainingRouter = require('./routes/api/training');
// import swaggerUi from "swagger-ui-express";
// import * as swaggerDocument from '../swager/openapi.json';
app.use(cors());
app.use(express.json());
app.use('/api/users', authRouter);
app.use('/api/books', booksRouter);
app.use('/api/training', trainingRouter);
app.use((req, res) => {
res.status(404).json({ message: 'Not found' });
});
app.use((err, req, res, next) => {
const { status = 500, message = 'Server error' } = err;
res.status(status).json({ message: err.message });
});
// app.use("/api-doc", swaggerUi.serve, swaggerUi.setup(swaggerDocument))
module.exports = app;