Skip to content

Instantly share code, notes, and snippets.

@dievardump
Last active April 5, 2020 19:29
Show Gist options
  • Save dievardump/f270480f2f98996ce1f5ca49166e532f to your computer and use it in GitHub Desktop.
Save dievardump/f270480f2f98996ce1f5ca49166e532f to your computer and use it in GitHub Desktop.
Adonis v5 Provider exemple
import { IocContract } from '@adonisjs/fold'
import PostsLoader from './load/Posts'
export default class ETLProvider {
constructor (protected $container: IocContract) {
}
public register (): void {
// register bindings
this.$container.singleton('ETL/Loader/Posts', () => {
const Track = this.$container.use('App/Models/Track').default
const User = this.$container.use('App/Models/User').default
const Post = this.$container.use('App/Models/Post').default
const Helpers = this.$container.use('App/helpers').default
return new PostsLoader(Track, User, Post, Helpers)
})
}
public async boot () {
// optionally do some initial setup
const loader = this.$container.use('ETL/Loader/Posts')
await loader.init()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment