Last active
December 18, 2019 00:37
-
-
Save paulobunga/fd618af5c02c3d539368d9da7bf21392 to your computer and use it in GitHub Desktop.
Main index.js file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const mongoose = require('mongoose'); | |
const bodyParser = require('body-parser'); | |
const router = require('./router'); | |
const app = express(); | |
mongoose | |
.connect('mongodb://localhost:27017/node_api') | |
.then(() => console.log('Connected to database')); | |
app.use(bodyParser.urlencoded({ extended: false })); | |
app.use(bodyParser.json()); | |
app.use('/products', router); | |
app.listen(3000, () => console.log('App is running on port 3000')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment