Skip to content

Instantly share code, notes, and snippets.

@lucasmonstrox
Created January 11, 2024 16:38
Show Gist options
  • Save lucasmonstrox/b7ad969b6abf915ed3cb51f4d40fc2d0 to your computer and use it in GitHub Desktop.
Save lucasmonstrox/b7ad969b6abf915ed3cb51f4d40fc2d0 to your computer and use it in GitHub Desktop.
app.ts
import { StatusCodes } from 'http-status-codes';
const { id } = req.params;
const bookIndex = books.findIndex((book) => book.id === parseInt(id));
const bookNotFound = bookIndex === -1;
if (bookNotFound) {
res.status(StatusCodes.NOT_FOUND).send();
return;
}
books.splice(bookIndex, 1);
res.status(statusCodes.NO_CONTENT).send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment