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.
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.
Google more for the REST API naming conventions
There was a problem hiding this comment.
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.
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.
study benefits of uuid for unique ID generation
There was a problem hiding this comment.
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.
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.
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.
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.
replace 7 with a descriptive constant
There was a problem hiding this comment.
changed the descriptive constant
No description provided.