typescript-library-template-example
TypeScript icon, indicating that this package has built-in type declarations

1.5.20 • Public • Published

Express Logo

⭐ Typescript Library Template ⭐

Template for new libraries based on Typescript with the Best Practices and Ready for Production

nodejs supported node node typescript swc npm

👀 Motivation

Starting a new library for NodeJS can be a bit frustrating, there are a lot of things to consider if we want to have a really good starting point where later we can iterate.

The main objective of this template is to provide a good base configuration for our NodeJS libraries that we can start using and move to production as soon as possible.

🌟 What is including this template?

  1. 🐳 Fully dockerized project ready to develop in the library.
  2. 👷 Use SWC for running the tests of the library.
  3. 🐶 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 library does not have type errors with Typescript.
  4. 🧪 Testing with Vitest
  5. 📌 Custom path aliases, where you can define your own paths (you will be able to use imports like @src instead of ../../../src).
  6. 🚀 CI/CD using GitHub Actions, helping ensure a good quality of our code and providing useful insights about dependencies, security vulnerabilities and others.
  7. 🤖 ChatOps approach to help creating release candidates, getting help and more things. Here is an example.
  8. 🥷 Fully automatized release process. You just need to merge into main branch using conventional commits and that's all. Automatically we will:
    • 📘 Update library version
    • 📍 Create the tags associated to your change
    • 📝 Update the changelog
    • 📦 Create a release
    • ☁️ Publish the new version to NPM

🤩 Other templates

Are you thinking in start some new service in the NodeJS ecosystem? If you like this template there are others base on this you can check:

🧑‍💻 Developing

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

docker-compose up -d

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": "/app"
    }
  ]
}

When you want to stop developing, you can stop the project running:

docker-compose down

⚙️ Building

npm run build

✅ Testing

If you want to run the tests of the project, you can execute the following command:

npm run test

💅 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

Package Sidebar

Install

npm i typescript-library-template-example

Weekly Downloads

6

Version

1.5.20

License

MIT

Unpacked Size

11.2 kB

Total Files

12

Last publish

Collaborators

  • alberthernandez