Building the Real Application Chapter 5Until now, we have our frontend server up and running on port 8080 with the following:
$ npm run devThe backend server running on port 8081 with the following:
$ node server.jsOne important thing to remember is that whenever we change the code in server.js, we
have to restart the server by running the following command:
$ node server.jsThis is a very tedious task. However, there is one good way to get rid of that. There is a
package called nodemon, which, when installed, restarts the server automatically whenever
the code gets updated and we don't have to do it manually every time. So, let's go ahead
and install the package:
$ npm install nodemon --saveWith the package installed, now we can start our server with the following command:
$ nodemon server.jsAdding a Movie model
The next thing is to add the movies to the database when we submit the form. Let's go
ahead and create a folder called models in the root directory and add a Movie.js file in
the models directory:
We will be using singular capitalized names for Models, and all lowercase
plural names for Controllers files.The following code into the Movie.js:
const mongoose = require('mongoose');const Schema = mongoose.Schema;
const MovieSchema = new Schema({
name: String,
description: String,
release_year: Number,
genre: String,