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

编辑推荐精选

蛙蛙写作

蛙蛙写作

AI小说写作助手,一站式润色、改写、扩写

蛙蛙写作—国内先进的AI写作平台,涵盖小说、学术、社交媒体等多场景。提供续写、改写、润色等功能,助力创作者高效优化写作流程。界面简洁,功能全面,适合各类写作者提升内容品质和工作效率。

AI辅助写作AI工具蛙蛙写作AI写作工具学术助手办公助手营销助手AI助手
Trae

Trae

字节跳动发布的AI编程神器IDE

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

AI工具TraeAI IDE协作生产力转型热门
问小白

问小白

全能AI智能助手,随时解答生活与工作的多样问题

问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。

热门AI助手AI对话AI工具聊天机器人
Transly

Transly

实时语音翻译/同声传译工具

Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。

讯飞智文

讯飞智文

一键生成PPT和Word,让学习生活更轻松

讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。

AI办公办公工具AI工具讯飞智文AI在线生成PPTAI撰写助手多语种文档生成AI自动配图热门
讯飞星火

讯飞星火

深度推理能力全新升级,全面对标OpenAI o1

科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。

热门AI开发模型训练AI工具讯飞星火大模型智能问答内容创作多语种支持智慧生活
Spark-TTS

Spark-TTS

一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型

Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。

咔片PPT

咔片PPT

AI助力,做PPT更简单!

咔片是一款轻量化在线演示设计工具,借助 AI 技术,实现从内容生成到智能设计的一站式 PPT 制作服务。支持多种文档格式导入生成 PPT,提供海量模板、智能美化、素材替换等功能,适用于销售、教师、学生等各类人群,能高效制作出高品质 PPT,满足不同场景演示需求。

讯飞绘文

讯飞绘文

选题、配图、成文,一站式创作,让内容运营更高效

讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品牌传播,提升内容营销效果。

热门AI辅助写作AI工具讯飞绘文内容运营AI创作个性化文章多平台分发AI助手
材料星

材料星

专业的AI公文写作平台,公文写作神器

AI 材料星,专业的 AI 公文写作辅助平台,为体制内工作人员提供高效的公文写作解决方案。拥有海量公文文库、9 大核心 AI 功能,支持 30 + 文稿类型生成,助力快速完成领导讲话、工作总结、述职报告等材料,提升办公效率,是体制打工人的得力写作神器。

下拉加载更多