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

create-tsc-server

v2.0.4

Published

A package for creating TypeScript Node.js Express server boilerplate with modular architecture and essential features.

Downloads

119

Readme

Create TypeScript Boilerplate Server

npm version npm downloads license

create-tsc-server is a command-line tool that helps you quickly create a boilerplate TypeScript server by cloning a predefined GitHub repository.

Features

  • 🚀 Quick Setup: Instantly clone a TypeScript server template and get started.
  • 💡 Easy to Use: Simple command to create a new server project.
  • 📦 Production and Development Scripts: Scripts to start the server in production and development modes.
  • 🛠️ Build Script: Compile TypeScript code to JavaScript.
  • 🧹 Linting and Formatting: ESLint and Prettier configurations for code quality.
  • 🔐 Security: Built-in support for JWT authentication and bcrypt for password hashing.
  • 🌐 Middleware: Includes cookie-parser, CORS, and dotenv for environment variables.
  • 📦 Database: Mongoose integration for MongoDB.
  • 📂 builtin module create:Automatically create import module files.

Update

Creating a New Module

To create a new module within your existing TypeScript server project, use the following command:

npx tsc-module <module-name>

This command will:

  1. Create a new directory named <module-name> inside the src/modules directory.

  2. Generate the following files inside the new directory:

    • <module-name>.constant.ts

    • <module-name>.controller.ts

    • <module-name>.interface.ts

    • <module-name>.model.ts

    • <module-name>.route.ts

    • <module-name>.service.ts

    • <module-name>.utils.ts

    • <module-name>.validation.ts

      Each file will contain a basic template to get you started quickly.

Example

npx tsc-module user

This will create the following structure inside src/modules:

  • User/
    • user.constant.ts
    • user.controller.ts
    • user.interface.ts
    • user.model.ts
    • user.route.ts
    • user.service.ts
    • user.utils.ts
    • user.validation.ts

Installation

You can install create-tsc-server globally using npm:

npm install -g create-tsc-server

Or use it directly with npx (no installation required):

npx create-tsc-server <app-name>

Usage

To create a new TypeScript server project, run:

npx create-tsc-server my-app

Replace my-app with your desired project name.

This will:

  1. Clone the boilerplate repository.
  2. Create a new directory named awesome-server.
  3. Remove the .git directory from the cloned repository.
  4. Set up your new TypeScript server project.

Boilerplate Repository

The tool clones the repository from GitHub.

Project Structure

The generated project includes:

📦 src
├─ app
│  ├─ builder
│  ├─ config
│  ├─ DB
│  ├─ errors
│  │  ├─ AppError.ts
│  │  ├─ handleCastError.ts
│  │  ├─ handleDuplicateError.ts
│  │  ├─ handleValidationError.ts
│  │  └─ handleZodError.ts
│  ├─ helpers
│  ├─ interface
│  │  ├─ error.ts
│  │  └─ index.d.ts
│  ├─ middlewares
│  │  ├─ authGaurd.ts
│  │  ├─ globalErrorHandler.ts
│  │  ├─ notFoundAPIHandler.ts
│  │  └─ validateRequest.ts
│  ├─ routes
modules
│  │  └─ ExampleMoudles
│  │     ├─ user.constant.ts
│  │     ├─ user.controller.ts
│  │     ├─ user.interface.ts
│  │     ├─ user.model.ts
│  │     ├─ user.route.ts
│  │     ├─ user.service.ts
│  │     ├─ user.utils.ts
│  │     └─ user.validation.ts
│  ├─ shared
│  └─ utils
│     ├─ catchAsync.ts
│     └─ sendResponse.ts
├─ server.t
├─ app.ts
├─ tsconfig.json
├─ .env.example
├─ .prettierrc.json
├─ eslint.config.mjs
└─ yarn.lock

©generated by Project Tree Generator

Scripts

The package.json includes several useful scripts:

  1. Start in Production: yarn start:prod
    • Runs the server using the compiled JavaScript files.
  2. Start in Development: yarn start:dev
    • Runs the server using ts-node-dev with automatic restarts and TypeScript transpilation.
  3. Build: yarn build
    • Compiles TypeScript code to JavaScript.
  4. Lint: yarn lint
    • Runs ESLint on the src directory.
  5. Lint Fix: yarn lint:fix
    • Automatically fixes ESLint issues in the src directory.
  6. Prettier: yarn prettier
    • Formats the code using Prettier.
  7. Prettier Fix: yarn prettier:fix
    • Automatically formats the code in the src directory.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any bugs, improvements, or features you'd like to see.

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Make your changes.
  4. Commit your changes (git commit -am 'Add new feature').
  5. Push to the branch (git push origin feature-branch).
  6. Open a Pull Request.

Dependencies

Production

  • @typescript-eslint/eslint-plugin
  • @typescript-eslint/parser
  • bcrypt
  • cookie-parser
  • cors
  • dotenv
  • eslint
  • express
  • http-status
  • jsonwebtoken
  • mongoose
  • zod

Development

  • @eslint/js
  • @types/bcrypt
  • @types/cookie-parser
  • @types/cors
  • @types/express
  • @types/jsonwebtoken
  • @types/node
  • eslint-config-prettier
  • globals
  • prettier
  • ts-node
  • ts-node-dev
  • typescript
  • typescript-eslint

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

For any questions or feedback, feel free to reach out via GitHub Issues.

Made with ❤️ by MD. Monir Hoshen, GitHub Profile

tsc-server-npm