Skip to content

Instantly share code, notes, and snippets.

@OdongAlican
Created April 14, 2020 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OdongAlican/9fa9ab001c050fc290daec5aa9c653e1 to your computer and use it in GitHub Desktop.
Save OdongAlican/9fa9ab001c050fc290daec5aa9c653e1 to your computer and use it in GitHub Desktop.
const express = require('express');
const bodyParser = require('body-parser');
const mongoose = require('mongoose');
const app = express();
mongoose.connect('mongodb://localhost:27017/Posts');
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
const authorRouter = require('./Views/author');
const postRouter = require('./Views/posts');
app.use('/api', authorRouter);
app.use('/api', postRouter);
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Application running on port ${PORT}`);
});
@OdongAlican
Copy link
Author

Updated app.js gist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment