This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "net/http" | |
| "os" | |
| "app/api" | |
| "app/db" | |
| "app/repo" | |
| "app/worker" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package workers | |
| import ( | |
| "app/repo" | |
| "app/ws" | |
| "github.com/bitly/go-nsq" | |
| ) | |
| /* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package repo | |
| import ( | |
| "gopkg.in/mgo.v2" | |
| "app/db" | |
| "app/model" | |
| ) | |
| /** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package db | |
| import ( | |
| "errors" | |
| "gopkg.in/mgo.v2" | |
| ) | |
| /* | |
| Mongo construction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package model | |
| import ( | |
| "net/http" | |
| "time" | |
| "github.com/mholt/binding" | |
| "gopkg.in/mgo.v2/bson" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react'; | |
| import HighCharts from 'highcharts'; | |
| export default class Chart extends Component { | |
| componentDidMount() { | |
| if (this.props.modules) { | |
| this.props.modules.forEach(module => { | |
| module(HighCharts); | |
| }); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function (user, context, callback) { | |
| var namespace = 'your_domain'; | |
| context.idToken[namespace + 'app_metadata'] = user.app_metadata; | |
| context.idToken[namespace + 'user_metadata'] = user.user_metadata; | |
| callback(null, user, context); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import mqtt from 'mqtt'; | |
| export function mqclient(options) { | |
| return new Promise((resolve, reject) => { | |
| fetch('https://your-lambda-endpoint', { | |
| method: 'get' | |
| }).then((response) => { | |
| const client = mqtt.connect(response.body.url, options); | |
| resolve(client); | |
| }).catch(err => reject(err)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| const v4 = require('aws-signature-v4'); | |
| const crypto = require('crypto'); | |
| exports.handler = (event, context, callback) => { | |
| const url = v4.createPresignedURL( | |
| 'GET', | |
| process.env.IOT_ENDPOINT_HOST.toLowerCase(), | |
| '/mqtt', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var awsIot = require('aws-iot-device-sdk'); | |
| var device = awsIot.device({ | |
| keyPath: "./private.key", | |
| certPath: "./cert.pem", | |
| caPath: "./root-CA.crt", | |
| clientId: "name-of-thing", | |
| host: "https-endpoint", | |
| }); |