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