A TypeScript-based API for Nutrien back-end interview exercise.
- RESTful API for retrieving histogram data from CSV files
- API versioning with
/api/v1/
prefix for future-proof endpoints - Swagger/OpenAPI documentation
- Unit tests with Jest
- AWS Lambda deployment support via Serverless Framework and AWS CDK
- TypeScript for type safety
- Node.js (v14 or later)
- npm (v6 or later)
- AWS CLI (for deployment)
- AWS CDK (for deployment)
- AWS Credentials (for deployment)
Install Dependencies
npm install
Run dev server
Start the development server:
npm run dev
The API will be available at http://localhost:3000.
Swagger documentation is available at http://localhost:3000/api-docs when running locally. The Swagger UI shows both versioned API endpoints (recommended) and direct routes (for backward compatibility).
Two additional HTML viewers are included in the project:
swagger-viewer.html
: Loads the Swagger UI from the deployed APIswagger-viewer-alt.html
: Contains the Swagger JSON directly embedded in the HTML file
GET /api/v1/columns
- Get all available columns in the CSV dataGET /api/v1/{columnName}/histogram
- Get histogram data for a specific column
GET /{columnName}/histogram
- Get histogram data for a specific column (direct route without /api prefix)
npm test
npm run deploy
- Bootstrap your AWS environment (first time only):
npm run cdk:bootstrap
- Deploy the application:
npm run cdk:deploy