-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { DynamoDBClient } from '@aws-sdk/client-dynamodb'; | ||
import { SESClient } from '@aws-sdk/client-ses' | ||
import { AwsUtil } from '../app/code/AwsUtil'; | ||
import { handleReporting } from './reportRequestHandler'; | ||
|
||
const dynamoDBClient = new DynamoDBClient({region: 'eu-west-1'}); | ||
const sesClient = new SESClient({region: 'eu-west-1'}); | ||
let recipients: string[] = []; | ||
|
||
async function init() { | ||
if(!process.env.RECIPIENTS_LIST){ | ||
throw Error("process.env.RECIPIENTS_LIST not set!"); | ||
} | ||
const util = new AwsUtil(); | ||
const recipientsList = await util.getParameter(process.env.RECIPIENTS_LIST); | ||
recipients = recipientsList ? recipientsList.split('\n') : []; | ||
} | ||
|
||
const initialization = init(); | ||
|
||
exports.handler = async () => { | ||
try { | ||
await initialization; | ||
await handleReporting(sesClient, dynamoDBClient, recipients); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{{>header}} | ||
|
||
<main> | ||
<!-- START: template component(s) --> | ||
<div class="container" id="section-1"> | ||
<h1>{{name}} Opladen</h1> | ||
<p class="lead">Login met DigiD en laad uw gegevens in de {{name}} app.</p> | ||
<a href="{{{authUrl}}}" class="btn btn-primary waves-effect waves-light display-table"> | ||
<span class="title"> Inloggen </span><span class="assistive">via DigiD</span> | ||
</a> | ||
</div> | ||
</div> | ||
|
||
<!-- END: template component(s) --> | ||
</main> | ||
|
||
{{>footer}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { DynamoDBClient } from '@aws-sdk/client-dynamodb'; | ||
import { SESClient, SendEmailCommand } from '@aws-sdk/client-ses' | ||
import Mustache from 'mustache'; | ||
import template from './report.mustache'; | ||
|
||
export async function handleReporting(sesClient: SESClient, dynamoDBClient: DynamoDBClient, recipients: string[]){ | ||
|
||
console.log(dynamoDBClient.config.apiVersion); | ||
// Do dynamodb query (yesterday) | ||
// Do dynamodb query (this month) | ||
// Do dynamodb query (this year) | ||
// calculate statistics | ||
// Calculate nr of issuances with same bsn | ||
|
||
const data = {}; // TODO fill with statistics from above. | ||
|
||
const report = renderReport(data); | ||
await sendReportViaMail(sesClient, report, recipients); | ||
|
||
} | ||
|
||
function renderReport(data: any) { | ||
return Mustache.render(template, data); | ||
} | ||
|
||
async function sendReportViaMail(client: SESClient, body: string, recipients: string[]) { | ||
|
||
const sendEmail = new SendEmailCommand({ | ||
Destination: { | ||
ToAddresses: recipients, | ||
}, | ||
Message: { | ||
Subject: { | ||
Charset: 'UTF-8', | ||
Data: 'IRMA Issue Statistics', | ||
}, | ||
Body: { | ||
Html: { | ||
Charset: "UTF-8", | ||
Data: body | ||
}, | ||
}, | ||
}, | ||
Source: 'gemeente@accp.csp-nijmegen.nl' | ||
}); | ||
|
||
await client.send(sendEmail) | ||
|
||
} |