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
// REST API Client Definition | |
var apiClient = (function() { | |
var ajax = function(url, type, callback, data) { | |
var config = { | |
dataType: 'json', | |
error: function(xhr, status, text) { | |
return callback({ | |
xhr: xhr, | |
status: status, |
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
// Node.js Server: RMM Level Two | |
var express = require('express') | |
, http = require('http') | |
, path = require('path') | |
, store = require("./store").store; | |
var app = express(); | |
app.use(express.bodyParser()); |
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
# TODO_API.README | |
## Retrieve a list of todos | |
### Example request: | |
GET http://api.example.com/v1/todos | |
Content-Type: application/json; | |
### Example response |
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
+---------------------------------------------------------------+ | |
| PATH | VERB | NOTE | | |
+------------+--------+-----------------------------------------+ | |
| /todos | GET | Retrieve a list of todos | | |
| /todos | POST | Create a new todo | | |
| /todos/:id | PUT | Replace the todo with the provided todo | | |
| /todos/:id | DELETE | Delete the todo | | |
+------------+--------+-----------------------------------------+ |
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
# config/initializers/services.rb | |
require 'barrister-rails' | |
require 'barrister-redis' | |
class Services | |
# ... | |
def self.proxy_services |
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
# services/mail_service/main.rb | |
require 'barrister-sinatra' | |
opts = { | |
mount_path: '/api', | |
port: ENV['PORT'] | |
} | |
Barrister::SinatraContainer.new('./interface.json', MailService.new, opts).start |
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
# Procfile | |
web: bundle exec rails s -p $PORT | |
mail_service: sh -c 'cd services/mail_service; ./main.rb' | |
user_service: sh -c 'cd services/user_service; ./main.rb' |
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
# config/initializers/services.rb | |
require 'barrister-rails' | |
require 'barrister-redis' | |
class Services | |
# ... | |
def self.proxy_services |
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
# services/user_service/main.rb | |
require 'activerecord' | |
require 'barrister-redis' | |
# establish a connection to the database | |
db_config = YAML.load(ERB.new(File.read('../../config/database.yml')).result) | |
ActiveRecord::Base.establish_connection db_config[ENV['RACK_ENV'] || 'development'] | |
# create our MailService proxy |
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
# services/mail_service/main.rb | |
require 'barrister-redis' | |
opts = { | |
database_url: ENV['OPENREDIS_URL'], | |
list_name: 'mail_service' | |
} | |
Barrister::RedisContainer.new('./interface.json', MailService.new, opts).start |