-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler.js
More file actions
46 lines (38 loc) · 978 Bytes
/
handler.js
File metadata and controls
46 lines (38 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"use strict";
// const apikey = require("./credentials/index").key;
const data = require("./data/dictionary.json");
const listOfWords = require("./data/all_words.json");
module.exports.dictionary = async (event) => {
let word = event.queryStringParameters.word;
let meaning = data.filter(
(dict) => word.toLowerCase() === dict.word.toLowerCase()
);
// let api = event.queryStringParameters.apikey;
return {
statusCode: 200,
body: JSON.stringify(
{
word,
meaning: meaning.length > 0 ? meaning[0].meaning : "NOT FOUND",
},
null,
2
),
};
};
module.exports.wordExist = async (event) => {
let wordExist = event.queryStringParameters.word;
let result = listOfWords.filter(
(index) => wordExist.toLowerCase() === index.toLowerCase()
);
return {
statusCode: 200,
body: JSON.stringify(
{
wordExist: result.length > 0 ? true : false,
},
null,
2
),
};
};