Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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',
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')
})
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']
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()
})
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')
})
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()
})
})
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'))
})
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
})
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}`
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'
}