-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nomad-badges): Digital Nomad program
- 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 0a8ce38
Showing
3 changed files
with
614 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 GitHub Actions / Build & Test
|
||
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 }), | ||
}; | ||
}; |
Oops, something went wrong.