36 lines
962 B
TypeScript
36 lines
962 B
TypeScript
import * as functions from "firebase-functions";
|
|
import Utils from "./utils";
|
|
import Day1 from "./day1";
|
|
import {Response} from "firebase-functions";
|
|
|
|
|
|
// // Start writing Firebase Functions
|
|
// // https://firebase.google.com/docs/functions/typescript
|
|
//
|
|
// export const helloWorld = functions.https.onRequest((request, response) => {
|
|
// functions.logger.info("Hello logs!", {structuredData: true});
|
|
// response.send("Hello from Firebase!");
|
|
// });
|
|
|
|
interface DayResult {
|
|
part1: string | number;
|
|
part2: string | number;
|
|
}
|
|
|
|
export const day = {
|
|
1: functions.region("europe-west1").https.onRequest((request, response) => {
|
|
|
|
const input = Utils.parseInput(request);
|
|
const part1 = Day1.part1(input);
|
|
const part2 = Day1.part2(input);
|
|
|
|
sendResponse(response, part1, part2);
|
|
|
|
}),
|
|
}
|
|
|
|
function sendResponse(response: Response, part1: string | number, part2: string | number) {
|
|
|
|
const res: DayResult = { part1, part2 };
|
|
response.send(res);
|
|
} |