|
|
@@ -23,14 +23,14 @@ libraryRoutes.get('/all/', jwtAuthentication, async (request, response) => { |
|
|
|
libraryRoutes.get('/search/', jwtAuthentication, async (request, response) => { |
|
|
|
const wordCollection = getDatabaseClient().db(DB_NAME).collection<Word>('words'); |
|
|
|
|
|
|
|
if (!request.body.name) { |
|
|
|
if (!request.query.name) { |
|
|
|
response.status(400); |
|
|
|
response.send("Fill in the word to search for"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const allWords = await wordCollection.find({ |
|
|
|
name: {'$regex':'^' + request.body.name.toString().toUpperCase() + '*'} |
|
|
|
name: {'$regex':'^' + request.query.name.toString().toUpperCase() + '*'} |
|
|
|
}).toArray(); |
|
|
|
|
|
|
|
response.status(200); |
|
|
|