Skip to content

Conversation

@VipulSha99
Copy link
Owner

No description provided.

Comment on lines 7 to 9
router.delete('/userDelete',deleteUser);
router.post('/userCreate',createUser);
router.put('/updateUser',updateUser)
Copy link

@vineet-suri vineet-suri Jul 19, 2022

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)

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

Copy link
Owner Author

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


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)=>{

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

Copy link
Owner Author

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

CREATE TYPE roleType AS ENUM ('SuperAdmin', 'Admin', 'Subscriber') DEFAULT 'Subscriber';

CREATE TABLE users(
user_id SERIAL PRIMARY KEY,

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

Copy link
Owner Author

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


// 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");

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

Copy link
Owner Author

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

"address": arr[6],
"createdDate": arr[7]
}
fetch("http://localhost:9010/user/userCreate", {method: "POST",body:JSON.stringify(data),headers: {

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

selectedRowEdit(refer:referType){
let j : number = 0;
for(j=0;j<refer.parentNode.parentNode.cells.length-1;j++){
if(j===7){

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

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed the descriptive constant

Copy link

@vineet-suri vineet-suri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants