Skip to content

A NodeJS App showcasing a production setup with Express and Typescript.

Notifications You must be signed in to change notification settings

thepembeweb/express-ts-app

Repository files navigation

Express Typescript App

A NodeJS App showcasing a production setup with Express and Typescript.

NPM Version GitHub typescript npm swc

App features

  1. 🐳 Fully dockerized service ready for development and production environments with the best practices for docker, trying to provide a performance and small image just with the code we really need in your environments.
  2. 👷 Use SWC for compiling and running the tests of the service.
  3. ⚡️ Configure Express as HTTP framework.
  4. 🐶 Integration with husky to ensure we have good quality and conventions while we are developing like:
    • 💅 Running the linter over the files that have been changed
    • 💬 Use conventional commits to ensure our commits have a convention.
    • ✅ Run the tests automatically.
    • ⚙️ Check our project does not have type errors with Typescript.
  5. 🧪 Testing with Jest and supertest for unit and e2e tests.
  6. 🤜🤛 Combine unit and e2e test coverage. In the services we may have both type of tests, unit and e2e tests, and usually we would like to see what is the combined test coverage, so we can see the full picture.
  7. 📌 Custom path aliases, where you can define your own paths (you will be able to use imports like @core/logger instead of ../../../src/core/logger).
  8. 🚀 CI/CD using GitHub Actions, helping ensure a good quality of our code and providing useful insights about dependencies, security vulnerabilities and others.

Developing

First, we will need to create our .env file, we can create a copy from the example one:

cp .env.example .env

The project is fully dockerized 🐳, if we want to start the app in development mode, we just need to run:

docker-compose up -d node-app-dev

This development mode with work with hot-reload and exposing a debug port, the 9229, so later we can connect from our editor to it.

Now, you should be able to start debugging configuring using your IDE. For example, if you are using vscode, you can create a .vscode/launch.json file with the following config:

{
  "version": "0.1.0",
  "configurations": [
    {
      "type": "node",
      "request": "attach",
      "name": "Attach to docker",
      "restart": true,
      "port": 9229,
      "remoteRoot": "/project"
    }
  ]
}

Also, if you want to run the production mode, you can run:

docker-compose up -d node-app-production

This service is providing just a health endpoint which you can call to verify the service is working as expected:

curl --request GET \
  --url http:https://localhost:3000/health

If you want to stop developing, you can stop the service running:

docker-compose down

⚙️ Building

npm run build

Testing

The service provide different scripts for running the tests, to run all of them you can run:

npm run test

If you are interested just in the unit tests, you can run:

npm run test:unit

Or if you want e2e tests, you can execute:

npm run test:e2e

Linting

To run the linter you can execute:

npm run lint

And for trying to fix lint issues automatically, you can run:

npm run lint:fix

About

A NodeJS App showcasing a production setup with Express and Typescript.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages