Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('ignore http status inside the ignore list', (assert) => {
class AppHandler extends HttpExceptionHandler {
protected ignoreStatuses = [500]
protected dontReport = []
}
const logger = new FakeLogger(loggerConfig)
const handler = new AppHandler(logger)
const ctx = HttpContext.create('/', {}, logger, new Profiler({}).create(''), encryption)
handler.report(new Exception('bad request', 500, 'E_BAD_REQUEST'), ctx)
assert.deepEqual(logger.logs, [])
})
test('pass profiler to the client when defined explicitly', async (assert) => {
class User extends BaseModel {
public static $table = 'users'
@column({ primary: true })
public id: number
@column()
public username: string
}
await db.insertQuery().table('users').insert({ username: 'virk' })
const profiler = new Profiler({})
const user = await User.query({ profiler }).first()
assert.equal(user!.$options!.connection, 'primary')
assert.deepEqual(user!.$options!.profiler, profiler)
})
export function getProfiler () {
return new Profiler({ enabled: false })
}
const server = createServer(async (req, res) => {
const cors = new Cors(fixture.configureOptions())
const logger = new Logger({ name: 'adonis', enabled: false, level: 'trace' })
fixture.configureRequest(req)
const ctx = HttpContext.create('/', {}, logger, new Profiler({}).create(''), encryption, req, res)
await cors.handle(ctx)
if (!ctx.response.hasLazyBody) {
ctx.response.send(null)
}
ctx.response.finish()
})
private _instantiateProfiler () {
const profiler = new Profiler(this._getProfilerConfig())
this.ioc.singleton('Adonis/Src/Profiler', () => profiler)
this.ioc.alias('Adonis/Src/Profiler', 'Profiler')
/**
* Attach subscriber if exists
*/
if (this._profilerSubscriber) {
profiler.subscribe(this._profilerSubscriber)
}
this._bootstrapper = profiler.create('bootstrap', { intent: this._intent })
}