create-tsc-server
is a command-line tool that helps you quickly create a boilerplate TypeScript server by cloning a predefined GitHub repository.
- 🚀 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.
To create a new module within your existing TypeScript server project, use the following command:
npx tsc-module <module-name>
This command will:
-
Create a new directory named
<module-name>
inside thesrc/modules
directory. -
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.
-
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
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>
To create a new TypeScript server project, run:
npx create-tsc-server my-app
Replace my-app with your desired project name.
- Clone the boilerplate repository.
- Create a new directory named awesome-server.
- Remove the .git directory from the cloned repository.
- Set up your new TypeScript server project.
The tool clones the repository from GitHub.
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
The package.json includes several useful scripts:
-
Start in Production:
yarn start:prod
- Runs the server using the compiled JavaScript files.
-
Start in Development:
yarn start:dev
- Runs the server using ts-node-dev with automatic restarts and TypeScript transpilation.
-
Build:
yarn build
- Compiles TypeScript code to JavaScript.
-
Lint:
yarn lint
- Runs ESLint on the src directory.
-
Lint Fix:
yarn lint:fix
- Automatically fixes ESLint issues in the src directory.
-
Prettier:
yarn prettier
- Formats the code using Prettier.
-
Prettier Fix:
yarn prettier:fix
- Automatically formats the code in the src directory.
Contributions are welcome! Please open an issue or submit a pull request for any bugs, improvements, or features you'd like to see.
- Fork the repository.
- Create a new branch (git checkout -b feature-branch).
- Make your changes.
- Commit your changes (git commit -am 'Add new feature').
- Push to the branch (git push origin feature-branch).
- Open a Pull Request.
- @typescript-eslint/eslint-plugin
- @typescript-eslint/parser
- bcrypt
- cookie-parser
- cors
- dotenv
- eslint
- express
- http-status
- jsonwebtoken
- mongoose
- zod
- @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
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions or feedback, feel free to reach out via GitHub Issues.
Made with ❤️ by MD. Monir Hoshen, GitHub Profile