vendredi 3 novembre 2017

Documentation con typescript rest or alternatives

How can I do the following, I have a base class template

class BaseService {
    model=any;
    constructor(model){
        this.model=model;
    }

    async findAll(body){
        return await this.model.find(body);
    }
    async create(body){
        return await this.model.insert(body);
    }
}

and a child class

class UserService extends BaseService{
    constructor(model){
        super(model);
    }
}
class BookService extends BaseService{ 
    constructor(model){
        super(model);
    }
}

How can I generate the documentation of both using the template design template?

in this way if you can, but code is duplicated.

@Path("/users")`

class UserService{
   @GET
   findAll(): Promise<Array<User>> {
      //...
   }
 @POST
  create():Promide<User>{}
}
@Path("/books")
class UserService {
   @GET
   findAll(): Promise<Array<User>> {
      //...
   }
 @POST
  create():Promide<Book>{}
}

use typescript with nodejs + typescript-rest

Aucun commentaire:

Enregistrer un commentaire