Skip to content

Commit

Permalink
add validation and test folder
Browse files Browse the repository at this point in the history
  • Loading branch information
mskian committed Aug 3, 2022
1 parent 633b0b1 commit 313f7d5
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .vercelignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ test.js
app.js
renovate.json
proxy.js
.env
.env
test
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Content-Type: application/json
}
```

- Check [api.rest](/api.rest) file for more details
- Check [api.rest](/test/api.rest) file for more details

## 💡 Learn New word

Expand Down Expand Up @@ -117,19 +117,19 @@ Project - Give Forked Repo URL - Go Live

- Stage all changes

```
```sh
git add .
```

- Commit the changes

```
```sh
yarn commit
```

- Push the changes to GitHub

```
```sh
git push <TO YOUR FORK>
```

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js",
"action": "node test.js",
"action": "node ./test/test.js",
"dev": "nodemon index.js --ext '*'",
"commit": "gacp"
},
Expand Down
12 changes: 8 additions & 4 deletions routes/pronounce.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ router.post("/", function (req, res) {
res.header("Strict-Transport-Security", "max-age=63072000");
res.setHeader("Content-Type", "application/json");

var userWord = encodeURIComponent(req.body.word);
let wordData = pronounce(userWord);
const pronouncedWord = decodeURIComponent(wordData);
res.status(200).json({ pronunciation: pronouncedWord });
var userWord = encodeURIComponent(req.body.word) || "Hello World";
if (userWord == "undefined") {
res.status(400).json({ pronunciation: "Empty data" });
} else {
let wordData = pronounce(userWord);
const pronouncedWord = decodeURIComponent(wordData);
res.status(200).json({ pronunciation: pronouncedWord });
}
});

export default router;
1 change: 0 additions & 1 deletion api.rest → test/api.rest
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
## POST
POST http://localhost:3000/pronounce
Content-Type: application/json

Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 313f7d5

Please sign in to comment.