Skip to content

Latest commit

 

History

History
136 lines (110 loc) · 4.92 KB

README.md

File metadata and controls

136 lines (110 loc) · 4.92 KB

Node.JS Engineer's Code Challenge

The goal of this challenge is to create a browser application which receives, validates and displays data from a user.

Since it takes a while, we've prepared the application skeleton for you. It's not really a browser application, but we'll pretend that it is. ;)

In the provided skeleton, you should implement just two actions:

  1. Store action, which should validate and persist sample data in external service(s)
  2. Fetch action, which should retrieve data and ensure its integrity

Also, your solution must implement at least one of the following types of external services:

  1. Peer-to-peer service which hypothetically runs on user's hosts. Let’s call it "P2P" service. Networking and storage will be cheap for you - 0.0001$ per byte, but you can’t trust this service because a malicious user may spoof (modify) your data.
  2. Self-hosted service which runs on your server. Let’s call it "hosted" service. Networking and storage will be much more expensive for you - 0.001$ per byte, but the data is located on your server, so you can trust it.

For communication with your external service(s) we provide two functions which are wrappers around whatwg fetch. They help us to calculate incoming and outgoing traffic.

These functions are available for both the store and fetch application actions:

  • p2pFetch - should be used to store / retrieve data for P2P services
  • hostedFetch - function to store / retrieve data for hosted services

Your mission

  • Clone this repository
  • Implement as many external services as you need to store sample data from the application
  • Implement the store action. Validate and persist sample data in the external service(s)
  • Implement the fetch action. Fetch sample data back and ensure its integrity. When you fetch data back from the untrusted service, you should verify it for spoofing protection
  • Write beautiful code. Code design (SOLID, Clean Architecture, 12factor) is important to us.
  • Run application and see results. Try to spend as little money as possible. Cost depends on the size of request / response and elapsed time. You may find the exact formula in the application skeleton code
  • Send us an archive with your solution

Requirements

External services

  • Services should be written in JavaScript and run with Node.JS
  • Services should be dockerized and started with docker compose in the root directory
  • Data should be permanently persisted (i.e. available after a service restart)

Application

  • You should validate sample data in the store action. Throw error if data is not valid
  • You should check data integrity in the fetch action to avoid spoofing. Keep in mind that you don't have access to the original input data which you received in the store action
  • Make sure the data returned by the fetch action matches the input data from the store action
  • You should use p2pFetch for sending / retrieving data from a P2P service
  • You should use hostedFetch for sending / retrieving data from a hosted service
  • You cannot store any data on the application side

Sample data validation rules

Sample data represents a collection of various objects. Each type of object has its own validation rules.

User

  • id
    • Format: a-zA-Z0-9
    • Length: 256
    • Required
  • type
    • Value: user
    • Required
  • userName
    • Format: a-zA-Z0-9_.
    • Max length: 20
    • Required
  • firstName
    • Max length: 100
  • lastName
    • Max length: 100
  • email
    • According to RFC

Payment

  • id
    • Format: a-zA-Z0-9
    • Length: 256
    • Required
  • type
    • Value: payment
    • Required
  • fromUserId
    • Format: a-zA-Z0-9
    • Length: 256
    • Required
  • toMerchantId or toUserId
    • Format: a-zA-Z0-9
    • Length: 256
    • Required
  • amount
    • Format: float number
    • Not equal or less than 0
    • Required
  • createdAt
    • Format: Date ISO 8601
    • Required

Merchant

  • id
    • Format: a-zA-Z0-9
    • Length: 256
    • Required
  • type
    • Value: merchant
    • Required
  • name
    • Format: a-zA-Z0-9
    • Max length: 20
    • Required

Summary

Follow the challenge mission according to the provided requirements and do your best. Good luck!

Submission

Please email us [email protected] your submission, which includes your name, code, and a short description of what technologies you used and why, and also how and what you would improve about your solution if you had more time :)

License

MIT © 2018 Dash Core Team