In this project, we build a simple Express.js server that provides a set of API endpoints for testing purposes. The server is designed to be used with Docker and can be easily deployed to a production environment via CircleCI.
List any prerequisites here. For example:
- Node.js (v20 or later)
- Docker
- pnpm
- CircleCI
For test, first clone the repository:
git clone git@github.com:Ivanshamir/infra-test.gitAnd then install dependencies:
pnpm install Update necessary and push to the remote repository. This will trigger the CI/CD pipeline in CircleCI. And will build and push the Docker image to Docker Hub.
To run locally:
docker run -d -p 8000:5000 ivanshamir/infra-test:latest infraNow you can access the API endpoints at http://localhost:8000/test
GET /test: Returns the current timestamp.GET /dateonly: Returns the current date in YYYY-MM-DD format.POST /dateonly: Accepts a timestamp and returns the formatted date and time.GET /from-env: Returns the value of the APP_ENV environment variable.
To pull the latest image from Docker Hub:
docker pull ivanshamir/infra-test:latestThen run the container:
docker run -d -p 8000:5000 ivanshamir/infra-test:latestRun tests using:
pnpm testFor coverage report:
pnpm test:coveragetest