-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
56 lines (42 loc) · 1.31 KB
/
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const express = require('express');
const app = express();
const mongoose = require('mongoose');
const petRoutes = require('./routes/pet.route.js');
const dotenv = require('dotenv');
const path = require('path');
const { inject } = require('@vercel/analytics');
// import { inject } from 'vercel/analytics';
dotenv.config();
// Middleware Config
app.use(express.json());
app.use(express.urlencoded({extended: false}));
// Routes
app.use('/api/pets', petRoutes);
// app.get('/', (req, res) => {
// res.send('Homepage!');
// });
// // Getting all Products from DB.
// app.get('/api/products',);
// // Adding Products to DB
// app.post('/api/products', );
// // Getting individual Product by ID.
// app.get('/api/products/:id', );
// // Update individual Product by ID.
// app.put('/api/products/:id', )
// // Delete individual Product by ID.
// app.delete('/api/products/:id', );
// app.use('/docs', express.static('apidoc'));
app.use('/docs', express.static(path.join(__dirname, 'apidoc'))); // THIS!!
const port = process.env.PORT || 4000;
inject();
mongoose.connect(process.env.MONGO_URL)
.then(() => {
console.log("Connected to Database!");
app.listen(port, () => {
console.log(`Server running on PORT ${port}!`);
});
})
.catch(() => {
console.log("Connection Failed!")
})
module.exports = app;