typescript-rest icon indicating copy to clipboard operation
typescript-rest copied to clipboard

Rest with pattern template

Open dknitrox opened this issue 8 years ago • 0 comments
trafficstars

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<User>{}
}

dknitrox avatar Nov 04 '17 01:11 dknitrox