- Introduction
- Your Tasks
- Submitting Your Project
- Setup Instructions
- API Endpoints
- Appendix / Additional Information
This project is a backend service designed to understand how you reason around building an API. This service is built using TypeScript and Node.js, and it includes a mock service to simulate an external API.
Tip
This assignment should take you no more than one or two hours. (We don't want to take up too much of your time!) If you find yourself spending more time than that, feel free to stub out parts you don't have time to complete, and we can discuss them during the interview.
The goal of this project is to help provide context around a problem space of load balancing requests for an API that you are designing. We'll take the solution that you provide and discuss it during our interview.
A few things to keep in mind:
- This project should run standalone, so you don't need to worry about persistence. Please do not add dependencies that require additional configuration!
- We're looking for a solution that is simple, clean, and well-structured.
- We're not looking for a production-ready solution, we're looking for a solution that is well thought out and easy to understand.
- We'll take the solution that you provide and use that as the foundation for our interview.
Thank you for taking the time to complete this assignment. We're excited to see what you come up with!
Please clone this repository to get started.
When your project is ready for review, please export your project into a zip file (excluding the node_modules folder). Use Google Drive, Dropbox, OneDrive, or similar file upload service to host your project, then share a link so we can download this file.
- Implement user creation & fetching logic for the
POST /api/users
andGET /api/users
endpoints.
The Submit endpoint is not protected by authentication. Please add authentication using your choice of method.
- Add authentication to the
POST /api/submit
endpoint. You can use theaccessToken
field from theUser
model.
We want to limit the number of requests a user can create to our API in a single day and in bursts. Please implement the following rate limits on a per-account basis:
- Add a rate limit of 1 request per second to the
POST /api/submit
endpoint. - Add a rate limit of 100 requests per day to the
POST /api/submit
endpoint.
We want to keep track of how many quota points a user has used, and when they have used them. Please create a solution around the following:
- Please propose a solution to track usage of the
POST /api/submit
endpoint.
-
Install Dependencies
pnpm i
-
Run the Development Server
pnpmi dev
This will start the main service on port
8080
and the mock service on port8888
.
- URL:
/api/users
- Method:
GET
- Description: Returns a list of users.
- URL:
/api/users
- Method:
POST
- Description: Creates a new user.
- URL:
/api/recipients
- Method:
GET
- Description: Returns a list of recipients.
- URL:
/api/submit
- Method:
POST
- Description: Submits a request to process a user.
The mock service is designed to simulate an external API. It includes the following endpoints:
- URL:
/users
- Method:
GET
- Description: Returns a list of users.
- URL:
/process
- Method:
POST
- Description: Processes a user and returns a success message with the user id and processed value.
For more details, refer to the Mock Service README.
The project uses nodemon
for development. The configuration can be found in nodemon.json
.
The initial configuration logic is implemented in the initialConfiguration
function in src/utils.ts
. This function initializes the recipients and users data.
The project uses TypeScript interfaces to define the data structures. The interfaces can be found in src/types.ts
.
Mock data generation is implemented in src/mocks/mocker.ts
. This file includes functions to create fake recipients and users.
The project dependencies are listed in package.json
. Key dependencies include:
express
@faker-js/faker
express-rate-limit
ts-node
typescript