-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotes.txt
34 lines (33 loc) · 1.84 KB
/
notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
server.js file was created
npm init
npm i mongoose
mongodb.com ---> create database--> connect -->copy the connection string
create .env file in root directory
put the connection string in the .env file
npm i dotenv
create config dir --> create DBconn.js in it-->export the function --> use in server.js-->connectDB()
check if the database is connected before listening to the port. And only listen if the DB is connected
write the builtin middlewares:
To handle urlencoded data/form data
For json
For serving static files //self:- setting folder for serving css files
create the html pages in the views folder: index.html, 404.html, new-page.html .Link the css file to it.Which is present in the public folder in root dir. : public/css/style.css
create a routes folder
create a router for root page /index page -> root.js
write the code in root.js to serve the html files
the import this router in main server.js file
create mongoose schema for Users and Employee:
create User.js and Employee.js in model folder
create the mongoose schema in them
create a registration route and registerController to register new user
npm i bcrypt
check for ./public/img/rregisterNewUserPOSTRequest.png It is the screenshot of the post request=>registration of new user
npm i cors
create auth route and authController to login existing user
npm i jsonwebtoken
npm i cookie-parser
add ACCESS_TOKEN_SECRET and REFRESH_TOKEN_SECRET in .env file using:-> require('crypto').randomBytes(64).toString('hex')
create verifyJWT middleware
create employee route in api folder in routers folder. And create employeeController to GET,PUT,POST,DELETE an employee.
Add ROLES_LIST in config folder.
Add verifyRoles. And use it in employeesRoute to verify roles before getting/updating/creating/deleting an employee