Skip to content

Instantly share code, notes, and snippets.

View brianleroux's full-sized avatar
💚
You are now aware that you are breathing

Brian LeRoux brianleroux

💚
You are now aware that you are breathing
View GitHub Profile
@brianleroux
brianleroux / src-html-get-index-index.js
Last active August 24, 2018 21:50
a function that returns text/javascript esmodules; a function that renders an html page..
let begin = require('@architect/functions')
function index(req, res) {
let html = `<script type=module src=/js/entry.mjs></script>`
res({html})
}
exports.handler = begin.html.get(route)
@brianleroux
brianleroux / .arc
Created July 3, 2018 19:40
scheduled function w .arc
@app
test-app
@scheduled
test-fn rate(5 minutes)
@brianleroux
brianleroux / .arc
Created February 8, 2018 18:59 — forked from mandeluna/.arc
# this is an .arc file!
@app
hellobot
@html
get / # displays Add to Slack
get /install # saves a bot token and redirects back to /
get /signin # saves a user token and redirects back to /
@slack
@brianleroux
brianleroux / index.js
Created February 6, 2018 19:09
src/slack/bot-actions/index.js
exports.handler = function actions(event, context, callback) {
console.log(JSON.stringify(event, null, 2))
callback(null, {text:'hi from button press'})
}
@brianleroux
brianleroux / index.js
Created February 6, 2018 19:04
src/slack/bot-slash/index.js
exports.handler = function slash(event, context, callback) {
callback(null, {
text: 'Hello!',
attachments: [{
text: 'Click the button',
fallback: 'Click the button',
callback_id: 'clicky',
color: '#eheheh',
actions: [{
name: 'hello',
@brianleroux
brianleroux / install.js
Created February 2, 2018 23:20
Middleware that persists Add to Slack token
var data = require('../data')
var waterfall = require('run-waterfall')
var slack = require('slack')
module.exports = function install(req, res, next) {
let location = req._url('/')
if (req.query.code) {
waterfall([
function read(callback) {
slack.oauth.access({
@brianleroux
brianleroux / index.js
Created February 2, 2018 23:16
magic dynamodb data access layer client using @architect/data within src/shared
var path = require('path')
var arc = require('@architect/data')
var arcPath = path.join(__dirname, '..', '.arc')
module.exports = arc(arcPath)
@app
hellobot
@events
long-running-thing
@html
get / # displays Add to Slack
get /install # saves a bot token and redirects back to /
get /signin # saves a user token and redirects back to /
module.exports = function addToSlack() {
let scope = 'commands,bot'
let clientID = process.env.SLACK_CLIENT_ID
let redirect = process.env.SLACK_INSTALL_REDIRECT
let href = `https://slack.com/oauth/authorize?scope=${scope}&client_id=${clientID}&redirect_uri=${redirect}`
return `
<a href=${href}>
<img alt="Add to Slack"
height="40"
width="139"
@brianleroux
brianleroux / fixed-index.js
Created February 2, 2018 22:38
Passing req._url into a template.
const arc = require('@architect/functions')
const layout = require('@architect/shared/views/bootstrap')
function route(req, res) {
let html = layout({
_url: req._url,
title: 'My App',
body: `
<div class=jumbotron>
<h1 class=display-4>Add to Slack</h1>