text: const express = require('express');
  const path = require('path');
  
  const app = new express();
  const ejs = require('ejs');
  app.set('view engine', 'ejs');
  
  app.use(express.static('public'));
  
  const bodyParser = require('body-parser');
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: true }));
  
  const mongoose = require('mongoose');
  const BlogPost = require('./models/BlogPost');
  mongoose.connect('mongodb://localhost/my_database', { useUnifiedTopology: true, useNewUrlParser: true });
  
  const { error } = require('console');
  
  app.listen(4000, () => {
      console.log('App listening on port 4000');
  });
  
  app.get('/', async (req, res) => {
      const blogposts = await BlogPost.find({});
      res.render('index', {
          blogposts: blogposts
      });
  });
  
  app.get('/about', (req, res) => {
      res.render('about');
  });
  
  app.get('/contact', (req, res) => {
      res.render('contact');
  });
  
  app.get('/post/:id', async (req, res) => {
      const blogpost = await BlogPost.findById(req.params.id)
      res.render('post', {
          blogpost: blogpost
      });
  });
  
  app.get('/create', (req, res) => {
      res.render('create');
  });
  
  app.post('/posts/store', async (req, res) => {
      await BlogPost.create(req.body, (error, blogpost) => {
          res.redirect('/');
      });
  });
  