How to use the @adonisjs/fold.resolver.forDir 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 adonisjs / adonis-framework / src / Server / index.js View on Github external
_getExceptionHandlerNamespace () {
    const exceptionHandlerFile = resolver.forDir('exceptions').getPath('Handler.js')

    try {
      fs.accessSync(exceptionHandlerFile, fs.constants.R_OK)
      return resolver.forDir('exceptions').translate('Handler')
    } catch (error) {
      return 'Adonis/Exceptions/BaseExceptionHandler'
    }
  }
github adonisjs / adonis-framework / src / Server / index.js View on Github external
_getExceptionHandlerNamespace () {
    const exceptionHandlerFile = resolver.forDir('exceptions').getPath('Handler.js')

    try {
      fs.accessSync(exceptionHandlerFile, fs.constants.R_OK)
      return resolver.forDir('exceptions').translate('Handler')
    } catch (error) {
      return 'Adonis/Exceptions/BaseExceptionHandler'
    }
  }
github adonisjs / adonis-framework / src / Server / index.js View on Github external
async _routeHandler (ctx, next, params) {
    const { method } = resolver.forDir('httpControllers').resolveFunc(params[0])
    const returnValue = await method(ctx)

    this._safelySetResponse(ctx.response, returnValue)

    await next()
  }
github adonisjs / adonis-framework / src / Exception / index.js View on Github external
getHandler (name, ignoreWildcard = false) {
    const binding = this._bindings[name]
    let handler

    /**
     * Give priority to binding when it exists,
     * then look for inline handler and finally
     * fallback to wildcard if required
     */
    if (binding) {
      const bindingInstance = resolver.forDir('exceptionHandlers').resolve(binding)
      if (typeof (bindingInstance.handle) === 'function') {
        handler = bindingInstance.handle.bind(bindingInstance)
      }
    }

    /**
     * If handler was not resolved from the binding
     * then look for it inside handlers object.
     */
    handler = handler || this._handlers[name]

    /**
     * If ignoreWildcard is false and there is no
     * handler, return the wildcard handler
     */
    if (!handler && !ignoreWildcard) {
github adonisjs / adonis-framework / src / Event / index.js View on Github external
_resolveListener (listener) {
    const { method } = resolver.forDir('listeners').resolveFunc(listener)
    if (typeof (listener) === 'string') {
      this._namespacedListeners[listener] = method
    }
    return method
  }
github adonisjs / adonis-validation-provider / src / Middleware / Validator.js View on Github external
async handle (ctx, next, validator) {
    validator = validator instanceof Array === true ? validator[0] : validator

    if (!validator) {
      throw new Error('Cannot validate request without a validator. Make sure to call Route.validator(\'validatorPath\')')
    }

    const validatorInstance = resolver.forDir('validators').resolve(validator)

    /**
     * Set request ctx on the validator
     */
    validatorInstance.ctx = ctx

    /**
     * Sanitize request data if there are sanitization rules
     */
    this._sanitizeData(ctx.request, validatorInstance)

    /**
     * Validate the request. This method should handle the request
     * response, since the middleware chain has been stopped.
     *
     * If this method doesn't handles the response, then a generic