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;