// app.tsimportKoafrom'koa'importRouterfrom'@koa/router'import{KoaDriver,Restype}from'restype'constapp=newKoa()constrouter=newRouter()constrestype=newRestype<KoaDriver>({driverFactory(opts){returnnewKoaDriver({
router,
...opts})}})for(consthandlerofrestype.getHandlers()){app.use(handler)}restype.setup().then(()=>{app.listen(3000,()=>{console.log('Server is running on http://localhost:3000')})})
import{Restype,IDriver}from'restype'classCustomDriverimplementsIDriver{publicasyncsetup(): Promise<void>{// when Restype.setup() is called}publicasyncgetHandlers(): any[]{//}}constrestype=newRestype<CustomDriver>({driver: newCustomDriver(),// ordriverFactory(opts){// opts.restype has Restype instance, so you can pass it if it's required in your custom driverreturnnewCustomDriver()}})
import{useContainer,IIocAdapter}from'restype'classCustomIocAdapterimplementsIIocAdapter{get(target){// some logic that returns instance of `target`}}constiocAdapter=newCustomIocAdapter()useContainer(iocAdapter)