Skip to content

Instantly share code, notes, and snippets.

@paulobunga
Last active December 18, 2019 00:37
Show Gist options
  • Save paulobunga/fd618af5c02c3d539368d9da7bf21392 to your computer and use it in GitHub Desktop.
Save paulobunga/fd618af5c02c3d539368d9da7bf21392 to your computer and use it in GitHub Desktop.
Main index.js file
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