Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or download
Notice: Creating folder will generate an empty file .keep, because not support in Git


  • Support typeorm, the best typescript ORM framework, and easily write all kinds of logic of Dao layer
  • Allow static type modification and type inference to support back-end development and maintenance
  • Modular development makes the application easier to layer and provides an easy-to-use modular management mechanism
  • AOP code is written in a low-key way, but it is easy to realize log, interceptor, filter and other functions
  • MVC, API, websocket, microservice and other systems are constructed fastest, good and most fiercely
  • The configuration is greater than the code, and priority is given to automatically implement five methods, such as adding, deleting, modifying and querying, and pagination, to facilitate the establishment of authority background system
  • With the field level RBAC and pluggable middleware decorator, the assembly function has unlimited possibilities

With ThinkTs your controller look like this:

@Class(["add","del","fix","info","page"])//or @Class("/admin",……)or @Class("admin",……)
class AdminController extends Controller{
  @Inject(AdminService) readonly adminSvc:AdminService
  @Inject(UserService) readonly userSvc:AdminService

  async login(@B body) {
    return await this.userSvc.login(body.account,body.pwd)
/** Here's how to show EJS template rendering */
class View{
  async index(ctx:Context){
    await html(ctx,{test:"test",author:"asciphx"})
  async login(ctx:Context){
    await html(ctx,{test:"test",author:"Login"})

And your service looks like this:

export class UserService extends Service implements UserFace{
    private user:Repository<User>=Cache[],
    private role:Repository<Role>=Cache[]
  ) {
      where: query => {
        return new Brackets(qb => {
          if (query.account) qb.where('account like :v', { v: `%${query.account}%` })
          if ( qb.andWhere('id >:i', { i: })
      orderBy: { "": "desc" }

And your interface looks like this:

export interface UserFace{
  /** register one*/register(entity)
  /** login one*/login(entity)

Finally, please refer to the entity class writing method of TypeORM


  • The default value of class class decorator is/+ entity class name, which can also be customized
  • Automatically scan controller directory and configure routes route
  • Automatically scan the entity directory and load it into Cache, which is equivalent to a container, which can avoid multiple instances of entity
  • Automatically generate the configuration route file for reference, which is under the routes directory
  • Automatic implementation of addition, deletion, modification and query
  • Now add the basic controller and service layer. The controller decorator can be customized to automatically add, delete, modify, query and pagination.
  • The controller can now customize the name of the service class variable to be called.
  • In order to reduce memory overhead and instance calls, we have implemented the containerization of entity classes.
  • Add parameter decorator, more convenient and beautiful, and will not affect the running speed

New version of custom JWT authentication description

The header request header now has two parameters, and the original JWT does not change. Now add a secret. Secret is now provided by the back end. The algorithm is in the cryptoUtil.ts in


In particular, localhost:8080/index.html It is the postman interface. Remember to record token and sercet after login and use it as above. The front-end is still in implementation. Let's use postman for a while. For instructions started in a formal environment, windows uses NPM run pro, while MAC or Linux uses NPM run prod Because I use windows 10, PM2 does not support Linux or Mac temporarily. If you need to use it, please rewrite it and test it yourself

Steps to run this project:

  1. Run npm i command
  2. Setup database settings inside ormconfig.json file
  3. Run npm start command

Authority management

menu path,automatically generated(Matching rule)


The return value in restful specification actually costs too much bandwidth. However, I think the front end only needs to judge whether the return is a string or an object. For example, the string is displayed directly (the front-end pop-up window is OK), If an object is returned, the request status code must be 200, so only the important data is taken without the code status code and mass message to indicate success (those two things are totally a waste of traffic).

Directory structure

  1. ts: back end file entry
  2. ts/controller: control layer
  3. ts/entity:entity layer
  4. ts/interface: interface layer
  5. ts/service: service layer
  6. ts/think: base layer
  7. ts/utils: tool layer
  8. views: background EJS template rendering folder
  9. routes: output the route file to view. Each controller will create one
  10. Lib: Windows uses the RM and CP instructions of Linux, and needs to put the environment variable directory


Built by the world's No.1 man, Asciphx
Please wait this project will generate a blog project

Comments ( 0 )

Sign in for post a comment


基于koa和typeorm,异步非阻塞反应式架构,也是一个真正的MVC框架,开发速度最快,性能安全最好的架构。 spread retract


No release




load more
can not load any more