Skip to content

Commit

Permalink
Added invalid routes handling
Browse files Browse the repository at this point in the history
  • Loading branch information
aledipa committed Jun 25, 2023
1 parent 7d3a478 commit b31209c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ app.get('/terms', (req, res) => {
res.sendFile(__dirname + '/views/terms.html');
});

// Handling non existing page request
app.get('*', (req, res) => {
res.redirect('/')
});

// Handling search request
app.get('/result', (req, res) => {
if (req.query.search == '') { return res.redirect('/'); }
Expand Down Expand Up @@ -82,6 +77,11 @@ app.post("/suggestion", async (req, res) => {
})();
});

// Handling non existing page request
app.get('*', (req, res) => {
res.redirect('/')
});

// Server listening on given port
app.listen(port, () => console.info('Listening on port ' + port ));

Expand Down

0 comments on commit b31209c

Please sign in to comment.