index.ts 3.3 KB

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