Skip to content

Instantly share code, notes, and snippets.

View mmetting's full-sized avatar

mmetting

View GitHub Profile
@mmetting
mmetting / application.js
Created June 1, 2017 08:23
Add the /alexa endpoint
var mbaasApi = require('fh-mbaas-api');
var express = require('express');
var mbaasExpress = mbaasApi.mbaasExpress();
var cors = require('cors');
// list the endpoints which you want to make securable here
var securableEndpoints;
securableEndpoints = ['/hello', '/feeds', '/alexa'];
var app = express();
@mmetting
mmetting / package.json
Created June 1, 2017 09:04
Include the ASK
{
"name": "helloworld-cloud",
"version": "0.2.0",
"dependencies": {
"alexa-sdk": "^1.0.9",
"aws-lambda-mock-context": "^3.1.0",
"body-parser": "~1.0.2",
"cors": "~2.2.0",
"express": "~4.0.0",
"fh-mbaas-api": "6.1.5",
@mmetting
mmetting / alexa.js
Created June 1, 2017 09:05
Implementing our Skill
var express = require('express');
var bodyParser = require('body-parser');
var cors = require('cors');
const LambdaMockContext = require('aws-lambda-mock-context');
const Alexa = require('alexa-sdk');
function alexaRoute() {
var alexa = new express.Router();
alexa.use(cors());
@mmetting
mmetting / hello.js
Created June 21, 2017 15:32
Change /hello endpoint to use $fh.db to store string in MongoDB
var $fh = require('fh-mbaas-api');
var options = {
"act": "create",
"type": "myFirstEntity",
"fields": {
"name": world
}
};
@mmetting
mmetting / hello.js
Created June 21, 2017 15:33
Add a timestamp to each entry being inserted
var timestamp = new Date().getTime()
var options = {
"act": "create",
"type": "myFirstEntity",
"fields": {
"name": world,
"timestamp": timestamp
}
};
@mmetting
mmetting / hello.js
Last active June 21, 2017 15:37
Move DB logic from cloud app to Service
var express = require('express');
var bodyParser = require('body-parser');
var cors = require('cors');
var $fh = require('fh-mbaas-api');
function helloRoute() {
var hello = new express.Router();
hello.use(cors());
hello.use(bodyParser());
@mmetting
mmetting / hello.js
Created June 21, 2017 15:38
In cloud app, use $fh.service API to call service
var express = require('express');
var bodyParser = require('body-parser');
var cors = require('cors');
var $fh = require('fh-mbaas-api');
function helloRoute() {
var hello = new express.Router();
hello.use(cors());
hello.use(bodyParser());
@mmetting
mmetting / hello.js
Last active June 21, 2017 15:42
Return DB response from service to cloud, and then from cloud to client (Cloud App)
var $fh = require('fh-mbaas-api');
$fh.service({
"guid": "jfi5oop5vbxmvfcfkef4qyyz",
"path": "/hello",
"method": "GET",
"params": {
"hello": world
},
"timeout": 25000
@mmetting
mmetting / hello.js
Created June 21, 2017 15:43
Return DB response from service to cloud, and then from cloud to client (MBaaS Service)
var $fh = require('fh-mbaas-api');
var timestamp = new Date().getTime();
var options = {
"act": "create",
"type": "myFirstEntity",
"fields": {
"name": world,
"timestamp": timestamp
@mmetting
mmetting / hello.js
Created June 21, 2017 15:46
Only add unique Name values to DB (list)
var $fh = require('fh-mbaas-api');
var readOptions = {
"act": "list",
"type": "myFirstEntity",
"eq": {
"name": world
}
};