/ src / hooks / master-hook.ts
master-hook.ts
 1  // Use this hook to manipulate incoming or outgoing data.
 2  import type { HookContext } from "@feathersjs/feathers";
 3  import logger from "../logger";
 4  // For more information on hooks see: http://docs.feathersjs.com/api/hooks.html
 5  function recursive(i: number) {
 6  	setTimeout(() => {
 7  		logger.debug(`My Itteration ${i}`);
 8  		i++;
 9  		if (i < 50) {
10  			recursive(i);
11  		}
12  	}, 5000);
13  }
14  
15  export default function (options = {}) {
16  	return async (context: HookContext) => {
17  		const { method, type } = context;
18  		if (method === "find" && type === "before") {
19  			logger.info("oh... You need this loop?");
20  			const i = 0;
21  			recursive(i);
22  		}
23  		return context;
24  	};
25  }