-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.ru
More file actions
111 lines (96 loc) · 2.38 KB
/
config.ru
File metadata and controls
111 lines (96 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# -*- coding: utf-8 -*-
# gems
require 'rubygems'
require 'bundler'
Bundler.require
if ENV['RACK_ENV'] == 'production'
# production config / requires
else
# development or testing only
require 'pry'
require 'awesome_print'
use Rack::ShowExceptions
end
# require the dependencies
$LOAD_PATH.unshift(File.dirname(__FILE__))
require File.join(File.dirname(__FILE__), 'app', 'init')
require 'app/root'
require 'app/api_base'
require 'app/harp_api'
require 'app/harp_debug_api'
require 'app/harp_user_api'
require 'app/sample'
require 'app/editor'
require 'data_mapper'
require 'delayed_job_data_mapper'
if ENV['RACK_ENV'] == 'production'
# production config / requires
DataMapper::Logger.new($stdout, :info)
else
DataMapper::Logger.new($stdout, :debug)
end
DataMapper::Model.raise_on_save_failure = true # globally across all models
DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/dev.db")
require 'harp-runtime/models/base'
require 'harp-runtime/models/compute'
DataMapper.finalize
DataMapper.auto_upgrade!
Delayed::Worker.backend.auto_upgrade!
# Following are Swagger directives, for REST API documentation.
##~ sapi = source2swagger.namespace("harp-runtime")
##~ sapi.swaggerVersion = "1.2"
##~ sapi.apiVersion = "0.1.0"
##~ auth = sapi.authorizations.add :apiKey => { :type => "apiKey", :passAs => "header" }
#
# Harp Debug API
#
##~ a = sapi.apis.add
##
##~ a.set :path => "/harp-debug.{format}", :format => "json"
##~ a.description = "Harp runtime invocation for debugging."
map "/api/v1/harp-debug" do
run HarpDebugApiApp
end
#
# Harp API
#
##~ a = sapi.apis.add
##
##~ a.set :path => "/harp.{format}", :format => "json"
##~ a.description = "Harp runtime invocation"
map "/api/v1/harp" do
run HarpApiApp
end
#
# Harp User API
#
##~ a = sapi.apis.add
##
##~ a.set :path => "/user.{format}", :format => "json"
##~ a.description = "Harp User API"
map "/api/v1/user" do
run HarpUserApiApp
end
# Sample API
#
##~ a = sapi.apis.add
##
##~ a.set :path => "/sample"
##~ a.description = "API for sample Harp scripts"
map "/api/v1/sample" do
run SampleApp
end
map "/edit" do
run EditorApp
end
# Serve swagger-ui from bower directory
map "/swagger-ui" do
run Rack::Directory.new("./bower_components/swagger-ui/dist")
end
# Serve swagger-ui from bower directory
map "/bower_components" do
run Rack::Directory.new("./bower_components")
end
map '/' do
run RootApp
end