-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·28 lines (22 loc) · 894 Bytes
/
index.js
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
const express = require('express');
const swaggerUi = require('swagger-ui-express');
const swaggerDocs = require('./swagger.json');
const route = require('./routes');
const middlewares = require('./middlewares');
const { BlogPostsController } = require('./controllers');
const app = express();
app.use(express.json());
const PORT = process.env.PORT || 3000;
// não remova esse endpoint, e para o avaliador funcionar
app.get('/', (_request, response) => {
response.send();
});
app.get('/post/search', middlewares.authMiddleware, BlogPostsController.getPostByQueryParam);
app
.use('/user', route.userRoute)
.use('/categories', route.categorieRoute)
.use('/post', route.blogPostRoute)
.use('/login', route.loginRoute)
.use('/doc', swaggerUi.serve, swaggerUi.setup(swaggerDocs))
.use(middlewares.errorMiddleware);
app.listen(PORT, () => console.log(`ouvindo porta ${PORT}!`));