Skip to content

Instantly share code, notes, and snippets.

View ryanblock's full-sized avatar
:shipit:
Building stuff for @beginner-corp!

Ryan Block ryanblock

:shipit:
Building stuff for @beginner-corp!
View GitHub Profile
@ryanblock
ryanblock / arc-plugin.js
Last active January 28, 2022 22:30
arc 10 rc1 plugin outline
/**
* Assuming your app.arc includes:
* @plugins
* test-plugin
*
* This file would live in `src/plugins/test-plugin/index.js` or `src/plugins/test-plugin.js`
*/
// let { join } = require('path')
module.exports = {
@ryanblock
ryanblock / destroy-cloudwatch-logs.js
Last active February 27, 2021 15:31
Destroy CloudWatch logs
// I like using dotenv locally but that's up to you
// require('dotenv').config()
const aws = require('aws-sdk')
// eslint-disable-next-line
let logs = [
// Insert your logs here, eg '/aws/lambda/begin-production-foo',
]
const cloudwatchlogs = new aws.CloudWatchLogs()
@ryanblock
ryanblock / api-gateway-upgrade.js
Last active April 22, 2019 20:24
Arc API Gateway upgrade script
// I like using dotenv locally but that's up to you
require('dotenv').config()
const aws = require('aws-sdk')
const path = require('path')
const fs = require('fs')
const series = require('run-series')
const waterfall = require('run-waterfall')
const requestTemplate = fs.readFileSync(path.join(__dirname, 'node_modules', '@architect', 'architect', 'src', 'create', 'aws', 'create-http-route', 'create-route', '_request.vtl')).toString()
const requestFormPostTemplate = fs.readFileSync(path.join(__dirname, 'node_modules', '@architect', 'architect', 'src', 'create', 'aws', 'create-http-route', 'create-route', '_request-form-post.vtl')).toString()
const requestBinary = fs.readFileSync(path.join(__dirname, 'node_modules', '@architect', 'architect', 'src', 'create', 'aws', 'create-http-route', 'create-route', '_request-binary.vtl')).toString()
@ryanblock
ryanblock / example-begin-function.js
Created December 2, 2018 22:28
Example Begin cloud function
// This function is everything you need to build a Lambda-based app with Begin
exports.handler = async function http(req) {
return {
type: 'text/html; charset=utf8',
body: `<h1 class="center-text">Hello world!</h1>`
}
}
test('can list cats', async t=> {
t.plan(1)
let result = await data.cats.scan({})
t.ok(result, 'got result')
console.log(result)
})
test('can get /', async t=> {
t.plan(1)
let url = 'http://localhost:3333'
let result = await tiny.get({url})
t.ok(result.body, 'got a 200 response')
console.log(result.body)
})
let arc = require('@architect/architect')
let data = require('@architect/data')
let tiny = require('tiny-json-http')
let test = require('tape')
let end // save a ref
test('start sandbox', async t=> {
t.plan(1)
end = await arc.sandbox.start()
t.ok('started sandbox')
})
@ryanblock
ryanblock / arc-esm-00.js
Created November 13, 2018 05:49
Architect + ES Modules - example Lambda
const fs = require('fs')
const join = require('path').join
exports.handler = async function http(req) {
let module = req.params.module
let filePath = join(__dirname, 'node_modules', '@architect', 'views', module)
let exists = fs.existsSync(filePath)
if (exists) {
let file = fs.readFileSync(filePath).toString()
return {
type: 'text/javascript; charset=utf8',
@ryanblock
ryanblock / gist:b84edf9679b0e5ecc523596adaa19e76
Created October 22, 2018 03:04
Architect 4.0 HTTP code sample
// src/http/get-index/index.js
exports.handler = async function http(request) {
return {
type: 'text/html',
body: 'Hello world!' // 200 status by default
}
}

Keybase proof

I hereby claim:

  • I am ryanblock on github.
  • I am ryanblock (https://keybase.io/ryanblock) on keybase.
  • I have a public key whose fingerprint is 14F0 9ABC 90E5 7F55 0690 0056 6C27 888B 0369 8554

To claim this, I am signing this object: