-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from Nailsonseat/room-vacancy-lost-and-found-two
Room Vacancy and Lost & Found v2
- Loading branch information
Showing
25 changed files
with
527 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import express from "express"; | ||
import * as messages from "../../constants/messages.js"; | ||
import LostAndFoundItem from "../../models/lost_and_found.js"; | ||
import fs from "fs"; | ||
|
||
const lostAndFoundRouter = express.Router(); | ||
|
||
// DELETE item by id | ||
lostAndFoundRouter.delete("/:id", async (req, res) => { | ||
const itemId = req.params.id; | ||
|
||
try { | ||
const item = await LostAndFoundItem.findByIdAndDelete(itemId); | ||
|
||
if (!item) { | ||
return res.status(404).json({ message: messages.itemNotFound }); | ||
} | ||
|
||
// Delete the image file | ||
fs.unlink(item.imagePath, (err) => { | ||
if (err) { | ||
console.error(err); | ||
} | ||
}); | ||
|
||
res.json(item); | ||
} catch (err) { | ||
res.status(500).json({ message: messages.internalServerError }); | ||
} | ||
}); | ||
|
||
export default lostAndFoundRouter; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.