-
Notifications
You must be signed in to change notification settings - Fork 0
database connected with backend and frontend #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
server/src/routes/user.ts
Outdated
| router.delete('/userDelete',deleteUser); | ||
| router.post('/userCreate',createUser); | ||
| router.put('/updateUser',updateUser) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
route names should not have method name in it. Entity name should be plural.
Like
router.delete('/users/:id',deleteUser);
router.post('/users',createUser);
router.put('/users/:id',updateUser)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Google more for the REST API naming conventions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change the name of route according to naming conventions
server/src/controller/user.ts
Outdated
|
|
||
| export const deleteUser = (req:any,res:any)=>{ | ||
| console.log(req.query.userid); | ||
| pool.query('DELETE FROM users WHERE user_id = $1',[req.query.userid],(q_err:any,q_res:any)=>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
accept user id as a path param
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the path param for userid in both deleteuser and update user
server/src/models/schema.sql
Outdated
| CREATE TYPE roleType AS ENUM ('SuperAdmin', 'Admin', 'Subscriber') DEFAULT 'Subscriber'; | ||
|
|
||
| CREATE TABLE users( | ||
| user_id SERIAL PRIMARY KEY, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
study benefits of uuid for unique ID generation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
study and implement of uuid on database
client/src/tabular.ts
Outdated
|
|
||
| // this load_button element execute function when click on load_button and fetch the data from server | ||
| document.getElementById("load_button")?.addEventListener("click",async()=>{ | ||
| let data: Array<object> = await api("http://localhost:9010/user"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use dotenv package to store configurable parameters in environment file.
use these at other relevant places also, like DB config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the .env file to store config parameters
client/src/app.ts
Outdated
| "address": arr[6], | ||
| "createdDate": arr[7] | ||
| } | ||
| fetch("http://localhost:9010/user/userCreate", {method: "POST",body:JSON.stringify(data),headers: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check comment about route naming and using env file
client/src/app.ts
Outdated
| selectedRowEdit(refer:referType){ | ||
| let j : number = 0; | ||
| for(j=0;j<refer.parentNode.parentNode.cells.length-1;j++){ | ||
| if(j===7){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace 7 with a descriptive constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed the descriptive constant
vineet-suri
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check comments
No description provided.