17 lines
464 B
JavaScript
17 lines
464 B
JavaScript
export default class ApiBuilder {
|
|
constructor(common){
|
|
this.app=common.app;
|
|
this.middlewares=[...common.middlewares];
|
|
}
|
|
method(m){ this.m=m.toLowerCase(); return this; }
|
|
url(u){ this.path=u.build(); return this; }
|
|
schema(s){ this.schemaBuilder=s; return this; }
|
|
sync(){ return this; }
|
|
build(dbClient){
|
|
this.app[this.m](
|
|
this.path,
|
|
...this.middlewares,
|
|
(req,res)=>this.schemaBuilder.execute(req,res,dbClient)
|
|
);
|
|
}
|
|
} |