-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
21 lines (17 loc) · 740 Bytes
/
index.js
File metadata and controls
21 lines (17 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const serverless = require('serverless-http');
const express = require('express');
const mongoose = require('mongoose');
const swaggerUi = require('swagger-ui-express')
const YAML = require('yamljs')
require('dotenv').config()
const app = express();
app.use(express.json());
const DB_URI = process.env.MONGO_URI
const swaggerDocument = YAML.load('./swagger.yaml')
mongoose.connect(DB_URI, {useUnifiedTopology: true, useNewUrlParser: true})
.then(() => console.log('Connected to MongoDB'))
.catch(e => console.log('Error connecting to MongoDB:', e))
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument))
app.use('/', require('./routes/urlRoutes'))
module.exports = app;
module.exports.handler = serverless(app);