-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (24 loc) · 903 Bytes
/
index.js
File metadata and controls
31 lines (24 loc) · 903 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
import express, { json } from 'express';
import petRouter from './routes/pet.js';
import usuarioRouter from './routes/usuario.js';
import dotenv from 'dotenv'
import { connectMongoDB } from './config/db.js';
import swaggerUI from 'swagger-ui-express';
import fs from 'fs';
import cors from 'cors'
dotenv.config();
const PORT = process.env.PORT;
const app = express();
const URL = process.env.URL;
app.use(cors());
app.use(express.json())
app.use(`/`, express.static('public'))
app.use(`/api/pets`, petRouter)
app.use(`/api/usuarios`, usuarioRouter); // Agora o prefixo '/agenda' será usado para suas rotas
// Rota da documentação Swagger
app.use('/api/docs', swaggerUI.serve, swaggerUI.setup(JSON.parse(fs.readFileSync('./api/swagger/swagger_output.json')),))
connectMongoDB(app).then(() => {
app.listen(PORT, () => {
console.log(`Servidor rodando na porta ${PORT}!`)
})
});