Boilerplate generator and deno tasks for monorepo

This commit is contained in:
Emma
2023-05-01 20:28:18 -06:00
parent a367562ba0
commit a910783882
36 changed files with 1164 additions and 47 deletions

30
lib/Application.ts Normal file
View File

@@ -0,0 +1,30 @@
import { Application, Router } from 'oak';
import { authenticateUser } from 'middleware/auth.ts';
type servicePrefix = `/${string}`;
interface IServiceOpts {
prefix: servicePrefix;
}
export class CGGService<T> extends Application<T & {user?: string}> {
public prefix: servicePrefix;
constructor(options: IServiceOpts) {
super();
this.prefix = options.prefix;
this.use(authenticateUser);
// this.baseRouter = new Router({prefix: this.prefix});
}
start() {
const port = Deno.args.at(0);
this.listen({ port: port ? Number(port) : undefined })
}
route(router: Router) {
router.prefix(this.prefix);
this.use(router.routes())
this.use(router.allowedMethods());
}
}