All files / src app.ts

75% Statements 9/12
0% Branches 0/2
0% Functions 0/1
75% Lines 9/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                    4x 4x   4x 4x   4x             4x 4x 4x 4x      
import express from 'express';
import dotenv from 'dotenv';
import dotenvExpand from 'dotenv-expand';
import bodyParser from 'body-parser';
import posts_routes from './routes/posts_routes';
import comments_routes from './routes/comments_routes';
import auth_routes from './routes/auth_routes';
import swaggerUi from 'swagger-ui-express';
import loadOpenApiFile from './openapi/openapi_loader';
 
dotenvExpand.expand(dotenv.config());
const app = express();
 
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
// Error handler for invalid JSON
app.use((err, req, res, next) => {
    if (err instanceof SyntaxError) {
        return res.status(400).send('Invalid JSON syntax');
    }
    next(err);
});
 
app.use('/swagger', swaggerUi.serve, swaggerUi.setup(loadOpenApiFile()));
app.use('/post', posts_routes);
app.use('/comment', comments_routes);
app.use('/auth', auth_routes);
 
export default app;