The goal of these exercises are to assess your proficiency in software engineering that is related to the daily work that we do at Xendit. Please follow the instructions below to complete the assessment.
- Create a new repository in your own github profile named
backend-coding-testand commit the contents of this folder - Ensure
node (>8.6 and <= 10)andnpmare installed - Run
npm install - Run
npm test - Run
npm start - Hit the server to test health
curl localhost:8010/healthand expect a200response
Below will be your set of tasks to accomplish. Please work on each of these tasks in order. Success criteria will be defined clearly for each task
Please deliver documentation of the server that clearly explains the goals of this project and clarifies the API response that is expected.
Answer:
- Used node 10.0.0 and added
.nvmrcprevent using other node version. - Added dependecies for documentation
npm i swagger-ui-express yamljs -S - Added
docsfolder undersrcwhere the yaml file for documentations. - Added
/api-docsrotues for the API documentation and accessible only in development/staging. - Added
nodemonfor development changes reload/restart. - Updated some status code accordingly.
- A pull request against
masterof your fork with a clear description of the change and purpose and merge it - [BONUS] Create an easy way to deploy and view the documentation in a web format and include instructions to do so
Please implement the following tooling:
eslint- for lintingnyc- for code coveragepre-push- for git pre push hook running testswinston- for logging
Answer:
- Added dependecies for logging
npm i winston -S. - Added dev dependecies for logging
npm i eslint eslint-config-airbnb-base eslint-plugin-import nyc pre-push chai sinon -SD. - Added eslint standard config.
- Added threshold for test coverage
80%. - Added pre-push to run lint and test converage.
- Fix some eslint issues.
- Added test coverage.
- Create a pull request against
masterof your fork with the new tooling and merge iteslintshould have an opinionated formatnycshould aim for test coverage of80%across lines, statements, and branchespre-pushshould run the tests before allowing pushing usinggitwinstonshould be used to replace console logs and all errors should be logged as well. Logs should go to disk.
- Ensure that tooling is connected to
npm test - Create a separate pull request against
masterof your fork with the linter fixes and merge it - Create a separate pull request against
masterof your fork to increase code coverage to acceptable thresholds and merge it - [BONUS] Add integration to CI such as Travis or Circle
- [BONUS] Add Typescript support
Please implement pagination to retrieve pages of the resource rides.
Answer:
- Updated GET
/ridesto add pagination - Added query paramaters to add
pageandsize - Updated unit tesing.
- Updated documentation.
- Create a pull request against
masterwith your changes to theGET /ridesendpoint to support pagination including:- Code changes
- Tests
- Documentation
- Merge the pull request
Please implement the following refactors of the code:
Answer:
- Refactor API calls divide logic flow
- Refactor index.js and app for readable format
- Added unit testing
- [Security] Updated issue on sql injection
- Updated test coverage
- Updated
npm testinclude test coverage
- Convert callback style code to use
async/await - Reduce complexity at top level control flow logic and move logic down and test independently
- [BONUS] Split between functional and imperative function and test independently
- A pull request against
masterof your fork for each of the refactors above with:- Code changes
- Tests
Please implement the following security controls for your system:
Answer :
- Solved issue on GetRidesById query, id was append on the sql
- Added Helmet for the additional security with standard security features.
- Ensure the system is not vulnerable to SQL injection
- [BONUS] Implement an additional security improvement of your choice
- A pull request against
masterof your fork with:- Changes to the code
- Tests ensuring the vulnerability is addressed
Please implement load testing to ensure your service can handle a high amount of traffic
Answer :
- Added
artilleryin dev dependecies - Added
npm test:loadin npm scripts - Added
integration/api.yamlfor the load scripts - Added
rides.csvfor the load scripts data
- Implement load testing using
artillery- Create a PR against
masterof your fork including artillery - Ensure that load testing is able to be run using
npm test:load. You can consider using a tool likeforeverto spin up a daemon and kill it after the load test has completed. - Test all endpoints under at least
100 rpsfor30sand ensure thatp99is under50ms
- Create a PR against