npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

typescript-library-template-example

v1.15.0

Published

Template for new typescript libraries

Downloads

169

Readme

👀 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