Follow the instructions step-by-step.
-
Install Dependencies
npm install
-
Create Database
- Create a database in MySQL with the name
my_test.
- Create a database in MySQL with the name
-
Run Migrations
knex migrate:latest
-
Start the Server
npm start
=============
-
Insert User
- URL:
http://localhost:3000/users - Method:
POST - Body:
{ "name": "demo5", "email": "[email protected]" }
- URL:
-
List Users
- URL:
http://localhost:3000/users - Method:
GET
- URL:
-
Get User By ID
- URL:
http://localhost:3000/users/{id} - Method:
GET
- URL:
-
Update User
- URL:
http://localhost:3000/users/{id} - Method:
PUT - Body:
{ "name": "abc", "email": "[email protected]" }
- URL:
-
Delete User
- URL:
http://localhost:3000/users/{id} - Method:
DELETE
- URL:
-
Open
report.jsfile. -
Add your Gmail credentials:
auth: { user: process.env.USER || 'add your mail', pass: process.env.PASSWORD || 'generate app password' // if you don't know how to generate, follow https://www.youtube.com/watch?v=nuD6qNAurVM }
-
Set the mail options:
const mailOptions = { from: process.env.USER || 'add your mail', // Add your mail to: process.env.ADMIN || 'add admin mail', // Get daily report on this mail subject: 'Daily New Users Summary', text: `New users added today: ${userEmails}` };
- Ensure MySQL is running and accessible.
- Configure your
.envfile (if using) with the appropriate database credentials and other environment-specific settings. - The email credentials should be kept secure. Consider using environment variables or a secrets management tool.