Skip to content

Instantly share code, notes, and snippets.

View aaronksaunders's full-sized avatar

Aaron K Saunders aaronksaunders

View GitHub Profile
@aaronksaunders
aaronksaunders / app.js
Last active August 29, 2015 14:03
Appcelerator Cloud Services, Promises and Custom Objects
//
//
var Q = require('q'); // add q.js library - https://github.com/kriskowal/q
var Cloud = require("ti.cloud"); // add in tiapp.xml
Cloud.debug = true;
function cloudCreateObjects(_data) {
var deferred = Q.defer();
@aaronksaunders
aaronksaunders / userService.js
Created July 27, 2014 17:34
Work In Progress, full blog post forthcoming - UserService for Firebase and IonicFramework App I am working - Aaron Saunders Clearly Innovative Inc - http://www.clearlyinnovative.com/blog/post/tag/ionic-framework
// UserService.js
//
// Aaron K Saunders
// Clearly Innovative Inc
//
// http://www.clearlyinnovative.com/blog/post/tag/ionic-framework
//
/*global Firebase*/
(function(angular) {
'use strict';
$.getView().open();
// set the sync adapter
Alloy.Backbone.sync = function(method, model, opts) {
require("alloy/sync/properties").sync(method, model, opts);
};
// createing a model now just requires the collection_name field
function createCountryModel(_collection_name) {
//
// Project-Bridging-Header.h
// networkingtestApp
//
// Created by Aaron Saunders on 10/31/14.
// Copyright (c) 2014 Aaron Saunders. All rights reserved.
//
#ifndef networkingtestApp_Project_Bridging_Header_h
#define networkingtestApp_Project_Bridging_Header_h
@aaronksaunders
aaronksaunders / 1) instructions.md
Last active August 29, 2015 14:12
Packaging up an Angular JS App to Run in Node.ACS Environment from Appcelerator

Deploying an AngularJS Application to node.acs

###Follow the instructions below these instructions assume you used Grunt to create the basic project structure and are packaging the app for deployment using grunt build:dist

  1. Enter the grunt command to build the application from project root grunt build:dist

  2. Enter the following commands to copy needed files to dist directory, this assumes you placed them in a folder called acs_deploy

@aaronksaunders
aaronksaunders / snippet.js
Last active August 29, 2015 14:12
Saving custom object with photo in Appcelerator Cloud Services with Angular JS
//
// Angular JS documentation on $http Service
// https://docs.angularjs.org/api/ng/service/$http
//
// Referenced Blog Post
// http://uncorkedstudios.com/blog/multipartformdata-file-upload-with-angularjs
//
// Appcelerator Cloud Services Documentation - Photos & Custom Objects
// http://docs.appcelerator.com/cloud/latest/#!/api/Photos
// http://docs.appcelerator.com/cloud/latest/#!/api/CustomObjects
config.json
reading-image.png

This is an example of how to scaffold API endpoints to list / get / create / update / delete Posts in a Keystone website.

It's a modification of the default project created with the yo keystone generator (see https://github.com/JedWatson/generator-keystone)

Gists don't let you specify full paths, so in the project structure the files would be:

routes-index.js        -->    /routes/index.js         // modified to add the api endpoints
routes-api-posts.js    -->    /routes/api/posts.js     // new file containing the Post API route controllers

To implement API authentication in KeystoneJS, you need the following:

For key based authentication

  • Middleware that validates the key in the request body or a header

For session based authentication

  • An endpoint that handles signin
  • An endpoint that handles signout