Backend Class 2.
Love Babber (BD-2)
Send Data in DB and see folder structure.
Some steps of creating a folder.
Create a folder on the desktop
open it into in VS code
Open Vs code terminal
Initialization of the packege.json file using
npm init -y
commandCreate a file name
index.js
Now install express js using
npm i express
Now install Nodemon using
npm i nodemon
Now install env files to set the environment using
npm i dotenv
Create 4 different folders (routes, config, controller, models)
Create a
.env
file in the routes folderCreate a
database.js
file in the config folder to connect our DB to the serverCreate a
createTodo.js
file in the controller folder to control the dataCreate a
todo.js
file in the models' folder to create a DB SchemaCreate a
todos.js
file in the routes folder to define the API Routes
See the code example to connect the db to the server.
Index.js file code
database.js file code (Connect to DB)
todo.js file code (define Schema)
todos.js file (Creating routes)
createTodo.js (Doing funclatity)
.env file
Package.json file