-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
33 lines (24 loc) · 790 Bytes
/
Copy pathserver.js
File metadata and controls
33 lines (24 loc) · 790 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
32
33
// Require express and mongoose
const express = require('express');
const db = require('./config/connection');
const routes = require('./routes');
const mongoose = require('mongoose');
// const cwd = process.cwd();
const app = express();
const PORT = process.env.PORT || 3001;
app.use((req, res, next) => {
console.log(`${req.method} requested on endpoint ${req.path}`);
next();
});
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(routes);
// app.use(express.static('public'));
// Log mongoose queries
mongoose.set('debug', true);
// app.listen(PORT, () => console.log(`Now connected on localhost:${PORT} `));
db.once('open', () => {
app.listen(PORT, () => {
console.log(`API server running on localhost:${PORT}!`);
});
});