Skip to content
Bd999 edited this page Apr 16, 2019 · 9 revisions

🌈 T-Koa

T-Koa is a koa framework written in typescript. typescript logo

Introduction

T-Koa is similar to koa and has almost no changes in functionality, so you can view the tutorial on the koa official website. (Compared with koa, tkoa needs you to follow the typescript programming way, you can see the specific changes here.)

And you need to know some basic typescript and node.js programming knowledge.

More

T-koa has almost no change compared to koa, but you still have to know something:

  • Koa2 supports Generator middleware for koa1, but T-koa does not support Generator middleware since version 1.0.0.
  • Although typescript has its own programming way, we recommend that you use the commonjs module specification (for better compatibility with node.js and koa middleware)

Installation

TKoa requires typescript v3.1.0+ and node v7.6.0+ for ES2015 and async function support.

You can quickly install a supported version of node with your favorite version manager:

$ npm i tkoa
$ tsc -t es6 -m commonjs my-tkoa-app.ts
$ node my-tkoa-app.js

Quick Start

import tKoa = require('tkoa');

interface ctx {
    res: {
        end: Function
    }
}

const app = new tKoa();

// response
app.use((ctx: ctx) => {
    ctx.res.end('Hello T-koa!');
});

app.listen(3000);

Version Choice

T-Koa version -------- Koa version

  • v1.0.X --------------- v2.7.0