typescript-express-starter

typescript-express-starter

TypeScript Express 项目脚手架,快速构建高效 RESTful API

typescript-express-starter 是一个基于 TypeScript 的 Express RESTful API 脚手架。该项目集成了多种数据库 ORM、GraphQL 和 Docker 等工具,提供完整的开发环境和项目结构。开发者可通过简单命令快速创建项目并选择模板。项目还包含代码格式化和 API 文档生成等功能,适合构建现代化 Node.js 后端服务。

ExpressTypeScriptRESTful APINode.jsDockerGithub开源项目
<h1 align="center"> <br> <img src="https://github.com/ljlm0402/typescript-express-starter/raw/images/logo.jpg" alt="Project Logo" /> <br> <br> TypeScript Express Starter <br> </h1> <h4 align="center">🚀 Express RESTful API Boilerplate Using TypeScript</h4> <p align ="center"> <a href="https://nodei.co/npm/typescript-express-starter" target="_blank"> <img src="https://nodei.co/npm/typescript-express-starter.png" alt="npm Info" /> </a> </p> <p align="center"> <a href="http://npm.im/typescript-express-starter" target="_blank"> <img src="https://img.shields.io/npm/v/typescript-express-starter.svg" alt="npm Version" /> </a> <a href="http://npm.im/typescript-express-starter" target="_blank"> <img src="https://img.shields.io/github/v/release/ljlm0402/typescript-express-starter" alt="npm Release Version" /> </a> <a href="http://npm.im/typescript-express-starter" target="_blank"> <img src="https://img.shields.io/npm/dm/typescript-express-starter.svg" alt="npm Downloads" /> </a> <a href="http://npm.im/typescript-express-starter" target="_blank"> <img src="https://img.shields.io/npm/l/typescript-express-starter.svg" alt="npm Package License" /> </a> </p> <p align="center"> <a href="https://github.com/ljlm0402/typescript-express-starter/stargazers" target="_blank"> <img src="https://img.shields.io/github/stars/ljlm0402/typescript-express-starter" alt="github Stars" /> </a> <a href="https://github.com/ljlm0402/typescript-express-starter/network/members" target="_blank"> <img src="https://img.shields.io/github/forks/ljlm0402/typescript-express-starter" alt="github Forks" /> </a> <a href="https://github.com/ljlm0402/typescript-express-starter/stargazers" target="_blank"> <img src="https://img.shields.io/github/contributors/ljlm0402/typescript-express-starter" alt="github Contributors" /> </a> <a href="https://github.com/ljlm0402/typescript-express-starter/issues" target="_blank"> <img src="https://img.shields.io/github/issues/ljlm0402/typescript-express-starter" alt="github Issues" /> </a> </p> <br /> <br />

😎 Introducing The Project

Express consists of JavaScript, which makes it vulnerable to type definitions.

That's why we avoid supersets with starter packages that introduce TypeScript.

The package is configured to use TypeScript instead of JavaScript.

The project referred to express-generator-typescript

🤔 What is Express ?

Express is a fast, open and concise web framework and is a Node.js based project.

🚀 Quick Start

Install with the npm Global Package

$ npm install -g typescript-express-starter

Run npx to Install The Package

npx is a tool in the JavaScript package management module, npm.

This is a tool that allows you to run the npm package on a single run without installing the package.

If you do not enter a project name, it defaults to typescript-express-starter.

$ npx typescript-express-starter "project name"

Select a Templates

<img src="https://github.com/ljlm0402/typescript-express-starter/raw/images/cli.gif" alt="Example Cli" />

Start your typescript-express-starter app in development mode at http://localhost:3000/

Template Type

NameDescription
DefaultExpress Default
Routing ControllersCreate structured, declarative and beautifully organized class-based controllers with heavy decorators usage
SequelizeEasy to use multi SQL dialect ORM for Node.js
MongooseMongoDB Object Modeling(ODM) designed to work in an asynchronous environment
TypeORMAn ORM that can run in Node.js and Others
PrismaModern Database Access for TypeScript & Node.js
KnexSQL query builder for Postgres, MySQL, MariaDB, SQLite3 and Oracle
GraphQLquery language for APIs and a runtime for fulfilling those queries with your existing data
TypegooseDefine Mongoose models using TypeScript classes
Mikro ORMTypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL and SQLite databases
Node Postgresnode-postgres is a collection of node.js modules for interfacing with your PostgreSQL database

Template to be developed

NameDescription
Sequelize TypescriptDecorators and some other features for sequelize
TS SQLA SQL database implemented purely in TypeScript type annotations
inversify-express-utilsSome utilities for the development of Express application with InversifyJS
postgress typescript
graphql prisma

🛎 Available Commands for the Server

  • Run the Server in production mode : npm run start or Start typescript-express-starter in VS Code
  • Run the Server in development mode : npm run dev or Dev typescript-express-starter in VS Code
  • Run all unit-tests : npm test or Test typescript-express-starter in VS Code
  • Check for linting errors : npm run lint or Lint typescript-express-starter in VS Code
  • Fix for linting : npm run lint:fix or Lint:Fix typescript-express-starter in VS Code

💎 The Package Features

<p> <img src="https://img.shields.io/badge/-TypeScript-007ACC?style=for-the-badge&logo=TypeScript&logoColor=fff" />&nbsp;&nbsp; <img src="https://img.shields.io/badge/-Node.js-339933?style=for-the-badge&logo=Node.js&logoColor=fff" />&nbsp;&nbsp; <img src="https://img.shields.io/badge/-NPM-CB3837?style=for-the-badge&logo=NPM&logoColor=fff" />&nbsp;&nbsp; </p> <p> <img src="https://img.shields.io/badge/-Docker-2496ED?style=for-the-badge&logo=Docker&logoColor=fff" />&nbsp;&nbsp; <img src="https://img.shields.io/badge/-NGINX-269539?style=for-the-badge&logo=NGINX&logoColor=fff" /> <img src="https://img.shields.io/badge/-PM2-2B037A?style=for-the-badge&logo=PM2&logoColor=fff" />&nbsp;&nbsp; <img src="https://img.shields.io/badge/-Nodemon-76D04B?style=for-the-badge&logo=Nodemon&logoColor=fff" />&nbsp;&nbsp; <img src="https://img.shields.io/badge/-ESLint-4B32C3?style=for-the-badge&logo=ESLint&logoColor=fff" />&nbsp;&nbsp; <img src="https://img.shields.io/badge/-Prettier-F7B93E?style=for-the-badge&logo=Prettier&logoColor=000" />&nbsp;&nbsp; <img src="https://img.shields.io/badge/-Jest-C21325?style=for-the-badge&logo=Jest&logoColor=fff" />&nbsp;&nbsp; <img src="https://img.shields.io/badge/-Swagger-85EA2D?style=for-the-badge&logo=Swagger&logoColor=000" /> <img src="https://img.shields.io/badge/-SWC-FFFFFF?style=for-the-badge&logo=swc&logoColor=FBE1A6" /> </p> <p> <img src="https://img.shields.io/badge/-MySQL-4479A1?style=for-the-badge&logo=MySQL&logoColor=fff" />&nbsp;&nbsp; <img src="https://img.shields.io/badge/-MariaDB-003545?style=for-the-badge&logo=MariaDB&logoColor=fff" />&nbsp;&nbsp; <img src="https://img.shields.io/badge/-PostgreSQL-336791?style=for-the-badge&logo=PostgreSQL&logoColor=fff" />&nbsp;&nbsp; <img src="https://img.shields.io/badge/-MongoDB-47A248?style=for-the-badge&logo=MongoDB&logoColor=fff" /> </p>

🐳 Docker :: Container Platform

Docker is a platform for developers and sysadmins to build, run, and share applications with containers.

Docker Install.

  • starts the containers in the background and leaves them running : docker-compose up -d
  • Stops containers and removes containers, networks, volumes, and images : docker-compose down

Modify docker-compose.yml and Dockerfile file to your source code.

♻️ NGINX :: Web Server

NGINX is a web server that can also be used as a reverse proxy, load balancer, mail proxy and HTTP cache.

Proxying is typically used to distribute the load among several servers, seamlessly show content from different websites, or pass requests for processing to application servers over protocols other than HTTP.

When NGINX proxies a request, it sends the request to a specified proxied server, fetches the response, and sends it back to the client.

Modify nginx.conf file to your source code.

✨ ESLint, Prettier :: Code Formatter

Prettier is an opinionated code formatter.

ESLint, Find and fix problems in your JavaScript code

It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.

  1. Install VSCode Extension Prettier, ESLint

  2. CMD + Shift + P (Mac Os) or Ctrl + Shift + P (Windows)

  3. Format Selection With

  4. Configure Default Formatter...

  5. Prettier - Code formatter

<img src="https://user-images.githubusercontent.com/42952358/126604937-4ef50b61-b7e4-4635-b3c9-3c94dd6b06fa.png" alt="Formatter Setting" />

Palantir, the backers behind TSLint announced in 2019 that they would be deprecating TSLint in favor of supporting typescript-eslint in order to benefit the community. So, migration from TSLint to ESLint.

📗 Swagger :: API Document

Swagger is Simplify API development for users, teams, and enterprises with the Swagger open source and professional toolset.

Easily used by Swagger to design and document APIs at scale.

Start your app in development mode at http://localhost:3000/api-docs

Modify swagger.yaml file to your source code.

🌐 REST Client :: HTTP Client Tools

REST Client allows you to send HTTP request and view the response in Visual Studio Code directly.

VSCode Extension REST Client Install.

Modify *.http file in src/http folder to your source code.

🔮 PM2 :: Advanced, Production process manager for Node.js

PM2 is a daemon process manager that will help you manage and keep your application online 24/7.

  • production mode :: npm run deploy:prod or pm2 start ecosystem.config.js --only prod
  • development mode :: npm run deploy:dev or pm2 start ecosystem.config.js --only dev

Modify ecosystem.config.js file to your source code.

🏎 SWC :: a super-fast JavaScript / TypeScript compiler

SWC is an extensible Rust-based platform for the next generation of fast developer tools.

SWC is 20x faster than Babel on a single thread and 70x faster on four cores.

  • tsc build :: npm run build
  • swc build :: npm run build:swc

Modify .swcrc file to your source code.

💄 Makefile :: This is a setting file of the make program used to make the compilation that occurs repeatedly on Linux

Makefiles are used to help decide which parts of a large program need to be recompiled.

  • help :: make help

Modify Makefile file to your source code.

🗂 Code Structure (default)

├──📂 .vscode │ ├── launch.json │ └── settings.json ├──📂 src │ ├──📂 config │ │ └── index.ts │ │ │ ├──📂 controllers │ │ ├── auth.controller.ts │ │ └── users.controller.ts │ │ │ ├──📂 dtos │ │ └── users.dto.ts │ │ │ ├──📂 exceptions │ │ └── httpException.ts │ │ │ ├──📂 http │ │ ├── auth.http │ │ └── users.http │ │ │ ├──📂 interfaces │ │ ├── auth.interface.ts │ │ ├── routes.interface.ts │ │ └── users.interface.ts │ │ │ ├──📂 middlewares │ │ ├── auth.middleware.ts │ │ ├── error.middleware.ts │ │ └── validation.middleware.ts │ │ │ ├──📂 models │ │ └── users.model.ts │ │ │ ├──📂 routes │ │ ├── auth.route.ts │ │ └── users.route.ts │ │ │ ├──📂 services │ │ ├── auth.service.ts │ │ └── users.service.ts │ │ │ ├──📂 test │ │ ├── auth.test.ts │ │ └── users.test.ts │ │ │ ├──📂 utils │ │ ├── logger.ts │ │ └── vaildateEnv.ts │ │ │ ├── app.ts │ └── server.ts ├── .dockerignore ├── .editorconfig ├── .env.development.local ├── .env.production.local ├── .env.test.local ├── .eslintignore ├── .eslintrc ├── .gitignore ├── .huskyrc ├── .lintstagedrc.json ├── .prettierrc ├── .swcrc ├── docker-compose.yml ├── Dockerfile.dev ├── Dockerfile.prod ├── ecosystem.config.js ├── jest.config.js ├── Makefile ├── nginx.conf ├── nodemon.json ├── package-lock.json ├── package.json ├── swagger.yaml └── tsconfig.json

⭐️ Stargazers

Stargazers repo roster for @ljlm0402/typescript-express-starter

🍴 Forkers

[![Forkers repo roster for

编辑推荐精选

Vora

Vora

免费创建高清无水印Sora视频

Vora是一个免费创建高清无水印Sora视频的AI工具

Refly.AI

Refly.AI

最适合小白的AI自动化工作流平台

无需编码,轻松生成可复用、可变现的AI自动化工作流

酷表ChatExcel

酷表ChatExcel

大模型驱动的Excel数据处理工具

基于大模型交互的表格处理系统,允许用户通过对话方式完成数据整理和可视化分析。系统采用机器学习算法解析用户指令,自动执行排序、公式计算和数据透视等操作,支持多种文件格式导入导出。数据处理响应速度保持在0.8秒以内,支持超过100万行数据的即时分析。

AI工具使用教程AI营销产品酷表ChatExcelAI智能客服
TRAE编程

TRAE编程

AI辅助编程,代码自动修复

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

热门AI工具生产力协作转型TraeAI IDE
AIWritePaper论文写作

AIWritePaper论文写作

AI论文写作指导平台

AIWritePaper论文写作是一站式AI论文写作辅助工具,简化了选题、文献检索至论文撰写的整个过程。通过简单设定,平台可快速生成高质量论文大纲和全文,配合图表、参考文献等一应俱全,同时提供开题报告和答辩PPT等增值服务,保障数据安全,有效提升写作效率和论文质量。

数据安全AI助手热门AI工具AI辅助写作AI论文工具论文写作智能生成大纲
博思AIPPT

博思AIPPT

AI一键生成PPT,就用博思AIPPT!

博思AIPPT,新一代的AI生成PPT平台,支持智能生成PPT、AI美化PPT、文本&链接生成PPT、导入Word/PDF/Markdown文档生成PPT等,内置海量精美PPT模板,涵盖商务、教育、科技等不同风格,同时针对每个页面提供多种版式,一键自适应切换,完美适配各种办公场景。

热门AI工具AI办公办公工具智能排版AI生成PPT博思AIPPT海量精品模板AI创作
潮际好麦

潮际好麦

AI赋能电商视觉革命,一站式智能商拍平台

潮际好麦深耕服装行业,是国内AI试衣效果最好的软件。使用先进AIGC能力为电商卖家批量提供优质的、低成本的商拍图。合作品牌有Shein、Lazada、安踏、百丽等65个国内外头部品牌,以及国内10万+淘宝、天猫、京东等主流平台的品牌商家,为卖家节省将近85%的出图成本,提升约3倍出图效率,让品牌能够快速上架。

iTerms

iTerms

企业专属的AI法律顾问

iTerms是法大大集团旗下法律子品牌,基于最先进的大语言模型(LLM)、专业的法律知识库和强大的智能体架构,帮助企业扫清合规障碍,筑牢风控防线,成为您企业专属的AI法律顾问。

SimilarWeb流量提升

SimilarWeb流量提升

稳定高效的流量提升解决方案,助力品牌曝光

稳定高效的流量提升解决方案,助力品牌曝光

Sora2视频免费生成

Sora2视频免费生成

最新版Sora2模型免费使用,一键生成无水印视频

最新版Sora2模型免费使用,一键生成无水印视频

下拉加载更多