This is a Node.js application built with Express and TypeScript.
- Prerequisites
- Installation
- Running the Application
- Running Tests
- Linting
- Docker
- Healthcheck Endpoint
- Node.js
- npm
Clone the repository and install the dependencies:
git clone https://github.com/TheDigitalNinja/Sample-TS-App.git
npm install
To run the application in development mode, use:
npm run dev
This will start the application with nodemon, which will automatically restart the server whenever you make changes to the source code.
To build the application for production, use:
npm run build
This will compile the TypeScript code into JavaScript.
To start the application in production mode, use:
npm start
This will start the compiled JavaScript code.
To run the tests, use:
npm test
This will run the tests with Jest.
To lint the code, use:
npm run lint
This will lint the code with ESLint.
Our application includes a healthcheck endpoint (/health
). This endpoint is used to check the health of our application. It's useful in a production environment to ensure that the application is running correctly and to take action if it's not.
Here's how you can use the healthcheck endpoint:
curl http://localhost:3000/health
This application includes a Dockerfile that you can use to build a Docker image of the application. Here's how you can do it:
docker build -t sample-ts-app .
This will build a Docker image of the application and tag it as sample-ts-app
.
To run the application in a Docker container, use:
docker run -p 3000:3000 sample-ts-app
This will start a Docker container from the my-application image and map port 3000 in the container to port 3000 on your machine.
You can then access the application at http://localhost:3000.