How to use the @adonisjs/fold.ioc.bind function in @adonisjs/fold

To help you get started, we’ve selected a few @adonisjs/fold examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github emilioforrer / adonis-translatable / test / setup.js View on Github external
wire: async function () {
    setupResolver()
    ioc.bind('Adonis/Src/Helpers', () => new Helpers(path.join(__dirname, '..', 'app')))

    await registrar.providers([
      '@adonisjs/framework/providers/AppProvider',
      '@adonisjs/lucid/providers/LucidProvider',
      '@adonisjs/validator/providers/ValidatorProvider',
      '@adonisjs/antl/providers/AntlProvider',
      path.join(__dirname, '../providers/TranslatableProvider')
    ]).registerAndBoot()

    ioc.singleton('App/Models/Role', (app) => {
      const Model = app.use('Model')
      class Role extends Model {
        static boot () {
          super.boot()
          this.addTrait('Translatable', {
            className: 'App/Models/RoleTranslation',
github HigoRibeiro / adonis-gql / test / unit / server.spec.js View on Github external
test('global middleware execution', assert => {
    const Gql = ioc.use('Gql')

    class Middleware {
      async gqlHandle (resolve, root, args, context, info) {}
    }

    ioc.bind('Adonis/Middleware/Auth', () => {
      return new Middleware()
    })

    class UserMiddlewareController {
      user (parent, args, ctx) {}
      users (parent, args, ctx) {}
    }

    ioc.bind('App/Controllers/Gql/UserMiddlewareController', () => {
      return UserMiddlewareController
    })

    Gql.schema('UserMiddleware', () => {
      Gql.query('UserMiddlewareController')
    })
github HigoRibeiro / adonis-gql / test / unit / server.spec.js View on Github external
test('middleware registered when schema and resolver is defined and inside controller', assert => {
    const Gql = ioc.use('Gql')

    class Middleware {
      async gqlHandle (resolve, root, args, context, info) {}
    }

    ioc.bind('Adonis/Middleware/Auth', () => {
      return new Middleware()
    })

    ioc.bind('Adonis/Middleware/Acl', () => {
      return new Middleware()
    })

    ioc.bind('Adonis/Middleware/SaaS', () => {
      return new Middleware()
    })

    Gql.registerNamed({
      auth: 'Adonis/Middleware/Auth',
      acl: 'Adonis/Middleware/Acl',
      saas: 'Adonis/Middleware/SaaS'
    })

    class UserMiddlewareController {
      user (parent, args, ctx) {}

      static middlewares () {
        return {
          all: ['auth'],
          user: ['acl']
github duyluonglc / lucid-mongo / test / functional / seed-database.spec.js View on Github external
group.before(async () => {
    ioc.bind('Adonis/Src/Config', () => {
      const config = new Config()
      config.set('database', {
        connection: 'testing',
        testing: helpers.getConfig()
      })
      return config
    })

    ioc.bind('Adonis/Src/Helpers', () => {
      return new Helpers(path.join(__dirname))
    })

    await fs.ensureDir(path.join(__dirname, 'database/seeds'))

    await registrar
      .providers([
        path.join(__dirname, '../../providers/LucidMongoProvider'),
        path.join(__dirname, '../../providers/MigrationsProvider')
      ]).registerAndBoot()

    await fs.ensureDir(path.join(__dirname, '../unit/tmp'))
    await helpers.createCollections(ioc.use('Database'))
    setupResolver()
  })
github brainnit / adonisjs-scout / test / unit / elasticsearch-driver.spec.js View on Github external
beforeAll(() => {
  ioc.bind('Adonis/Src/Model', () => Model)
  ioc.alias('Adonis/Src/Model', 'Model')

  ioc.bind('Adonis/Traits/Searchable', () => {
    const Searchable = require('../../src/Searchable')
    return new Searchable()
  })
  ioc.alias('Adonis/Traits/Searchable', 'Searchable')

  setupResolver()

  nock.disableNetConnect()
  nock('http://localhost:9200').get('/').reply(200, 'connection')
})
github enniel / adonis-acl / test / functional / commands.spec.js View on Github external
group.before(async () => {
    ioc.bind('Adonis/Src/Config', () => {
      const config = new Config()
      config.set('database', require('../config'))
      return config
    })
    ioc.bind('Adonis/Src/Helpers', () => {
      return new Helpers(path.join(__dirname, '..'))
    })
    ioc.alias('Adonis/Src/Helpers', 'Helpers')

    await registrar
      .providers([
        '@adonisjs/lucid/providers/LucidProvider',
        path.join(__dirname, '../../providers/AclProvider'),
        path.join(__dirname, '../../providers/CommandsProvider')
      ]).registerAndBoot()
    await fs.ensureDir(path.join(__dirname, '../tmp'))
    const Database = use('Database')
    await fixtures.up(Database)
    setupResolver()
  })
github brainnit / adonisjs-scout / test / unit / searchable.spec.js View on Github external
})
    return new DatabaseManager(config)
  })
  ioc.alias('Adonis/Src/Database', 'Database')

  ioc.singleton('Adonis/Addons/Scout', () => {
    const Config = ioc.use('Adonis/Src/Config')
    const Scout = require('../../src/Scout')
    return new Scout(Config)
  })
  ioc.alias('Adonis/Addons/Scout', 'Scout')

  ioc.bind('Adonis/Src/Model', () => Model)
  ioc.alias('Adonis/Src/Model', 'Model')

  ioc.bind('Adonis/Traits/Searchable', () => {
    const Searchable = require('../../src/Searchable')
    return new Searchable()
  })
  ioc.alias('Adonis/Traits/Searchable', 'Searchable')

  setupResolver()

  await setup.setupTables(ioc.use('Database'))
})
github HigoRibeiro / adonis-gql / test / functional / setup / index.js View on Github external
module.exports = async () => {
  ioc.bind('Adonis/Src/HttpContext', () => {
    return Context
  })

  ioc.bind('Adonis/Src/Config', () => {
    const config = new Config()

    config.set('grafql', {
      kernel: 'gqlKernel'
    })

    return config
  })

  ioc.bind('App/Controllers/Gql/Queries/UnamedController', () => {
    return UnamedController
  })
github adonisjs / adonis-auth / test / functional / setup / index.js View on Github external
module.exports = async () => {
  ioc.bind('Adonis/Src/HttpContext', () => {
    return Context
  })

  ioc.bind('Adonis/Src/View', () => {
    return {
      tag: function () {},
      engine: {
        BaseTag: class BaseTag {}
      }
    }
  })

  ioc.bind('Adonis/Src/Encryption', () => {
    return {
      encrypt (token) {
        return `e${token}`
github nrempel / adonis-kue / test / functional / providers.spec.js View on Github external
group.before(async () => {
    resolver.appNamespace('App')
    registrar
      .providers([
        '@adonisjs/framework/providers/AppProvider',
        '@adonisjs/redis/providers/RedisProvider',
        path.join(__dirname, '../../providers/KueProvider'),
        path.join(__dirname, '../../providers/CommandsProvider')
      ])
      .register()
    ioc.bind('Adonis/Src/Helpers', () => {
      return new Helpers(__dirname)
    })
    ioc.alias('Adonis/Src/Helpers', 'Helpers')
    ioc.bind('Adonis/Src/Config', () => {
      const config = new Config()
      config.set('kue', {
        connection: {
          prefix: 'q',
          redis: {
            host: 'localhost',
            post: 6379
          }
        }
      })
      config.set('app', {
        logger: {
          transport: 'console',
          console: {
            driver: 'console'
          }