-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
34 lines (29 loc) · 1.03 KB
/
server.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
const express = require( 'express' );
const morgan = require( 'morgan' );
const cors = require( 'cors' );
const bodyParser = require( 'body-parser' );
const mongoose = require( 'mongoose' );
const passport = require( 'passport' );
const userRouter = require( './routes/userRouter' );
const transactionRouter = require( './routes/transactionRouter' );
const app = express();
app.use( morgan( 'dev' ) );
app.use( cors() );
app.use( bodyParser.urlencoded( { extended: false } ) );
app.use( bodyParser.json() );
app.use( passport.initialize() );
require( './utils/passport' )( passport );
app.use( '/api/user', userRouter );
app.use( '/api/transaction', transactionRouter );
app.get( '/', ( req, res ) => {
res.json({
message: 'Welcome to the application'
})
})
const PORT = process.env.PORT || 4000;
app.listen(PORT, () => {
console.log( `SERVER is running on port ${PORT}` );
mongoose.connect( 'mongodb://127.0.0.1/expense-tracker', { useNewUrlParser: true }, () => {
console.log( 'database connected' );
} )
})