-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Faye server to send websocket updates to front-end
- Loading branch information
Showing
19 changed files
with
211 additions
and
65 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
module CodePraise | ||
class Api < Roda | ||
# Represent HTTP response for result | ||
# Parameters: | ||
# - result: Result object with #message to represent | ||
# - success_representer: representer class if result is success | ||
# #to_json called if result is failure | ||
# - (optional) block to execute before success representation | ||
# Returns: Json representation of success/failure message | ||
def represent_response(result, success_representer) | ||
http_response = HttpResponseRepresenter.new(result.value) | ||
response.status = http_response.http_code | ||
if result.success? | ||
yield if block_given? | ||
success_representer.new(result.value.message).to_json | ||
else | ||
http_response.to_json | ||
end | ||
end | ||
|
||
# Extracts sub-resource path from request | ||
# Parameters: HTTP request (Roda request object) | ||
# Returns: folder path (string) | ||
def folder_name_from(request) | ||
path = request.remaining_path | ||
path.empty? ? '' : path[1..-1] | ||
end | ||
end | ||
end |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative 'collaborator_representer' | ||
|
||
# Represents essential Repo information for API output | ||
module CodePraise | ||
class CloneRequestRepresenter < Roar::Decorator | ||
include Roar::JSON | ||
|
||
property :repo, extend: RepoRepresenter, class: OpenStruct | ||
property :id | ||
end | ||
end |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'faye' | ||
require_relative './init.rb' | ||
|
||
use Faye::RackAdapter, :mount => '/faye', :timeout => 25 | ||
run CodePraise::Api.freeze.app |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
--- | ||
development: | ||
API_URL: 'http://localhost:3030' | ||
DB_FILENAME: infrastructure/database/dev.db | ||
REPOSTORE_PATH: infrastructure/gitrepo/repostore | ||
|
||
test: | ||
API_URL: 'http://localhost:3000' | ||
DB_FILENAME: infrastructure/database/test.db | ||
REPOSTORE_PATH: infrastructure/gitrepo/repostore | ||
|
||
app_test: | ||
API_URL: 'http://localhost:3000' | ||
DB_FILENAME: infrastructure/database/test.db | ||
REPOSTORE_PATH: infrastructure/gitrepo/repostore | ||
|
||
production: | ||
API_URL: 'https://codepraise-api.herokuapp.com' | ||
REPOSTORE_PATH: infrastructure/gitrepo/repostore |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module CodePraise | ||
CloneRequest = Struct.new :repo, :id | ||
end |
This file contains 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
This file contains 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
Oops, something went wrong.