Skip to content

Instantly share code, notes, and snippets.

@sgnl
Last active November 13, 2019 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 11 You must be signed in to fork a gist
  • Save sgnl/cfe5e4b715fdd75f1a36 to your computer and use it in GitHub Desktop.
Save sgnl/cfe5e4b715fdd75f1a36 to your computer and use it in GitHub Desktop.
Redacted

Redacted

One of your clients have contacted you with a problem. Their Users have figured out that their chat messages aren't filtered and they can say anything that they want. The CEO dislikes the slang terms being used on the internet and wants to implement a system which will remove certain words and replace them.

Goal

Your task is to build middleware for Express which will search through a message's contents and replace certain words with ones that are more, family-friendly. You have been given a set of words to which have been blacklisted.

You will build a small project which will test your middleware.

Blacklisted words and acceptable replacements

  • Selfie : self-portrait
  • yummers : delicious
  • outchea : are out here
  • bruh : wow
  • doge : pug
  • cilantro : soap
  • bae : loved one
  • swag : style
  • yolo : carpe diem

Example input #1:

I took a selfie with my bae next to a tardis. yolo!

Filtered output:

I took a self-portrait with my loved one next to a tardis. carpe diem!

Example inout #2:

we outchea! saw a doge, #bruh!

Filtered output:

we are out here! saw a pug, #wow!

Requirements (minimal)

  • ExpressJs
    • body-parser
    • custom middlware for filtering text

Server

Middleware

Built a filtering middleware to find and replace blacklisted words.

POST '/message' (required)

This is the endpoint for your form. You will respond with the data stored at req.body after replacing redacted words. response: { "message": "we are out here! saw a pug, #wow!" }

References

Express Routes

Express Middleware

PugJs Template Engine formerly known as Jade or handlebars

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment