Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

📐 Ts.ED is a Node.js and TypeScript framework on top of Express to write your application with TypeScript (or ES6). It provides a lot of decorators and guideline to make your code more readable and less error-prone. ⭐️ Star to support our work!

License

NotificationsYou must be signed in to change notification settings

tsedio/tsed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ts.ED logo


Build & ReleasePR Welcomenpm versionsemantic-releasecode style: prettiergithubopencollective

Website  •  Getting started  •  Slack  •  Twitter

What it is

Ts.ED is a modern Node.js framework built with TypeScript. It offers a flexible structure with a fast learning curve, specifically designed to improve the developer experience. Ts.ED provides numerous decorators and guidelines to make your code more readable and less error-prone. It supports various platforms and tools, including Node.js/Bun.js, Express.js/Koa.js, CLI, and serverless architectures (e.g., AWS).

  • Multi-platform: Easily build your server-side application using Express.js, Koa.js, CLI, or serverless platforms (e.g., AWS). It supports both Node.js and Bun.js runtimes. Learn morehere.
  • Configuration: Stop wasting time on configuration—your application comes preconfigured for a fast start! Try ourCLI.
  • Decorators: Use a wide range of decorators to structure your code, define routes, and implement methods with ease. Learn morehere.
  • Class-based: Define classes asControllers,Models,Providers (DI),Pipes, and more, with JSON Schema and OpenAPI at the core of the framework.
  • Testing: Testing is not optional—it's essential! Ts.ED includes built-in features to make testing your code simple and efficient. Learn morehere.

Features

  • Use our CLI to create a new project:https://tsed.dev/introduction/getting-started.html#installation
  • Support TypeORM, Mongoose, GraphQL, Socket.io, Swagger-ui, Passport.js, etc...
  • Define class as Controller,
  • Define class as Service (IoC),
  • Define class as Middleware and MiddlewareError,
  • Define class as Json Mapper (POJ to Model and Model to POJ),
  • Define root path for an entire controller and versioning your Rest API,
  • Define as sub-route path for a method,
  • Define routes on GET, POST, PUT, DELETE and HEAD verbs,
  • Define middlewares on routes,
  • Define required parameters,
  • Inject data from query string, path parameters, entire body, cookies, session or header,
  • Inject Request, Response, Next object from Express request,
  • Template (View),
  • Testing.

Links

Getting started

See ourgetting started here to create new Ts.ED project or useourCLI

Overview

Server example

Here an example to create a Server with Ts.ED:

import{Configuration,Inject}from"@tsed/di";import{PlatformApplication}from"@tsed/platform-http";import"@tsed/platform-express";importcookieParserfrom"cookie-parser";importcompressfrom"compress";importmethodOverridefrom"method-override";@Configuration({port:3000,middlewares:["cookie-parser","compression","method-override","json-parser","urlencoded-parser"]})exportclassServer{}

To run your server, you have to use Platform API to bootstrap your application with the expectedplatform like Express.

import{$log}from"@tsed/logger";import{PlatformExpress}from"@tsed/platform-express";import{Server}from"./Server.js";asyncfunctionbootstrap(){try{$log.debug("Start server...");constplatform=awaitPlatformExpress.bootstrap(Server);awaitplatform.listen();$log.debug("Server initialized");}catch(er){$log.error(er);}}bootstrap();

To customize the server settings seeConfigure server with decorator

Controller example

This is a simple controller to expose user resource. It use decorators to build the endpoints:

import{Inject}from"@tsed/di";import{Summary}from"@tsed/swagger";import{Controller,Get,QueryParams,PathParams,Delete,Post,Required,BodyParams,Status,Put,Returns,ReturnsArray}from"@tsed/schema";import{BadRequest}from"@tsed/exceptions";import{UsersService}from"../services/UsersService.js";import{User}from"../models/User.js";@Controller("/users")exportclassUsersCtrl{  @Inject()privateusersService:UsersService;  @Get("/:id")  @Summary("Get a user from his Id")  @Returns(User)asyncgetUser(@PathParams("id")id:string):Promise<User>{returnthis.usersService.findById(id);}  @Post("/")  @Status(201)  @Summary("Create a new user")  @Returns(User)asyncpostUser(@Required() @BodyParams()user:User):Promise<User>{returnthis.usersService.save(user);}  @Put("/:id")  @Status(201)  @Summary("Update the given user")  @Returns(User)asyncputUser(@PathParams("id")id:string, @Required() @BodyParams()user:User):Promise<User>{if(user.id!==id){thrownewBadRequest("ID mismatch with the given payload");}returnthis.usersService.save(user);}  @Delete("/:id")  @Summary("Remove a user")  @Status(204)asyncdeleteUser(@PathParams("id") @Required()id:string):Promise<User>{awaitthis.usersService.delete(user);}  @Get("/")  @Summary("Get all users")  @(Returns(200,Array).Of(User))asyncfindUser(@QueryParams("name")name:string){returnthis.usersService.find({name});}}

Repository stats

Alt

Contributors

Please readcontributing guidelines here.

Backers

Thank you to all our backers! 🙏 [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

License

The MIT License (MIT)

Copyright (c) 2016 - 2023 Romain Lenzotti

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

📐 Ts.ED is a Node.js and TypeScript framework on top of Express to write your application with TypeScript (or ES6). It provides a lot of decorators and guideline to make your code more readable and less error-prone. ⭐️ Star to support our work!

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp