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 🙏

© 2026 – Pkg Stats / Ryan Hefner

create-template-expressjs

v1.1.2

Published

Gerar um projeto Express.js com TypeScript, testes e validação de ambiente.

Readme

ExpressJS + TypeScript Boilerplate

Este é um boilerplate para um projeto ExpressJS com TypeScript, com validação de variáveis de ambiente usando Joi, testes automatizados utilizando Vitest, e integração de tipos com o TypeScript. Este template é ideal para quem deseja começar rapidamente a desenvolver APIs com um ambiente já configurado e otimizado.

Funcionalidades

  • ExpressJS: Framework web para Node.js.
  • TypeScript: Linguagem que adiciona tipagem estática ao JavaScript.
  • Joi: Biblioteca para validação de variáveis de ambiente.
  • Vitest: Ferramenta de testes automatizados.
  • Estrutura de pastas organizada para desenvolvimento escalável.

Pré-requisitos

  • Node.js (v16 ou superior)
  • npm ou yarn

Instalação

  1. Clone este repositório para sua máquina local:

    git clone https://github.com/DiegoLimaCoder/Boilerplate_ExpressJS.git
       
    cd express-typescript-boilerplate
  2. Instale as dependências do projeto:

    npm install
    # ou
    yarn install
  3. Crie um arquivo .env na raiz do projeto e configure as variáveis de ambiente necessárias:

    PORT=3000
    NODE_ENV="development"

Estrutura do Projeto

A estrutura de diretórios do projeto é a seguinte:

express-typescript-boilerplate/
├── src/
│   ├── app.ts        # Configuração principal do Express
│   ├── env.ts        # Validação de variáveis de ambiente usando Joi
│   └── server.ts     # Inicialização do servidor
├── test/             # Arquivos de teste
│   ├── test.e2e-spec.ts         # Testes de end to end
│   ├── test.integration.spec.ts # Testes de integração
│   └── test.spec.ts             # Testes unitários simples
├── vitest.config.mts  # Configuração do Vitest
├── tsconfig.json      # Configuração do TypeScript
├── package.json       # Dependências e scripts
└── .env               # Variáveis de ambiente

Scripts

Aqui estão os scripts principais definidos no package.json:

  • dev: Inicia o servidor em modo de desenvolvimento.

    npm run dev
  • build: Compila o código TypeScript para JavaScript.

    npm run build
  • test: Executa os testes utilizando Vitest.

    npm run test
  • test:watch: Executa os testes automaticamente quando há alterações no código.

    npm run test:watch
  • test:cov: Executa os testes e gera um relatório de cobertura.

    npm run test:cov

Testes

O boilerplate vem com exemplos de testes utilizando Vitest e Supertest.

Testes de Integração (E2E)

Exemplo de teste de integração para o endpoint principal /:

import request from "supertest";
import { app } from "../src/app";

describe("Basic Endpoint Test", () => {
  it("should respond with status 200 for the root route", async () => {
    const res = await request(app).get("/"); // Requisição GET à rota principal
    expect(res.status).toBe(200);
  });
});

Testes de Unidade

Um exemplo de teste de unidade simples:

describe('Example Test Suite', () => {
  it('should pass', () => {
    expect(1 + 1).toBe(2);
  });
});

Variáveis de Ambiente

O projeto usa o pacote dotenv para carregar as variáveis de ambiente a partir de um arquivo .env. O arquivo .env deve conter pelo menos as seguintes variáveis:

PORT=3000
NODE_ENV="development"