Skip to content

dperezzaro/node-coding-exercise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-coding-exercise

The purpose of this coding exercise is to create a Node.js application that can programmatically remove all duplicate fields and objects from the given mock application schema and output a new sanitized version.

Requirements

Please check the original README file.

Notes

The following assumptions have been made:

  • schema.versions is an array of objects
  • schema.versions[\*].objects is an array of objects
  • schema.versions[\*].objects[\*].name exists and is a scalar
  • schema.versions[\*].objects[\*].fields is an array of objects
  • schema.versions[\*].objects[\*].fields[\*].name exists and is a scalar
  • schema.versions[\*].scenes is an array of objects
  • schema.versions[\*].scenes[\*].key exists and is a scalar
  • schema.versions[\*].scenes[\*].views is an array of objects
  • schema.versions[\*].scenes[\*].views[\*].key exists and is a scalar

The main app is src/index.js, by default it reads the schema from data/mock_application.json and writes a sanitized version to output/clean_application.json.

The parsing logic is in src/lib/removeDuplicates.js, it exports a single function which accepts a javascript object (the application schema) and optionally a filter object that overrides the default fields to be sanitized (as specified in the original requirements).

Unit tests have been written for this main function, but not for the application's CLI parsing / file handling.

Possible next steps:

  • Implement an ApplicationSchema class that allows to:
  • Read / write from different sources (object, ile, db, cache, etc)
  • Configure the fields to be checked
  • Validate the input schema against a JSON schema
  • Increase coverage of tests

Usage

Install dependencies

npm install

Run tests

npm test

Run application

npm start <file>

If file is not specified it will read the schema from {repo_root}/data/mock_application.json.

The output schema will be written to {repo_root}/out/clean_application.json

Dependencies

The following external modules have been used:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published