Skip to content

Getting Started ​

Try it online ​

You can try Ts.ED directly in your browser on CodeSandbox.

Installation ​

To get started, you can either scaffold the project with the Ts.ED CLI, or clone a starter project.

To scaffold the project with the CLI, run the following commands. This will create a new project directory, and populate the directory with the initial core Ts.ED files and supporting modules, creating a conventional base structure for your project. Creating a new project with the CLI is recommended for first-time users.

sh
npx -p @tsed/cli tsed init .
sh
yarn set version berry
yarn dlx -p @tsed/cli tsed init .
sh
pnpm --package=@tsed/cli dlx tsed init .
sh
bunx -p @tsed/cli tsed init .

WARNING

Ts.ED v8 required at least Node.js v20.11.0 version to work.

You will be greeted with a few simple questions:

? Choose the target platform: (Use arrow keys)
❯ Express.js
  Koa.js
  Fastify.js

? Choose the architecture for your project: (Use arrow keys)
❯ Ts.ED
  Feature

? Choose the convention file styling: (Use arrow keys)
❯ Ts.ED
  Angular

? Check the features needed for your project (Press <space> to select, <a> to toggle all, <i> to invert selection, and <enter> to proceed)
  ◉ Swagger
  ◯ OpenID Connect provider
  ◉ Testing
❯ ◉ Linter
  ◯ Commands
  ◯ TypeGraphQL
  ◯ Database

? Choose unit framework (Use arrow keys)
❯ Jest
  Mocha + Chai + Sinon

? Choose linter tools framework (Use arrow keys)
❯ EsLint

? Choose extra linter tools (Press <space> to select, <a> to toggle all, <i> to invert selection, and <enter> to proceed)
  ◉ Prettier
❯ ◉ Lint on commit

? Choose the runtime:
❯ Node.js
  Node.js + Babel
  Node.js + Webpack
  Node.js + SWC
  Bun.js (experimental)

? Choose the package manager:
  NPM
  Yarn
❯ Yarn Berry

TIP

By default, it's recommended to select the following options: Express, Ts.ED (convention), Swagger, Jest and Eslint + prettier.

When all options are selected, the CLI will generate all files. When it's done, run one of this command:

sh
npm start
sh
yarn start
sh
pnpm start
sh
bun start
[2024-02-18T12:51:22.798] [INFO ] [TSED] - Loading EXPRESS platform adapter... +2ms
[2024-02-18T12:51:22.800] [INFO ] [TSED] - Injector created... +2ms
[2024-02-18T12:51:22.934] [INFO ] [TSED] - Build providers +134ms
[2024-02-18T12:51:22.986] [INFO ] [TSED] - Settings and injector loaded... +52ms
[2024-02-18T12:51:22.986] [INFO ] [TSED] - Mount app context +0ms
[2024-02-18T12:51:22.986] [INFO ] [TSED] - Load routes +0ms
[2024-02-18T12:51:22.990] [INFO ] [TSED] - Routes mounted... +4ms
[2024-02-18T12:51:22.990] [INFO ] [TSED] - 
┌───────────────┬───────────────────┬────────────────────────────┐
│ Method        │ Endpoint          │ Class method               │
│───────────────│───────────────────│────────────────────────────│
│ GET           │ /rest/hello-world │ HelloWorldController.get() │
│───────────────│───────────────────│────────────────────────────│
│ GET           │ /                 │ IndexController.get()      │
└───────────────┴───────────────────┴────────────────────────────┘
[2024-02-18T12:51:22.993] [INFO ] [TSED] - Listen server on http://0.0.0.0:8083
[2024-02-18T12:51:22.993] [INFO ] [TSED] - [default] Swagger JSON is available on http://0.0.0.0:8083/doc/swagger.json
[2024-02-18T12:51:22.993] [INFO ] [TSED] - [default] Swagger UI is available on http://0.0.0.0:8083/doc/
[2024-02-18T12:51:22.993] [INFO ] [TSED] - Started in 197 ms +3ms

Update dependencies ​

WARNING

If you have to upgrade Ts.ED dependencies, keep in mind this point:

It's really important to keep the same version for all @tsed/* (excepted @tsed/logger) packages. To prevent errors, fix the version for each Ts.ED packages:

json
{
  "dependencies": {
    "@tsed/platform-http": "8.0.0",
    "@tsed/di": "8.0.0",
    "@tsed/core": "8.0.0",
    "@tsed/exceptions": "8.0.0",
    "@tsed/platform-express": "8.0.0",
    "@tsed/swagger": "8.0.0"
  }
}

Project examples ​

Alternatively, you can check out one of these projects:

If none of previous solutions are satisfying maybe you are in these cases:

What's next? ​

Now you can follow one of these links to develop your new application:

Released under the MIT License.