How to use before-after-hook - 7 common examples

To help you get started, we’ve selected a few before-after-hook 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 newrelic / newrelic-ruby-agent / .github / actions / build-ruby / node_modules / @octokit / core / dist-src / index.js View on Github external
constructor(options = {}) {
        const hook = new Collection();
        const requestDefaults = {
            baseUrl: request.endpoint.DEFAULTS.baseUrl,
            headers: {},
            request: Object.assign({}, options.request, {
                hook: hook.bind(null, "request"),
            }),
            mediaType: {
                previews: [],
                format: "",
            },
        };
        // prepend default user agent with `options.userAgent` if set
        requestDefaults.headers["user-agent"] = [
            options.userAgent,
            `octokit-core.js/${VERSION} ${getUserAgent()}`,
        ]
github newrelic / newrelic-ruby-agent / .github / actions / build-ruby / node_modules / @octokit / core / dist-node / index.js View on Github external
constructor(options = {}) {
    const hook = new beforeAfterHook.Collection();
    const requestDefaults = {
      baseUrl: request.request.endpoint.DEFAULTS.baseUrl,
      headers: {},
      request: Object.assign({}, options.request, {
        hook: hook.bind(null, "request")
      }),
      mediaType: {
        previews: [],
        format: ""
      }
    }; // prepend default user agent with `options.userAgent` if set

    requestDefaults.headers["user-agent"] = [options.userAgent, `octokit-core.js/${VERSION} ${universalUserAgent.getUserAgent()}`].filter(Boolean).join(" ");

    if (options.baseUrl) {
      requestDefaults.baseUrl = options.baseUrl;
github newrelic / newrelic-ruby-agent / .github / actions / build-ruby / node_modules / @octokit / core / dist-web / index.js View on Github external
constructor(options = {}) {
        const hook = new Collection();
        const requestDefaults = {
            baseUrl: request.endpoint.DEFAULTS.baseUrl,
            headers: {},
            request: Object.assign({}, options.request, {
                hook: hook.bind(null, "request"),
            }),
            mediaType: {
                previews: [],
                format: "",
            },
        };
        // prepend default user agent with `options.userAgent` if set
        requestDefaults.headers["user-agent"] = [
            options.userAgent,
            `octokit-core.js/${VERSION} ${getUserAgent()}`,
        ]
github JasonEtco / action-record / src / model.ts View on Github external
constructor (model: ModelInput) {
    this.name = model.name
    this.schema = model.schema

    // An object of Hook instances
    this.hooks = {
      create: new Hook.Singular(),
      validate: new Hook.Singular(),
      save: new Hook.Singular()
    }

    // A map of hook names to actual setters
    this.hookMap = {
      beforeCreate: this.hooks.create.before,
      afterCreate: this.hooks.create.after,
      beforeValidate: this.hooks.validate.after,
      afterValidate: this.hooks.validate.after,
      beforeSave: this.hooks.save.after,
      afterSave: this.hooks.save.after,
    }

    // Actually register the hooks
    if (model.hooks) {
      for (const key in model.hooks) {
github JasonEtco / action-record / src / model.ts View on Github external
constructor (model: ModelInput) {
    this.name = model.name
    this.schema = model.schema

    // An object of Hook instances
    this.hooks = {
      create: new Hook.Singular(),
      validate: new Hook.Singular(),
      save: new Hook.Singular()
    }

    // A map of hook names to actual setters
    this.hookMap = {
      beforeCreate: this.hooks.create.before,
      afterCreate: this.hooks.create.after,
      beforeValidate: this.hooks.validate.after,
      afterValidate: this.hooks.validate.after,
      beforeSave: this.hooks.save.after,
      afterSave: this.hooks.save.after,
    }

    // Actually register the hooks
    if (model.hooks) {
      for (const key in model.hooks) {
        const hookFn = model.hooks[key as keyof Hooks]
github JasonEtco / action-record / src / model.ts View on Github external
constructor (model: ModelInput) {
    this.name = model.name
    this.schema = model.schema

    // An object of Hook instances
    this.hooks = {
      create: new Hook.Singular(),
      validate: new Hook.Singular(),
      save: new Hook.Singular()
    }

    // A map of hook names to actual setters
    this.hookMap = {
      beforeCreate: this.hooks.create.before,
      afterCreate: this.hooks.create.after,
      beforeValidate: this.hooks.validate.after,
      afterValidate: this.hooks.validate.after,
      beforeSave: this.hooks.save.after,
      afterSave: this.hooks.save.after,
    }

    // Actually register the hooks
    if (model.hooks) {
github octokit / rest.js / lib / constructor.js View on Github external
function Octokit(plugins, options) {
  options = options || {};
  const hook = new Hook.Collection();
  const log = Object.assign(
    {
      debug: () => {},
      info: () => {},
      warn: console.warn,
      error: console.error
    },
    options && options.log
  );
  const api = {
    hook,
    log,
    request: request.defaults(parseClientOptions(options, log, hook))
  };

  plugins.forEach(pluginFunction => pluginFunction(api, options));

before-after-hook

asynchronous before/error/after hooks for internal functionality

Apache-2.0
Latest version published 2 years ago

Package Health Score

72 / 100
Full package analysis