This file contains hidden or 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
service: sls-oncall | |
provider: | |
name: aws | |
runtime: nodejs14.x | |
stage: ${opt:stage, 'dev'} | |
region: ${opt:region, 'eu-west-1'} | |
timeout: 10 | |
memorySize: 256 | |
logRetentionInDays: 14 |
This file contains hidden or 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
const { readFile } = require('fs').promises; | |
const mjml = require('mjml'); | |
const i18n = require('i18n'); | |
const htmlToText = require('html-to-text'); | |
const assert = require('assert'); | |
const mustache = require('mustache'); | |
const AWS = require('aws-sdk'); | |
i18n.configure({ | |
directory: `${process.cwd()}/locales`, |
This file contains hidden or 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
EventsSNS: | |
Type: AWS::SNS::Topic | |
Properties: | |
TopicName: sam-pigeon-events | |
Subscription: | |
- Endpoint: !GetAtt EventsQueue.Arn | |
Protocol: sqs | |
EventsQueue: | |
Type: AWS::SQS::Queue |
This file contains hidden or 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
SendLambda: | |
Type: AWS::Serverless::Function | |
Properties: | |
CodeUri: src/send-mail/ | |
Description: Polls SQS, builds email, sends to SES | |
MemorySize: 256 | |
Policies: | |
- SQSPollerPolicy: | |
QueueName: !GetAtt ApiQueue.QueueName | |
- SESCrudPolicy: |
This file contains hidden or 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
ApiGateway: | |
Type: AWS::Serverless::Api | |
Properties: | |
StageName: !Ref Stage | |
DefinitionBody: | |
swagger: "2.0" | |
info: | |
title: !Ref AWS::StackName | |
x-amazon-apigateway-request-validators: | |
body-only: |
This file contains hidden or 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
const tokenIntrospection = require('token-introspection'); | |
const createError = require('http-errors'); | |
const wrap = (fn) => (...args) => fn(...args).catch(args[2]); | |
const introspectMiddleware = (opts = {}) => { | |
const introspect = tokenIntrospection(opts); | |
return wrap(async (req, res, next) => { | |
try { |
This file contains hidden or 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
const tokenIntrospection = require('token-introspection')({ | |
jwks_uri: 'https://example.com/jwks', | |
endpoint: 'https://example.com/introspect', | |
client_id: 'client-id', | |
client_secret: 'client-secret', | |
}); | |
tokenIntrospection(token).then(console.log).catch(console.warn); |
This file contains hidden or 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
const tokenIntrospection = require('token-introspection'); | |
const crypto = require('crypto'); | |
const createError = require('http-errors'); | |
const throwIfTrue = require('throw-if-true'); | |
const Cache = require('../lib/cache'); | |
const wrap = require('../lib/routeWrapper'); | |
const logger = require('../lib/logger'); | |
const cache = new Cache(); |
This file contains hidden or 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
console.log(process.argv[2].split('').filter((e, i, a) => e === a[(i + 1) % a.length]).reduce((s, c) => s + +c, 0)); |