Skip to content

Instantly share code, notes, and snippets.

View rts-rob's full-sized avatar
👋
Howdy

Rob Sutter rts-rob

👋
Howdy
View GitHub Profile
@rts-rob
rts-rob / isWidget.test.ts
Created November 29, 2021 18:22
Composing unit tests in FQL
// Copyright Fauna, Inc.
// SPDX-License-Identifier: MIT-0
import { IsWidget } from '../src/widget/lib';
// Test setup, etc.
test('Widgets are identified correctly', async () => {
const result = await faunaClient.query(
Let({
@rts-rob
rts-rob / docker-compose.yml
Last active August 17, 2022 02:34
Local development of Cloudflare Workers and Fauna with Fauna Dev and Miniflare
# Copyright Fauna, Inc.
# SPDX-License-Identifier: MIT-0
version: "3.9"
services:
fauna:
image: fauna/faunadb:latest
ports:
- "8443:8443"
- "8444:8444"
@rts-rob
rts-rob / Counter.json
Last active April 1, 2021 15:30
Increment a counter using Fauna and GraphQL
{
"counter": 0
}
@rts-rob
rts-rob / gfds.sh
Created July 9, 2020 14:47
Bash script to delete an AWS SAM/AWS CloudFormation stack
#!/bin/bash
aws cloudformation delete-stack \
--stack-name $@
@rts-rob
rts-rob / samout.sh
Created July 9, 2020 14:44
Bash script to get AWS SAM (and AWS CloudFormation) outputs
#!/bin/bash
aws cloudformation describe-stacks \
--stack-name $1 \
--query 'Stacks[].{Name: StackName, Outputs: Outputs}' "${@:2}"
@rts-rob
rts-rob / app.js
Created April 22, 2020 13:04
Export multiple functions
const ready = true;
exports.readyHandler = () => { return ready; };
exports.notReadyHandler = () => {return !ready; };
@rts-rob
rts-rob / main.go
Created March 19, 2020 21:15
Partial SAM template and partial Go function code for limiting access to GSIs in IAM
func (d *dependencies) handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
input := dynamodb.QueryInput{
ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{
":v1": {
S: aws.String(request.PathParameters[PathParameter]),
},
},
// hard-coded for proof of concept
IndexName: aws.String("SSN-index"),
@rts-rob
rts-rob / main.go
Last active March 17, 2020 21:50
Setting DynamoDB timeout to 100ms
package main
import (
"encoding/json"
"fmt"
"net/http"
"os"
"time"
"github.com/aws/aws-lambda-go/events"
@rts-rob
rts-rob / buildError.js
Created September 12, 2017 09:01
Helper function for building JSON errors.
function buildError(statusCode, message) {
const error = {
statusCode: statusCode,
body: JSON.stringify({
error: message
})
};
return error;
};
@rts-rob
rts-rob / promisePrototype.js
Last active September 12, 2017 09:02
Basic Promise-wrapped helper function framework
function promisePrototype(event) {
return new Promise(function(resolve, reject) {
if (success) {
resolve(someNewObject);
} else {
reject(buildError(500, "An internal error occured."));
}
});
}