Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typescript-library-template-example

Package Overview
Dependencies
Maintainers
0
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typescript-library-template-example

Template for new typescript libraries

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

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.
    • 🙊 Check typos to ensure we don't have grammar mistakes.
  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
  9. 🐦‍🔥 Use of ESModules instead of CommonJS, which is the standard in JavaScript, while allowing clients to use the library regardless of whether they use ESModules or CommonJS.

🤩 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

Keywords

FAQs

Package last updated on 03 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc