Skip to content

Instantly share code, notes, and snippets.

View lewisdaly's full-sized avatar

Lewis Daly lewisdaly

View GitHub Profile
@lewisdaly
lewisdaly / install.sh
Last active July 23, 2018 10:31
Apollo Server + Serverless setup guide
#install global nodeyness
npm install -g serverless
serverless create --template aws-nodejs --path al_serverless
cd al_serverless
#local dependencies for apollo and stuff
npm install --save apollo-server-lambda graphql-tools lodash
/**
* refer here:
* https://github.com/lewisdaly/iota_mam_examples/
* for the rest of the code examples
*/
declare var require: any
const Mam = require('../lib/mam.node.js');
const IOTA = require('iota.lib.js');
@lewisdaly
lewisdaly / subscriber_01.ts
Created May 11, 2018 06:20
A simple IOTA MAM Subscriber
declare var require: any
declare var process: {
env: {
ROOT: string
}
}
var Mam = require('../lib/mam.node.js')
var IOTA = require('iota.lib.js')
const IOTA = require('iota.lib.js');
const MAM = require('./lib/mam.client.js/lib/mam.client');
var iota = new IOTA({ provider: `https://testnet140.tangle.works` });
const five = require("johnny-five");
const board = new five.Board();
// Initialise MAM State - PUBLIC
var mamState = MAM.init(iota)
const IOTA = require('iota.lib.js');
const MAM = require('./lib/mam.client.js/lib/mam.client');
var iota = new IOTA({ provider: `https://testnet140.tangle.works` })
const five = require("johnny-five");
const board = new five.Board();
// Initialise MAM State - PUBLIC
/*iota library */
const IOTA = require('iota.lib.js');
const {
provider,
functionName,
trytes //todo: remove
} = require('./config');
//Please don't ever use this seed for anything
const seed = "UFLKWXVHYTPDBAOJS9CQMGNRZEI";
/*iota library */
const IOTA = require('iota.lib.js');
const { provider, functionName } = require('./config');
const iota = new IOTA({
provider,
});
/* set up AWS config to refer to our lambda */
const AWS = require('aws-sdk');
const lambda = new AWS.Lambda({
region: 'ap-southeast-2' //I come from a land down under
@lewisdaly
lewisdaly / serverless.yml
Created May 25, 2018 05:41
Apollo Server + serverless example
service: apollo-lambda
provider:
name: aws
runtime: nodejs6.10
region: ap-southeast-2
stage: development
functions:
graphql:
handler: handler.graphql
events:
'use strict';
const server = require("apollo-server-lambda");
const schema = require('./schema');
exports.graphql = server.graphqlLambda((event, context) => {
const headers = event.headers;
const functionName = context.functionName;
return {
schema: schema,