This project is a REST API developed with Node.js, TypeScript, and Hapi.js, designed to manage a list of items. It was developed as part of a coding challenge for El Dorado.
This project was developed as part of a coding challenge. You can find the original challenge requirements in CHALLENGE.md.
- Node.js
- TypeScript
- Hapi.js (Web Framework)
- TypeORM (ORM)
- PostgreSQL (Database)
- Jest (Testing)
- Docker
- Node.js (v20 or higher)
- npm (v9 or higher)
- Docker and Docker Compose
- VS Code with Remote Containers extension (optional)
- Clone the repository:
git clone https://github.com/Guiw5/coding-interview-backend-level-3
cd coding-interview-backend-level-3- Install dependencies:
npm install- Set up environment variables:
cp .env.example .env
cp .env.example .devcontainer/.envThe project includes a DevContainer configuration that provides a consistent development environment with:
- Node.js 20
- PostgreSQL for development db
- PostgreSQL for testing db
- All necessary tools pre-installed
To use the DevContainer:
- Open the project in VS Code
- Press F1 and select "Dev Containers: Rebuild and Reopen in Container"
- Wait for the container to build and start
npm run start: Starts the server in development mode with hot-reloadnpm run test: Runs end-to-end (e2e) testsnpm run test:unit: Runs unit testsnpm run build: Compiles the TypeScript project to JavaScript
ensure you have added 127.0.0.1 postgres in /etc/hosts file
echo "127.0.0.1 postgres" | sudo tee -a /etc/hostsnpm run start:local: Starts the server in development mode with hot-reloadnpm run test:local: Runs end-to-end (e2e) testsnpm run test:unit: Runs unit testsnpm run build: Compiles the TypeScript project to JavaScript
.devcontainer/
├── .env # Environment variables for development (example copy)
|── devcontainer.json # DevContainer context configuration
|── docker-compose.yml # DevContainer services setup
└── Dockerfile # DevContainer context builder
e2e/
├── index.test.ts # End-to-end tests
|── jest.config.js # jest configuration
|── jest.setup.ts # e2e db environment variables
└── setup.ts # e2e db initialization
src/
├── __tests__/ # Unit tests
├── api/ # Routes and API configuration
├── config/ # Configurations (database, etc.)
├── controllers/ # Application controllers
├── entities/ # TypeORM entities/models
├── migrations/ # Database migrations
├── index.ts # Application entry point
└── server.ts # Server configuration
.env.example # Environment variables
Dockerfile # Builder for production deployment
The project includes two types of tests:
Unit tests are located in src/__tests__/ and can be run with:
npm run test:unitEnd-to-end tests are located in e2e/ and can be run with:
In Devcontainer
npm testor Local env
npm test:localThe API documentation is available through Swagger UI when the server is running:
- Development: http://localhost:3000/documentation
- Production: https://eldoradochallengue.onrender.com/documentation
⚠️ Important Note: The production environment is hosted on Render.com and has a cold start behavior. The service may take up to 1 minute to wake up if there has been no recent traffic. The documentation will be available once the service is fully awake.
🔍 Status Check: You can verify the service status at: https://eldoradochallengue.onrender.com/ping
To compile the project:
npm run buildThe compiled code will be generated in the dist/ folder.
This project is licensed under the ISC License.