Skip to content

Commit 5349079

Browse files
committed
Initial commit
0 parents  commit 5349079

File tree

8 files changed

+2504
-0
lines changed

8 files changed

+2504
-0
lines changed

.gitignore

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Intellij based ides
2+
.idea/
3+
4+
# Logs
5+
logs
6+
*.log
7+
npm-debug.log*
8+
yarn-debug.log*
9+
yarn-error.log*
10+
11+
# Runtime data
12+
pids
13+
*.pid
14+
*.seed
15+
*.pid.lock
16+
17+
# Directory for instrumented libs generated by jscoverage/JSCover
18+
lib-cov
19+
20+
# Coverage directory used by tools like istanbul
21+
coverage
22+
23+
# nyc test coverage
24+
.nyc_output
25+
26+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
27+
.grunt
28+
29+
# Bower dependency directory (https://bower.io/)
30+
bower_components
31+
32+
# node-waf configuration
33+
.lock-wscript
34+
35+
# Compiled binary addons (https://nodejs.org/api/addons.html)
36+
build/Release
37+
38+
# Dependency directories
39+
node_modules/
40+
jspm_packages/
41+
42+
# TypeScript v1 declaration files
43+
typings/
44+
45+
# Optional npm cache directory
46+
.npm
47+
48+
# Optional eslint cache
49+
.eslintcache
50+
51+
# Optional REPL history
52+
.node_repl_history
53+
54+
# Output of 'npm pack'
55+
*.tgz
56+
57+
# Yarn Integrity file
58+
.yarn-integrity
59+
60+
# dotenv environment variables file
61+
.env
62+
63+
# next.js build output
64+
.next

Readme.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Xendit Coding Exercise
2+
3+
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.
4+
5+
## Setup
6+
7+
1. Create a new repository in your own github profile named `backend-coding-test` and commit the contents of this folder
8+
2. Ensure `node (>8.6 and <= 10)` and `npm` are installed
9+
3. Run `npm install`
10+
4. Run `npm test`
11+
5. Run `npm start`
12+
6. Hit the server to test health `curl localhost:8010/health` and expect a `200` response
13+
14+
## Tasks
15+
16+
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
17+
18+
1. [Documentation](#documentation)
19+
2. [Implement Tooling](#implement-tooling)
20+
3. [Implement Pagination](#implement-pagination)
21+
4. [Refactoring](#refactoring)
22+
5. [Security](#security)
23+
6. [Load Testing](#load-testing)
24+
25+
### Documentation
26+
27+
Please deliver documentation of the server that clearly explains the goals of this project and clarifies the API response that is expected.
28+
29+
#### Success Criteria
30+
31+
1. A pull request against `master` of your fork with a clear description of the change and purpose and merge it
32+
3. **[BONUS]** Create an easy way to deploy and view the documentation in a web format and include instructions to do so
33+
34+
### Implement Tooling
35+
36+
Please implement the following tooling:
37+
38+
1. `eslint` - for linting
39+
2. `nyc` - for code coverage
40+
3. `pre-push` - for git pre push hook running tests
41+
4. `winston` - for logging
42+
43+
#### Success Criteria
44+
45+
1. Create a pull request against `master` of your fork with the new tooling and merge it
46+
1. `eslint` should have an opinionated format
47+
2. `nyc` should aim for test coverage of `80%` across lines, statements, and branches
48+
3. `pre-push` should run the tests before allowing pushing using `git`
49+
4. `winston` should be used to replace console logs and all errors should be logged as well. Logs should go to disk.
50+
2. Ensure that tooling is connected to `npm test`
51+
3. Create a separate pull request against `master` of your fork with the linter fixes and merge it
52+
4. Create a separate pull request against `master` of your fork to increase code coverage to acceptable thresholds and merge it
53+
5. **[BONUS]** Add integration to CI such as Travis or Circle
54+
6. **[BONUS]** Add Typescript support
55+
56+
### Implement Pagination
57+
58+
Please implement pagination to retrieve pages of the resource `rides`.
59+
60+
1. Create a pull request against `master` with your changes to the `GET /rides` endpoint to support pagination including:
61+
1. Code changes
62+
2. Tests
63+
3. Documentation
64+
2. Merge the pull request
65+
66+
### Refactoring
67+
68+
Please implement the following refactors of the code:
69+
70+
1. Convert callback style code to use `async/await`
71+
2. Reduce complexity at top level control flow logic and move logic down and test independently
72+
3. **[BONUS]** Split between functional and imperative function and test independently
73+
74+
#### Success Criteria
75+
76+
1. A pull request against `master` of your fork for each of the refactors above with:
77+
1. Code changes
78+
2. Tests
79+
80+
### Security
81+
82+
Please implement the following security controls for your system:
83+
84+
1. Ensure the system is not vulnerable to [SQL injection](https://www.owasp.org/index.php/SQL_Injection)
85+
2. **[BONUS]** Implement an additional security improvement of your choice
86+
87+
#### Success Criteria
88+
89+
1. A pull request against `master` of your fork with:
90+
1. Changes to the code
91+
2. Tests ensuring the vulnerability is addressed
92+
93+
### Load Testing
94+
95+
Please implement load testing to ensure your service can handle a high amount of traffic
96+
97+
#### Success Criteria
98+
99+
1. Implement load testing using `artillery`
100+
1. Create a PR against `master` of your fork including artillery
101+
2. 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.
102+
3. Test all endpoints under at least `100 rps` for `30s` and ensure that `p99` is under `50ms`

index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
3+
const express = require('express');
4+
const app = express();
5+
const port = 8010;
6+
7+
const bodyParser = require('body-parser');
8+
const jsonParser = bodyParser.json();
9+
10+
const sqlite3 = require('sqlite3').verbose();
11+
const db = new sqlite3.Database(':memory:');
12+
13+
const buildSchemas = require('./src/schemas');
14+
15+
db.serialize(() => {
16+
buildSchemas(db);
17+
18+
const app = require('./src/app')(db);
19+
20+
app.listen(port, () => console.log(`App started and listening on port ${port}`));
21+
});

0 commit comments

Comments
 (0)