muriloamendola / nextjs-playground

Production grade React applications that scale? Let's see it!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Next.JS Playground

Actions Status Maintainability Test Coverage JavaScript Style Guide

First I use it to test Next.JS and its various features. I had a big headache to configure Jest with it in order to work properly but now everything seems OK.

Well here you'll see my solution for a code-challenge which I believe is not used anymore as it is old, maybe if you search for it you may find it somewhere in GitHub.

As always I'm following Yoda's philosophy, that's why this project exists.

Run NOW with Docker

Simply execute:

docker run -itd --name nextjs-playground \
-p 3000:3000 \
-e NEXTJS_BIND_PORT=3000 \
-e API_TVMAZE_ENDPOINT=https://api.tvmaze.com \
-e PAGE_DETAILS_ENDPOINT=http://localhost:3000/api/page-details \
willianantunes/nextjs-playground

Access on your browser: http://localhost:3000

See the logs:

docker logs -f nextjs-playground

How to run and test it locally

Run it:

docker-compose up app

Execute the following to test everything:

docker-compose up all-test

Challenge details

  1. @mentions: A way to mention a user. Always starts with an '@' and ends when hitting a non-word.
  2. Emoticons: For this exercise, you only need to consider 'custom' emoticons which are ASCII strings, no longer than 15 characters, contained in parenthesis. You can assume that anything matching this format is an emoticon.
  3. Links: Any URLs contained in the message, along with the page's title.

For example, calling your function with the following inputs should result in the corresponding return values.

Input: "@chris you around?"

Return (string):

{
  "mentions": [
    "chris"
  ]
}

Input: "Good morning! (megusta) (coffee)"

Return (string):

{
  "emoticons": [
    "megusta",
    "coffee"
  ]
}

Input: "Olympics are starting soon; http://www.nbcolympics.com"

Return (string):

{
  "links": [
    {
      "url": "http://www.nbcolympics.com",
      "title": "NBC Olympics | Home of the 2016 Olympic Games in Rio"
    }
  ]
}

Input: "@bob @john (success) such a cool feature; https://twitter.com/jdorfman/status/430511497475670016"

Return (string):

{
  "mentions": [
    "bob",
    "john"
  ],
  "emoticons": [
    "success"
  ],
  "links": [
    {
      "url": "https://twitter.com/jdorfman/status/430511497475670016",
      "title": "Justin Dorfman on Twitter: \"nice @littlebigdetail from ..."
    }
  ]
}

Useful links

About Next.JS and so on:

About testing:

About

Production grade React applications that scale? Let's see it!


Languages

Language:JavaScript 99.0%Language:Dockerfile 1.0%