UNPKG

@thisismissem/adonisjs-respond-with

Version:

A small plugin for Adonis.js to make responding with different content-types easier.

22 lines (21 loc) 697 B
import { AcceptNegotiator } from '../src/acceptor.js'; export default class RespondWithProvider { app; constructor(app) { this.app = app; } async boot() { await import('../src/extension.js'); } register() { this.app.container.singleton(AcceptNegotiator, async () => { const config = this.app.config.get('respond_with', { defaultHandler: 'error', mappings: {}, }); const logger = await this.app.container.make('logger'); return new AcceptNegotiator(config, logger); }); this.app.container.alias('respondWith.acceptNegotiator', AcceptNegotiator); } }