index.ts 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import { type Context, type Handler } from "aws-lambda";
  2. import config from "./config";
  3. import { handler as chilecultura } from "./portales/chilecultura/handler";
  4. import { handler as ciper } from "./portales/ciper/handler";
  5. import { handler as codexverde } from "./portales/codexverde/handler";
  6. import { handler as contrapoder } from "./portales/contrapoder/handler";
  7. // import { handler as cooperativa } from "./portales/cooperativa/handler";
  8. import { handler as df } from "./portales/df/handler";
  9. import { handler as elciudadano } from "./portales/elciudadano/handler";
  10. import { handler as eldesconcierto } from "./portales/eldesconcierto/handler";
  11. import { handler as elmostrador } from "./portales/elmostrador/handler";
  12. import { handler as fastcheck } from "./portales/fastcheck/handler";
  13. import { handler as glaciareschilenos } from "./portales/glaciareschilenos/handler";
  14. import { handler as emol } from "./portales/emol/handler";
  15. import { handler as interferencia } from "./portales/interferencia/handler";
  16. import { handler as laderasur } from "./portales/laderasur/handler";
  17. import { handler as latercera } from "./portales/latercera/handler";
  18. // import { handler as metrodesantiago } from "./portales/metrodesantiago/handler";
  19. import { handler as tarreo } from "./portales/tarreo/handler";
  20. import { handler as theclinic } from "./portales/theclinic/handler";
  21. const context: Context = {
  22. callbackWaitsForEmptyEventLoop: false,
  23. functionName: "",
  24. functionVersion: "",
  25. invokedFunctionArn: "",
  26. memoryLimitInMB: "0",
  27. awsRequestId: "",
  28. logGroupName: "",
  29. logStreamName: "",
  30. done: () => { },
  31. fail: () => { },
  32. succeed: () => { },
  33. getRemainingTimeInMillis: () => 1
  34. };
  35. const portalsHandlers = {
  36. "chilecultura": chilecultura,
  37. "ciper": ciper,
  38. "codexverde": codexverde,
  39. "contrapoder": contrapoder,
  40. // "cooperativa": cooperativa,
  41. "df": df,
  42. "elciudadano": elciudadano,
  43. "eldesconcierto": eldesconcierto,
  44. "elmostrador": elmostrador,
  45. "emol": emol,
  46. "fastcheck": fastcheck,
  47. "glaciareschilenos": glaciareschilenos,
  48. "interferencia": interferencia,
  49. "laderasur": laderasur,
  50. "latercera": latercera,
  51. // "metrodesantiago": metrodesantiago,
  52. "tarreo": tarreo,
  53. "theclinic": theclinic
  54. };
  55. const activePortalsHandlers: Array<Handler> = Object.keys(portalsHandlers)
  56. .filter((portalName) => !config.DEVELOP || config.DEV_ACTIVE_PORTALS.includes(portalName))
  57. .map((portalName) => portalsHandlers[portalName]);
  58. const cooldown = 10000; // 10 seconds
  59. async function main(): Promise<void> {
  60. console.log(`${activePortalsHandlers}`)
  61. for (const portalHandler of activePortalsHandlers) {
  62. await portalHandler(null, context, () => { });
  63. await new Promise((resolve) => setTimeout(resolve, cooldown));
  64. }
  65. }
  66. main()
  67. .catch((err) => {
  68. console.error(err)
  69. })
  70. .finally(() => {
  71. process.exit(0);
  72. });