| @@ -23,14 +23,14 @@ libraryRoutes.get('/all/', jwtAuthentication, async (request, response) => { | |||||
| libraryRoutes.get('/search/', jwtAuthentication, async (request, response) => { | libraryRoutes.get('/search/', jwtAuthentication, async (request, response) => { | ||||
| const wordCollection = getDatabaseClient().db(DB_NAME).collection<Word>('words'); | const wordCollection = getDatabaseClient().db(DB_NAME).collection<Word>('words'); | ||||
| if (!request.body.name) { | |||||
| if (!request.query.name) { | |||||
| response.status(400); | response.status(400); | ||||
| response.send("Fill in the word to search for"); | response.send("Fill in the word to search for"); | ||||
| return; | return; | ||||
| } | } | ||||
| const allWords = await wordCollection.find({ | const allWords = await wordCollection.find({ | ||||
| name: {'$regex':'^' + request.body.name.toString().toUpperCase() + '*'} | |||||
| name: {'$regex':'^' + request.query.name.toString().toUpperCase() + '*'} | |||||
| }).toArray(); | }).toArray(); | ||||
| response.status(200); | response.status(200); | ||||
| @@ -14,8 +14,15 @@ export const jwtAuthentication = passport.authenticate('jwt', { session: false } | |||||
| categoryRoutes.get('/details/', jwtAuthentication, async (request, response) => { | categoryRoutes.get('/details/', jwtAuthentication, async (request, response) => { | ||||
| const categoryCollection = getDatabaseClient().db(DB_NAME).collection<MongoCategory>('categories'); | const categoryCollection = getDatabaseClient().db(DB_NAME).collection<MongoCategory>('categories'); | ||||
| if (!request.query._id) { | |||||
| response.status(400); | |||||
| response.send("Missing category _id"); | |||||
| return; | |||||
| } | |||||
| const currentCategory = await categoryCollection.findOne({ | const currentCategory = await categoryCollection.findOne({ | ||||
| _id: new ObjectId(request.body._id), | |||||
| _id: new ObjectId(request.query._id.toString()), | |||||
| }); | }); | ||||
| if (currentCategory) { | if (currentCategory) { | ||||
| @@ -17,7 +17,7 @@ shelfRoutes.get('/details/', jwtAuthentication, async (request, response) => { | |||||
| const shelfCollection = getDatabaseClient().db(DB_NAME).collection<MongoShelf>('shelves'); | const shelfCollection = getDatabaseClient().db(DB_NAME).collection<MongoShelf>('shelves'); | ||||
| const currentShelf = await shelfCollection.findOne({ | const currentShelf = await shelfCollection.findOne({ | ||||
| _id: new ObjectId(request.body._id) | |||||
| _id: new ObjectId(request.query._id.toString()) | |||||
| }); | }); | ||||
| if (!currentShelf) { | if (!currentShelf) { | ||||