Translate

Sunday, 20 January 2019

Build Your First Router in Node with Express

Serverless Development with Node.js AWS Lambda and MongoDB Atlas

This article was originally published on the Okta developer blog. Thank you for supporting the partners who make SitePoint possible.

If you’ve done any web development with Node in the last few years, you’ve probably used Express. Even if you haven’t used it directly, many frameworks meant to make web development even simpler are still built on Express.

One of the key features in Express is the ability to create routes. An infinite combination of URLs can hit the same Express server, and routes are how you can determine which URLs run what piece of code. You can have parameters and wildcards so that you don’t have to explicitly state each endpoint.

In this tutorial, I’ll walk you through creating a server and teach you all you need to know about routes in Express.

What is a Route in Express?

Routes determine what data should be delivered given any URL. Let’s take the most basic file server as an example. Say you have a file structure of:

The post Build Your First Router in Node with Express appeared first on SitePoint.



No comments:

Post a Comment