Skip to content

Instantly share code, notes, and snippets.

View brianneisler's full-sized avatar
🏠
Working from home

Brian Neisler brianneisler

🏠
Working from home
View GitHub Profile
@brianneisler
brianneisler / renameFunction.js
Created July 20, 2021 02:51
How to rename a function in firemin
import { assocNodePath, findNodeInTree, findNodePathInTree } from 'firetree'
import { createIdentifier } from 'firetree/parser/pipes'
import { Identifier } from 'firetree/parser/tokens'
import { List } from 'immutable'
import { propEq } from 'ramda'
import { measure } from '../../utils'
const renameFunction = measure(
(context, ast, functionId) => `renameFunction:${functionId}`,
@brianneisler
brianneisler / functionCurryN.js
Created January 21, 2019 00:51
functionCurryN
const functionCurry1 = (func) => {
return function f1(arg0, ...rest) {
if (arguments.length === 0) {
throw new Error('curried method called with no arguments')
}
if (anyIsPlaceholder(arg0)) {
if (rest.length > 0) {
throw new Error('use of a placeholder with additional arguments is not supported')
}
return f1

Single service that processes an image when added to a bucket

name: ImageProcessor
extends: Service

providers:
  aws:
    type: AWSProvider
    inputs:
@brianneisler
brianneisler / serverless.yml (AuthService)
Last active October 18, 2018 20:25
In Serverless Framework v2, serverless.yml is a class declaration
name: AuthService
extends: Service
props....
@brianneisler
brianneisler / serverless.yml
Last active January 22, 2019 19:04
Changing function's compute to Fargate
name: SimpleService
extends: Service
compute:
type: AwsFargateCompute # switched from AwsLambdaCompute
inputs:
runtime: nodejs
memory: 1024
timeout: 3600
@brianneisler
brianneisler / serverless.yml
Last active October 13, 2018 19:47
General serverless function abstractions
name: SimpleService
extends: Service
compute:
type: AwsLambdaCompute
inputs:
provider: ${inputs.providers.aws}
runtime: nodejs
functions:

Usage

  1. Create a new Serverless service and change into the directory.
serverless create --template hello-world
  1. Install the plugin: (needs Node version 7+)
@brianneisler
brianneisler / promiseMiddleware.js
Created March 2, 2018 06:02
Promise Middleware
import isPromise from 'is-promise';
const defaultTypes = ['PENDING', 'FULFILLED', 'REJECTED'];
export default function promiseMiddleware() {
return ({dispatch, getState}) => {
return next => action => {
if (typeof action === 'function') {
return action(dispatch, getState);
}

Examples

REST API

Platform

service:
  name: my-service
  provider: aws   # default for all functions in the service
@brianneisler
brianneisler / initial-setup.md
Last active July 30, 2018 16:39
Workshop - Setting Up the Serverless Framework

Initial Setup

End Results

  • Should have node 8.11.3 or later installed
  • Should have a new AWS IAM User with full admin privileges
  • Should have a text editor installed
  • Should have the serverless framework installed
  • Should have your AWS credentials configured in serverless

Install node js and NPM