Express: Handling Routes with Skyrim 🐉 ⚔️ 🪄

Created by: 7Legionarmy 😎
What you’ll need 🧰1. Understanding of Express.js basic setup2. Response + Request Cycle3. Express.js Middleware — — — — — — — — — — — — — — -Helpful Blogs 🧙‍♀️ 📜 🪶1. Express.js: https://ineedmoreplates.medium.com/express-js-learn-with-p-e-memes-bfa080b5a9182. Middleware Functions: https://ineedmoreplates.medium.com/learn-express-js-middleware-functions-mario-bros-6b8d8214cc32
Long way to Markarth from here… ⚖️ 😓🚶
“Routing is the process of selecting a path for traffic in a network or between or across multiple networks. Broadly, routing is performed in many types of networks, including circuit-switched networks, such as the public switched telephone network (PSTN), and computer networks, such as the Internet.”- Wikipedia
in app.jsconst express = require(‘express’);const app = express();app.use(😯 ‘/’😯 ,(req,res,next) => { ← first argument is a path😯next() ← go to next middleware 🥾 🥾 🥾});app.listen(3000);
50 septim !!!! In this economy? No thanks, buddy I’ll walk! 😡 💼 🏃
In terminal 🧑‍💻npm install — save body-parser — — — — — for reference 👀Dragonbones 🐉 🦴 🪙weight: 15Base Cost: 500. ←- That’s really good 💰
in app.jsconst express = require(‘express’);const app = express();const bodyParser= require(‘body-parser’) ← Import here 😯app.use(bodyParser.urlendcoded({extended: false})) ← bodyparser 😯app.use(‘/’ ,(req,res,next) => {next()});app.use(‘/markarth’ ,(req,res,next) => { ← we want to go here 🐎res.send(‘<h1>Greetings from Markarth!!!</h1>’) ← sends a response, html code 😯});app.use(‘/whiterun’ ,(req,res,next) => {res.send(‘<h1>Welcome to White Run!!!</h1><form action=”/markarth” method=”POST”><input type=”text” ><button></form>’ ←- enter what’s being shipped !});app.use(‘/winterhold’ ,(req,res,next) => {res.send(‘<h1>Greetings from Winterhold!!!</h1>’)});app.listen(3000);
Housecarl… I need you to hold something for me 🧝
Check out these links! 😎
Cool Links Here:Express Docs on Routing: https://expressjs.com/en/guide/routing.htmlWiki Link (Routing): https://en.wikipedia.org/wiki/RoutingbodyParser npm: https://www.npmjs.com/package/body-parserMore on .urlencoded(extended: false) https://github.com/expressjs/body-parser#bodyparserurlencodedoptionsReddit post about 7Legionarmy’s artwork: https://www.reddit.com/r/inkarnate/comments/d6486y/skyrim/

--

--

Career Changer, Software Engineer & Web Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store