Skip to content

Commit

Permalink
feat(nomad-badges): Digital Nomad program
Browse files Browse the repository at this point in the history
- putBadges for level1,2,3,4
- sendmail for level1,2,3,4
- incremental levels 1 by 1, no skipping each level

for thematters/matters-server#3721
  • Loading branch information
Ubuntu authored and Ubuntu committed Dec 7, 2023
1 parent d26b7d2 commit 1e166cf
Show file tree
Hide file tree
Showing 3 changed files with 460 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bin/check-nomad-badge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env -S node --trace-warnings --loader ts-node/esm

import { checkNomadBadge } from "../lib/check-nomad-badge.js";

async function main() {
const args = process.argv.slice(2);

await checkNomadBadge();
}

main().catch((err) => console.error(new Date(), "ERROR:", err));
42 changes: 42 additions & 0 deletions handlers/check-nomad-badge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Context, APIGatewayProxyResult, APIGatewayEvent } from "aws-lambda";
import { checkNomadBadge } from "../lib/check-nomad-badge.js";

export const handler = async (
event: APIGatewayEvent & {
campaignTagIds?: number[];
campaignBegins?: Date | string;
campaignEnds?: Date | string;
},
context: Context
): Promise<APIGatewayProxyResult> => {
console.log(`Event:`, event);
console.log(`Context:`, context);

const { method, path } = (event?.requestContext as any)?.http || {};

Check warning on line 15 in handlers/check-nomad-badge.ts

View workflow job for this annotation

GitHub Actions / Build & Test

'method' is assigned a value but never used

Check warning on line 15 in handlers/check-nomad-badge.ts

View workflow job for this annotation

GitHub Actions / Build & Test

Unexpected any. Specify a different type
if (
!(
path === "/refresh" &&
event?.headers?.accept?.includes("application/json")
)
) {
return {
statusCode: 400,
body: JSON.stringify({
error:
"input error, call with POST /refresh with accept: application/json",
}),
};
}

const { campaignTagIds, campaignBegins, campaignEnds } = event;
const retBadges = await checkNomadBadge({
campaignTagIds,
campaignBegins,
campaignEnds,
});

return {
statusCode: 200,
body: JSON.stringify({ message: "done.", retBadges }),
};
};
Loading

0 comments on commit 1e166cf

Please sign in to comment.