|
@@ -1,4 +1,6 @@
|
|
|
-import { type Context } from "aws-lambda";
|
|
|
+import { type Context, type Handler } from "aws-lambda";
|
|
|
+
|
|
|
+import config from "./config";
|
|
|
|
|
|
import { handler as chilecultura } from "./portales/chilecultura/handler";
|
|
|
import { handler as df } from "./portales/df/handler";
|
|
@@ -25,12 +27,26 @@ const context: Context = {
|
|
|
getRemainingTimeInMillis: () => 1
|
|
|
};
|
|
|
|
|
|
-const portals = [chilecultura, df, elciudadano, eldesconcierto, elmostrador, emol, interferencia, latercera, theclinic];
|
|
|
-const cooldown = 10000; // 10 seconds
|
|
|
+const portalsHandlers = {
|
|
|
+ "chilecultura": chilecultura,
|
|
|
+ "df": df,
|
|
|
+ "elciudadano": elciudadano,
|
|
|
+ "eldesconcierto": eldesconcierto,
|
|
|
+ "elmostrador": elmostrador,
|
|
|
+ "emol": emol,
|
|
|
+ "interferencia": interferencia,
|
|
|
+ "latercera": latercera,
|
|
|
+ "theclinic": theclinic,
|
|
|
+};
|
|
|
|
|
|
+const activePortalsHandlers: Array<Handler> = Object.keys(portalsHandlers)
|
|
|
+ .filter((portalName) => ! config.DEVELOP || config.DEV_ACTIVE_PORTALS.includes(portalName))
|
|
|
+ .map((portalName) => portalsHandlers[portalName]);
|
|
|
+
|
|
|
+const cooldown = 10000; // 10 seconds
|
|
|
async function main (): Promise<void> {
|
|
|
- for (const portal of portals) {
|
|
|
- await portal(null, context, () => {});
|
|
|
+ for (const portalHandler of activePortalsHandlers) {
|
|
|
+ await portalHandler(null, context, () => {});
|
|
|
await new Promise((resolve) => setTimeout(resolve, cooldown));
|
|
|
}
|
|
|
}
|