
- Software Engineer, Product
- Modern Technology stacks:
- So What is a Tech Stack?
- Frontend tech stack
- Backend tech stack
- How to choose/build a tech stack
- What is a CI/CD Pipeline?
- Software Business Analyst
- Node.js Express Back-end App
- Build React App With Java Backend
- Connecting React-Frontend and NodeJS/Express Backend Applications
- React-Frontend, Node.js/Express-Backend, MySQL Architecture
- React Frontend with a NodeJS/Express Backend SQL-Architecture
- So What is git ?
- Git vs GitHub
- Big O Notation


Node.js Express Back-end App Overview



Project Structure

* db.config.js exports configuring parameters for MySQL connection & Sequelize.
* Express web server in server.js where we configure CORS, initialize & run Express REST APIs.
* Next, we add configuration for MySQL database in models/index.js, create Sequelize data model in models/tutorial.model.js.
* Tutorial controller in controllers.
* Routes for handling all CRUD operations (including custom finder) in tutorial.routes.js.
This backend works well with frontend in this tutorial.
Implementation
Create Node.js AppFirst, we create a folder:
mkdir nodejs-express-sequelize-mysql
- Navigate to the project directory: Use the cd command to navigate into the newly created directory:
cd nodejs-express-sequelize-mysql
Next, we initialize the Node.js App with a package.json file:
-Initialize a new Node.js project: To initialize a new Node.js project, run the following command in your terminal:
npm init
This command will prompt you to provide information about your project, such as the name, version, description, entry point, etc. You can press enter to accept the default values or provide your own.
{
"name": "nodejs-express-sequelize-mysql",
"version": (1.0.0) ,
"description": "Node.js Rest Apis with Express, Sequelize & MySQL",
"entry point": "(index.js) server.jsst",
"strict": true,
"test command": ,
"git repository": ,
"Author": Jama Hassan
},
"license": ["(ISC)"],
"exclude": ["node_modules"]
}
- Install the necessary dependencies: With your project initialized, We need to install the required dependencies. In this case, We need to install necessary modules: express, sequelize, mysql2 and cors.
Run the following command in your terminal to install these dependencies:
npm install express sequelize mysql2 cors--save
npm install express sequelize mysql2 cors --save
This command will download and install the specified packages and save them as devDependencies in your package.json file.
This command will download and install the specified packages and save them as devDependencies in your package.json file.
Full-Stack Engineer
