You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
810 B
45 lines
810 B
const createError = require('http-errors');
|
|
const express = require('express');
|
|
const cors = require('cors');
|
|
|
|
const documentationRouter = require('./helpers/documentation');
|
|
|
|
const { fishRouter } = require('./router/fishRouter');
|
|
|
|
const app = express();
|
|
|
|
app.use(cors({
|
|
credentials: true
|
|
}));
|
|
|
|
app.use(async (req, res, next) => {
|
|
express.json({
|
|
type: function () {
|
|
return true;
|
|
}
|
|
})(req, res, next);
|
|
});
|
|
|
|
app.use('', documentationRouter);
|
|
|
|
app.use('/fish',
|
|
fishRouter()
|
|
|
|
);
|
|
|
|
app.use(async (req, res, next) => {
|
|
next(createError.NotFound());
|
|
})
|
|
|
|
app.use((err, req, res, next) => {
|
|
res.status(err.status || 500);
|
|
res.send({
|
|
err: {
|
|
status: err.status || 500,
|
|
message: err.message,
|
|
}
|
|
})
|
|
})
|
|
|
|
module.exports = app;
|