Skip to content

Add endpoint to delete registered door cards#1717

Merged
adarshm11 merged 15 commits intodevfrom
Adarsh/06182025_card_reader_delete_api
Jun 26, 2025
Merged

Add endpoint to delete registered door cards#1717
adarshm11 merged 15 commits intodevfrom
Adarsh/06182025_card_reader_delete_api

Conversation

@adarshm11
Copy link
Copy Markdown
Contributor

This PR depends on PR #1652 , please review that one first

Created a /delete endpoint in OfficeAccessCard.js to delete registered cards

return new Promise((resolve) => {
try {
OfficeAccessCard.findOneAndDelete(
{ cardBytes: cardBytes }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
{ cardBytes: cardBytes }
{ cardBytes }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines +58 to +62
if(!result){
logger.info(`Card:${cardBytes} not found in the database`);
return resolve(false);
}
return resolve(!!result);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if(!result){
logger.info(`Card:${cardBytes} not found in the database`);
return resolve(false);
}
return resolve(!!result);
if(!result){
logger.info(`Card:${cardBytes} not found in the database`);
}
return resolve(!!result);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines +144 to +150
router.get('/delete', async (req, res) => {
const { cardBytes } = req.query;
const apiKey = req.headers['x-api-key'];
const required = [
{ value: apiKey, title: 'X-API-Key HTTP header', },
{ value: cardBytes, title: 'cardBytes query parameter', },
];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lets rely on a token instead, i dont think we will be using api keys to delete cards

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

will do

Base automatically changed from Adarsh/05272025_card_reader_ui to dev June 20, 2025 20:35
Copy link
Copy Markdown
Collaborator

@hunter-nguyen hunter-nguyen left a comment

Choose a reason for hiding this comment

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

lgtm adarsh

@adarshm11 adarshm11 merged commit 28624bd into dev Jun 26, 2025
4 checks passed
@adarshm11 adarshm11 deleted the Adarsh/06182025_card_reader_delete_api branch June 26, 2025 02:44
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