Skip to content

Commit 9496e97

Browse files
committed
Add Vercel
1 parent 4011789 commit 9496e97

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

index.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,21 @@ const sendAnswer = (req, res) => {
8686
delimiters: ["{", "}"],
8787
});
8888

89-
const {
90-
amount,
91-
unitFrom,
92-
unitTo,
93-
} = valuesObj;
94-
9589
rating = 1;
9690
action = "unit_converter";
97-
responseText = changeUnit(amount, unitFrom, unitTo);
91+
92+
try {
93+
const {
94+
amount,
95+
unitFrom,
96+
unitTo,
97+
} = valuesObj;
98+
99+
responseText = changeUnit(amount, unitFrom, unitTo);
100+
} catch (error) {
101+
responseText = "One or more unit missing.";
102+
console.log(error);
103+
}
98104
} else {
99105
const similarQuestionObj = stringSimilarity.findBestMatch(humanInput, allQustions).bestMatch;
100106
const similarQuestionRating = similarQuestionObj.rating;

intents/unit_converter.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[
2-
"change {amount} {unit_from} into {unit_to}",
3-
"can you convert {amount} {unit_from} to {unit_to}",
4-
"convert {amount} {unit_from} into {unit_to}",
5-
"how many {unit_to} in {amount} {unit_from}"
2+
"change {amount} {unitFrom} into {unitTo}",
3+
"change {amount} {unitFrom} to {unitTo}",
4+
"can you convert {amount} {unitFrom} to {unitTo}",
5+
"convert {amount} {unitFrom} into {unitTo}",
6+
"how many {unitTo} in {amount} {unitFrom}"
67
]

vercel.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"version": 2,
3+
"builds": [
4+
{
5+
"src": "index.js",
6+
"use": "@vercel/node"
7+
}
8+
],
9+
"routes": [
10+
{
11+
"src": "/(.*)",
12+
"dest": "/"
13+
}
14+
]
15+
}

0 commit comments

Comments
 (0)