adonis-provider-tester
v2.1.0
Published
Util for testing adonis provider
Downloads
10
Readme
adonis5-provider-tester
AdonisJS
Util for running adonis providers for testing.
Using
Setup adonis app with your providers and configs:
const app = await new AdonisApplication()
.registerProvider(AdonisCacheProvider)
.registerProvider(AdonisRequestThrottlerProvider)
.registerAppConfig({ configName: 'cache', appConfig: cacheConfig })
.registerAppConfig({ configName: 'request-throttler', appConfig: throttlerConfig })
.loadApp()
Take object from container:
const instance = app.iocContainer.use(<ProviderURI>)
Setup adonis app and start http server for app:
const app = await new AdonisApplication()
.registerProvider(AdonisCacheProvider)
.registerProvider(AdonisRequestThrottlerProvider)
.registerAppConfig({ configName: 'cache', appConfig: cacheConfig })
.registerAppConfig({ configName: 'request-throttler', appConfig: throttlerConfig })
.loadAppWithHttpServer()
Close app:
await app.stopApp()
Close http server:
await app.stopServer()
Register middleware:
import { Middleware } from "co-compose";
const app = await new AdonisApplication()
.registerProvider(MiddlewareProvider)
.registerNamedMiddleware('<middleware-name>', '<middleware-uri>')
.loadAppWithHttpServer()