Skip to content

Latest commit

 

History

History
113 lines (79 loc) · 5.53 KB

Readme.md

File metadata and controls

113 lines (79 loc) · 5.53 KB

Xendit Coding Exercise

CircleCI codecov

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.

Setup

  1. Fork this repository to your own github profile
  2. Ensure node (>=12) and npm are installed
  3. Run npm install
  4. Run npm test
  5. Run npm start
  6. Hit the server to test health curl localhost:8010/health and expect a 200 response

Tasks

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

Documentation

Please deliver documentation of the server that clearly explains the goals of this project and clarifies the API request and response that is expected. Feel free to use any open source documentation tools such as OpenAPI / Swagger.

Success Criteria

    • A pull request against master of 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 - (Check below)
Steps

Implement Tooling

Please implement the following tooling:

    • eslint - for linting
    • nyc - for code coverage
    • pre-push - for git pre push hook running tests - (Using husky instead)
    • winston - for logging

Success Criteria

    • Create a pull request against master of your fork with the new tooling and merge it
      • eslint should have an opinionated format
      • nyc should aim for test coverage of 80% across lines, statements, and branches
      • pre-push should run the tests before allowing pushing using git
      • winston should 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
    • Ensure that tests covers possible positive and negative scenarios
    • Create a separate pull request against master of your fork with the linter fixes and merge it
    • Create a separate pull request against master of your fork to increase code coverage to acceptable thresholds and merge it
    • [BONUS] Add integration to CI such as Travis or Circle - (CircleCI is being chosen here with Codecov integration)
    • [BONUS] Add Typescript support

Implement Pagination

Please implement pagination to retrieve pages of the resource rides.

    • Create a pull request against master with your changes to the GET /rides endpoint to support pagination including:
      • Code changes
      • Tests
      • Documentation
    • Merge the pull request

Refactoring

Please implement the following refactors of the code:

    • 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

Success Criteria

    • A pull request against master of your fork for each of the refactors above with:
      • Code changes
      • Tests covering positive and negative scenarios

Security

Please implement the following security controls for your system:

    • [BONUS] Implement an additional security improvement of your choice

Solutions

  • Added TypeORM in this project and no raw SQL query being called with repo.query
  • where: { riderName: Like(%${query.keyword}%) } will not treat riderName as a partial SQL syntax, but rather a prepared statements.

Success Criteria

    • [] A pull request against master of your fork with:
      • Changes to the code
      • Tests ensuring the vulnerability is addressed

Load Testing

Please implement load testing to ensure your service can handle a high amount of traffic

Success Criteria

    • Implement load testing using artillery
      • Create a PR against master of your fork including artillery
      • Ensure that load testing is able to be run using npm test:load. You can consider using a tool like forever to spin up a daemon and kill it after the load test has completed. - (Using concurrently instead with --quiet option. TODO: It doesn't properly exit. Need to manually exit for now)
      • Test all endpoints under at least 100 rps for 30s and ensure that p99 is under 50ms - (Average is p99:30ms. Check out .artillery/summary.json.html for summary report)