@@ -8,7 +8,7 @@ Before you start this tutorial it is you need to fulfill all the requirements li
8
8
9
9
10
10
```
11
- 1. Node JS and MySQL installed on your PC.
11
+ 1. Node JS, Nodemon and MySQL installed on your PC.
12
12
2. It is better to have a basic understanding of Node JS, Express JS and MySQL queries.
13
13
3. A text editor or IDE of your choice.
14
14
```
@@ -30,7 +30,7 @@ npm install
30
30
```
31
31
32
32
33
- ## Creating the database for the app
33
+ ## Creating the database and tables for the app
34
34
35
35
``` sql
36
36
@@ -137,24 +137,18 @@ ALTER TABLE `products`
137
137
138
138
## Database connection
139
139
140
- inside app.js file
140
+ create rename .env.example to .env and setup your ENV varaibales
141
141
142
142
``` node
143
- // the mysql.createConnection function takes in a configuration object which contains host, user, password and the database name.
144
- const db = mysql .createConnection ({
145
- host: ' localhost' , // host name
146
- user: ' root' , // username of your database
147
- password: ' root' , // password your application
148
- database: ' app1' // database name of your application
149
- });
150
-
151
- // connect to database
152
- db .connect ((err ) => {
153
- if (err) {
154
- throw err;
155
- }
156
- console .log (' Connected to database' );
157
- });
143
+ # .env .example
144
+ NODE_ENV = development
145
+ PORT = 8000
146
+
147
+ # Set your database connection information here
148
+ DATABASE_HOST = 192.168 .56 .111
149
+ DATABASE_NAME = app1
150
+ DATABASE_USER = homestead
151
+ DATABASE_PASSWORD = secret
158
152
```
159
153
160
154
### Run application
0 commit comments