How to use the koa.prototype function in koa

To help you get started, we’ve selected a few koa 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 AfterShip / koa-newrelic / index.js View on Github external
};

				return wrapped;
			}

			return middleware;
		};

		try {
			let Koa = require('koa');
			let originalUse = Koa.prototype.use;
			Koa.prototype.use = function (middleware) {
				let wrapped = wrapMiddleware(middleware);
				return originalUse.call(this, wrapped);
			};
			Koa.prototype.use._original = originalUse;
			registerWrapped(Koa.prototype, 'use');

			try {
				const Router = require('koa-router');

				let originalRegister = Router.prototype.register;

				Router.prototype.register = function () {
					let middlewares = Array.isArray(arguments[2]) ? arguments[2] : [arguments[2]];

					let wrappedMiddlewares = middlewares.map(middleware => wrapMiddleware(middleware));

					arguments[2] = wrappedMiddlewares;
					return originalRegister.apply(this, arguments);
				};
				Router.prototype.register._original = originalRegister;
github AfterShip / koa-newrelic / index.js View on Github external
return wrapped;
			}

			return middleware;
		};

		try {
			let Koa = require('koa');
			let originalUse = Koa.prototype.use;
			Koa.prototype.use = function (middleware) {
				let wrapped = wrapMiddleware(middleware);
				return originalUse.call(this, wrapped);
			};
			Koa.prototype.use._original = originalUse;
			registerWrapped(Koa.prototype, 'use');

			try {
				const Router = require('koa-router');

				let originalRegister = Router.prototype.register;

				Router.prototype.register = function () {
					let middlewares = Array.isArray(arguments[2]) ? arguments[2] : [arguments[2]];

					let wrappedMiddlewares = middlewares.map(middleware => wrapMiddleware(middleware));

					arguments[2] = wrappedMiddlewares;
					return originalRegister.apply(this, arguments);
				};
				Router.prototype.register._original = originalRegister;
				registerWrapped(Router.prototype, 'register');
github AfterShip / koa-newrelic / index.js View on Github external
throw e;
					} finally {
						endTracer();
					}
				};

				return wrapped;
			}

			return middleware;
		};

		try {
			let Koa = require('koa');
			let originalUse = Koa.prototype.use;
			Koa.prototype.use = function (middleware) {
				let wrapped = wrapMiddleware(middleware);
				return originalUse.call(this, wrapped);
			};
			Koa.prototype.use._original = originalUse;
			registerWrapped(Koa.prototype, 'use');

			try {
				const Router = require('koa-router');

				let originalRegister = Router.prototype.register;

				Router.prototype.register = function () {
					let middlewares = Array.isArray(arguments[2]) ? arguments[2] : [arguments[2]];

					let wrappedMiddlewares = middlewares.map(middleware => wrapMiddleware(middleware));
github AfterShip / koa-newrelic / index.js View on Github external
} catch (e) {
						throw e;
					} finally {
						endTracer();
					}
				};

				return wrapped;
			}

			return middleware;
		};

		try {
			let Koa = require('koa');
			let originalUse = Koa.prototype.use;
			Koa.prototype.use = function (middleware) {
				let wrapped = wrapMiddleware(middleware);
				return originalUse.call(this, wrapped);
			};
			Koa.prototype.use._original = originalUse;
			registerWrapped(Koa.prototype, 'use');

			try {
				const Router = require('koa-router');

				let originalRegister = Router.prototype.register;

				Router.prototype.register = function () {
					let middlewares = Array.isArray(arguments[2]) ? arguments[2] : [arguments[2]];

					let wrappedMiddlewares = middlewares.map(middleware => wrapMiddleware(middleware));

koa

Koa web app framework

MIT
Latest version published 7 months ago

Package Health Score

93 / 100
Full package analysis