How to use the moleculer.deprecate function in moleculer

To help you get started, we’ve selected a few moleculer 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 moleculerjs / moleculer-web / src / index.js View on Github external
res.setHeader("Location", location);
				}
			}

			// Override responseType by action (Deprecated)
			let responseType;
			/* istanbul ignore next */
			if (action && action.responseType) {
				deprecate("The 'responseType' action property has been deprecated. Use 'ctx.meta.$responseType' instead");
				responseType = action.responseType;
			}

			// Custom headers (Deprecated)
			/* istanbul ignore next */
			if (action && action.responseHeaders) {
				deprecate("The 'responseHeaders' action property has been deprecated. Use 'ctx.meta.$responseHeaders' instead");
				Object.keys(action.responseHeaders).forEach(key => {
					res.setHeader(key, action.responseHeaders[key]);
					if (key == "Content-Type" && !responseType)
						responseType = action.responseHeaders[key];
				});
			}

			// Custom responseType from ctx.meta
			if (ctx.meta.$responseType) {
				responseType = ctx.meta.$responseType;
			}

			// Custom headers from ctx.meta
			if (ctx.meta.$responseHeaders) {
				Object.keys(ctx.meta.$responseHeaders).forEach(key => {
					if (key == "Content-Type" && !responseType)
github moleculerjs / moleculer-web / src / index.js View on Github external
}
			}

			// Resolve endpoint by action name
			if (alias.action) {
				const endpoint = this.broker.findNextActionEndpoint(alias.action, route.callOptions, ctx);
				if (endpoint instanceof Error) {
					if (!alias._notDefined && endpoint instanceof ServiceNotFoundError) {
						throw new ServiceUnavailableError();
					}

					throw endpoint;
				}

				if (endpoint.action.publish === false) {
					deprecate("The 'publish: false' action property has been deprecated. Use 'visibility: public' instead.");
					// Action is not publishable (Deprecated in >=0.13)
					throw new ServiceNotFoundError({ action: alias.action });
				}

				if (endpoint.action.visibility != null && endpoint.action.visibility != "published") {
					// Action can't be published
					throw new ServiceNotFoundError({ action: alias.action });
				}

				req.$endpoint = endpoint;
				req.$action = endpoint.action;
			}

			// onBeforeCall handling
			if (route.onBeforeCall) {
				await route.onBeforeCall.call(this, ctx, route, req, res);
github moleculerjs / moleculer-web / src / index.js View on Github external
// Redirect
			if (res.statusCode >= 300 && res.statusCode < 400 && res.statusCode !== 304) {
				const location = ctx.meta.$location;
				/* istanbul ignore next */
				if (!location) {
					this.logger.warn(`The 'ctx.meta.$location' is missing for status code '${res.statusCode}'!`);
				} else {
					res.setHeader("Location", location);
				}
			}

			// Override responseType by action (Deprecated)
			let responseType;
			/* istanbul ignore next */
			if (action && action.responseType) {
				deprecate("The 'responseType' action property has been deprecated. Use 'ctx.meta.$responseType' instead");
				responseType = action.responseType;
			}

			// Custom headers (Deprecated)
			/* istanbul ignore next */
			if (action && action.responseHeaders) {
				deprecate("The 'responseHeaders' action property has been deprecated. Use 'ctx.meta.$responseHeaders' instead");
				Object.keys(action.responseHeaders).forEach(key => {
					res.setHeader(key, action.responseHeaders[key]);
					if (key == "Content-Type" && !responseType)
						responseType = action.responseHeaders[key];
				});
			}

			// Custom responseType from ctx.meta
			if (ctx.meta.$responseType) {