Validating Route Parameters

In this lesson, we'll learn how we can return a 404 Not Found exception when someone tries to view a movie that doesn't exist. We'll then learn how we can validate our route parameters using Regular Expressions or matchers.

Published
Jan 24, 24
Duration
6m 7s

Developer, dog lover, and burrito eater. Currently teaching AdonisJS, a fully featured NodeJS framework, and running Adocasts where I post new lessons weekly. Professionally, I work with JavaScript, .Net C#, and SQL Server.

Adocasts

Burlington, KY

Get the Code

Download or explore the source code for this lesson on GitHub

Repository

Join The Discussion! (3 Comments)

Please sign in or sign up for free to join in on the dicussion.

  1. Commented 11 months ago

    Warning: When using the fs readFile function, or another readfile function, if you don't check the user input properly, you can expose yourself to the possibility of someone going back into your tree and reading arbitrary files on your server.

    For example :
    * fs.readFileSync('../../../../../../../etc/passwd', 'utf8')
    *
    fs.readFileSync('%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2e%2e%2e%2f%2e%2e%2fetc%2fpasswd', 'utf8')

    2

    Please sign in or sign up for free to reply

  2. Commented 2 months ago

    very good

    1

    Please sign in or sign up for free to reply

    1. Commented 2 months ago

      Thank you, mrs3rver!!

      0

      Please sign in or sign up for free to reply

Playing Next Lesson In
seconds