sumomo 0.8.3 → 0.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +169 -0
- data/Gemfile +2 -0
- data/Rakefile +5 -3
- data/bin/console +4 -3
- data/data/sumomo/api_modules/node_modules/.bin/uuid +1 -1
- data/data/sumomo/api_modules/real_script.js +37 -1
- data/data/sumomo/api_modules/test_script.js +212 -175
- data/data/sumomo/custom_resources/AMILookup.js +146 -58
- data/data/sumomo/custom_resources/Echo.js +25 -0
- data/data/sumomo/custom_resources/SelectSpot.js +142 -54
- data/data/sumomo/custom_resources/TempS3Bucket.js +213 -0
- data/data/sumomo/custom_resources/USEastCertificate.js +44 -31
- data/data/sumomo/custom_resources/USEastCertificateWaiter.js +60 -0
- data/exe/sumomo +50 -41
- data/lib/sumomo.rb +236 -233
- data/lib/sumomo/api.rb +148 -151
- data/lib/sumomo/cdn.rb +119 -113
- data/lib/sumomo/dns.rb +20 -20
- data/lib/sumomo/ec2.rb +490 -491
- data/lib/sumomo/ecs.rb +256 -262
- data/lib/sumomo/irregular.rb +9 -0
- data/lib/sumomo/momo_extensions/resource.rb +8 -7
- data/lib/sumomo/momo_extensions/stack.rb +4 -3
- data/lib/sumomo/network.rb +109 -106
- data/lib/sumomo/stack.rb +191 -189
- data/lib/sumomo/version.rb +3 -1
- data/sumomo.gemspec +23 -22
- metadata +27 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 85ea8b9717493794761cd6651e7595ea4056994972508fd8af43965852a7a653
|
4
|
+
data.tar.gz: 5ceac9bf30af9b4e632a680bb0c414daca770b05c35ed5fd1aa29700f5227a51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdf4b4055e84d51971a94a479830bb3cc5e8bfdab565fec391db7bca5426e720489b5a7f95e4da899c2a9ebfead5ea120e2873efb544f38c549b53584cf668f9
|
7
|
+
data.tar.gz: d819e57bec186f3e3c08a54b50f379ade66b9e9cc5e4b362ba427e0c12ac85a0ddcde969d9aa2ee89b407fd41a42c16679559a9448df92a426c2b898287d2766
|
data/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2019-11-05 10:31:48 +0900 using RuboCop version 0.76.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 4
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity.
|
12
|
+
# SupportedStylesAlignWith: keyword, variable, start_of_line
|
13
|
+
Layout/EndAlignment:
|
14
|
+
Exclude:
|
15
|
+
- 'exe/sumomo'
|
16
|
+
- 'lib/sumomo/ec2.rb'
|
17
|
+
- 'lib/sumomo/ecs.rb'
|
18
|
+
|
19
|
+
# Offense count: 3
|
20
|
+
Lint/AmbiguousBlockAssociation:
|
21
|
+
Exclude:
|
22
|
+
- 'lib/sumomo/ec2.rb'
|
23
|
+
- 'lib/sumomo/ecs.rb'
|
24
|
+
|
25
|
+
# Offense count: 2
|
26
|
+
Lint/ParenthesesAsGroupedExpression:
|
27
|
+
Exclude:
|
28
|
+
- 'lib/sumomo/api.rb'
|
29
|
+
|
30
|
+
# Offense count: 11
|
31
|
+
# Cop supports --auto-correct.
|
32
|
+
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
|
33
|
+
Lint/UnusedMethodArgument:
|
34
|
+
Exclude:
|
35
|
+
- 'lib/sumomo.rb'
|
36
|
+
- 'lib/sumomo/ec2.rb'
|
37
|
+
|
38
|
+
# Offense count: 3
|
39
|
+
Lint/UselessAssignment:
|
40
|
+
Exclude:
|
41
|
+
- 'exe/sumomo'
|
42
|
+
- 'lib/sumomo/ecs.rb'
|
43
|
+
- 'lib/sumomo/stack.rb'
|
44
|
+
|
45
|
+
# Offense count: 15
|
46
|
+
Metrics/AbcSize:
|
47
|
+
Max: 137
|
48
|
+
|
49
|
+
# Offense count: 10
|
50
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
51
|
+
# ExcludedMethods: refine
|
52
|
+
Metrics/BlockLength:
|
53
|
+
Max: 146
|
54
|
+
|
55
|
+
# Offense count: 1
|
56
|
+
# Configuration parameters: CountComments.
|
57
|
+
Metrics/ClassLength:
|
58
|
+
Max: 101
|
59
|
+
|
60
|
+
# Offense count: 5
|
61
|
+
Metrics/CyclomaticComplexity:
|
62
|
+
Max: 19
|
63
|
+
|
64
|
+
# Offense count: 19
|
65
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
66
|
+
Metrics/MethodLength:
|
67
|
+
Max: 213
|
68
|
+
|
69
|
+
# Offense count: 6
|
70
|
+
# Configuration parameters: CountComments.
|
71
|
+
Metrics/ModuleLength:
|
72
|
+
Max: 423
|
73
|
+
|
74
|
+
# Offense count: 9
|
75
|
+
# Configuration parameters: CountKeywordArgs.
|
76
|
+
Metrics/ParameterLists:
|
77
|
+
Max: 27
|
78
|
+
|
79
|
+
# Offense count: 6
|
80
|
+
Metrics/PerceivedComplexity:
|
81
|
+
Max: 19
|
82
|
+
|
83
|
+
# Offense count: 1
|
84
|
+
Naming/AccessorMethodName:
|
85
|
+
Exclude:
|
86
|
+
- 'lib/sumomo/ec2.rb'
|
87
|
+
|
88
|
+
# Offense count: 2
|
89
|
+
# Configuration parameters: EnforcedStyle.
|
90
|
+
# SupportedStyles: snake_case, normalcase, non_integer
|
91
|
+
Naming/VariableNumber:
|
92
|
+
Exclude:
|
93
|
+
- 'lib/sumomo/ec2.rb'
|
94
|
+
|
95
|
+
# Offense count: 2
|
96
|
+
Security/Eval:
|
97
|
+
Exclude:
|
98
|
+
- 'exe/sumomo'
|
99
|
+
|
100
|
+
# Offense count: 1
|
101
|
+
Style/CommentedKeyword:
|
102
|
+
Exclude:
|
103
|
+
- 'lib/sumomo/ecs.rb'
|
104
|
+
|
105
|
+
# Offense count: 1
|
106
|
+
# Cop supports --auto-correct.
|
107
|
+
# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
|
108
|
+
# SupportedStyles: assign_to_condition, assign_inside_condition
|
109
|
+
Style/ConditionalAssignment:
|
110
|
+
Exclude:
|
111
|
+
- 'lib/sumomo/ecs.rb'
|
112
|
+
|
113
|
+
# Offense count: 14
|
114
|
+
Style/Documentation:
|
115
|
+
Exclude:
|
116
|
+
- 'spec/**/*'
|
117
|
+
- 'test/**/*'
|
118
|
+
- 'lib/sumomo.rb'
|
119
|
+
- 'lib/sumomo/api.rb'
|
120
|
+
- 'lib/sumomo/cdn.rb'
|
121
|
+
- 'lib/sumomo/dns.rb'
|
122
|
+
- 'lib/sumomo/ec2.rb'
|
123
|
+
- 'lib/sumomo/ecs.rb'
|
124
|
+
- 'lib/sumomo/momo_extensions/resource.rb'
|
125
|
+
- 'lib/sumomo/momo_extensions/stack.rb'
|
126
|
+
- 'lib/sumomo/network.rb'
|
127
|
+
- 'lib/sumomo/stack.rb'
|
128
|
+
|
129
|
+
# Offense count: 3
|
130
|
+
# Configuration parameters: MinBodyLength.
|
131
|
+
Style/GuardClause:
|
132
|
+
Exclude:
|
133
|
+
- 'lib/sumomo.rb'
|
134
|
+
- 'sumomo.gemspec'
|
135
|
+
|
136
|
+
# Offense count: 5
|
137
|
+
# Cop supports --auto-correct.
|
138
|
+
Style/IfUnlessModifier:
|
139
|
+
Exclude:
|
140
|
+
- 'lib/sumomo/ec2.rb'
|
141
|
+
- 'lib/sumomo/ecs.rb'
|
142
|
+
- 'lib/sumomo/network.rb'
|
143
|
+
|
144
|
+
# Offense count: 1
|
145
|
+
Style/MethodMissingSuper:
|
146
|
+
Exclude:
|
147
|
+
- 'lib/sumomo.rb'
|
148
|
+
|
149
|
+
# Offense count: 2
|
150
|
+
Style/MissingRespondToMissing:
|
151
|
+
Exclude:
|
152
|
+
- 'lib/sumomo.rb'
|
153
|
+
- 'lib/sumomo/api.rb'
|
154
|
+
|
155
|
+
# Offense count: 1
|
156
|
+
# Cop supports --auto-correct.
|
157
|
+
# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
|
158
|
+
# SupportedStyles: predicate, comparison
|
159
|
+
Style/NumericPredicate:
|
160
|
+
Exclude:
|
161
|
+
- 'spec/**/*'
|
162
|
+
- 'lib/sumomo/ec2.rb'
|
163
|
+
|
164
|
+
# Offense count: 71
|
165
|
+
# Cop supports --auto-correct.
|
166
|
+
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
167
|
+
# URISchemes: http, https
|
168
|
+
Metrics/LineLength:
|
169
|
+
Max: 153
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'sumomo'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "sumomo"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
../uuid/bin/uuid
|
@@ -75,11 +75,47 @@ function Storage()
|
|
75
75
|
});
|
76
76
|
}
|
77
77
|
|
78
|
+
this.list = function(prefix, start_after, onComplete, onError)
|
79
|
+
{
|
80
|
+
var params = {
|
81
|
+
Bucket: "{{ BUCKET }}",
|
82
|
+
Prefix: "data/{{ STORE_PREFIX }}/" + prefix
|
83
|
+
}
|
84
|
+
|
85
|
+
if (start_after)
|
86
|
+
{
|
87
|
+
params.StartAfter = start_after;
|
88
|
+
}
|
89
|
+
|
90
|
+
s3.listObjectsV2(params, function(err, data) {
|
91
|
+
if (err)
|
92
|
+
{
|
93
|
+
if (onError)
|
94
|
+
{
|
95
|
+
onError(err);
|
96
|
+
}
|
97
|
+
}
|
98
|
+
else
|
99
|
+
{
|
100
|
+
if (onComplete)
|
101
|
+
{
|
102
|
+
onComplete(data.Contents.map(function(x){ return x.Key; }));
|
103
|
+
}
|
104
|
+
}
|
105
|
+
});
|
106
|
+
}
|
107
|
+
|
78
108
|
return this;
|
79
109
|
}
|
80
110
|
|
81
111
|
var Store = new Storage();
|
82
112
|
|
113
|
+
function decode_component(str) {
|
114
|
+
str = str.replace(/\+/g, '%20');
|
115
|
+
str = decodeURIComponent(str);
|
116
|
+
return str;
|
117
|
+
}
|
118
|
+
|
83
119
|
function parseQuery(queryString) {
|
84
120
|
try
|
85
121
|
{
|
@@ -91,7 +127,7 @@ function parseQuery(queryString) {
|
|
91
127
|
var pairs = queryString.split('&');
|
92
128
|
for (var i = 0; i < pairs.length; i++) {
|
93
129
|
var pair = pairs[i].split('=');
|
94
|
-
query[
|
130
|
+
query[decode_component(pair[0])] = decode_component(pair[1] || '');
|
95
131
|
}
|
96
132
|
return query;
|
97
133
|
}
|
@@ -12,50 +12,81 @@ var fs = require('fs')
|
|
12
12
|
// Simulated store
|
13
13
|
function Storage()
|
14
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
|
-
|
15
|
+
var store = {}
|
16
|
+
|
17
|
+
try
|
18
|
+
{
|
19
|
+
var store_contents = fs.readFileSync(".store")
|
20
|
+
store = JSON.parse(store_contents)
|
21
|
+
}
|
22
|
+
catch (e)
|
23
|
+
{
|
24
|
+
console.log("Error reading .store; will start with blank store")
|
25
|
+
console.log(e)
|
26
|
+
}
|
27
|
+
|
28
|
+
this.get = function(key, onComplete, onError)
|
29
|
+
{
|
30
|
+
if (store[key] === undefined)
|
31
|
+
{
|
32
|
+
if (onError)
|
33
|
+
{
|
34
|
+
onError({err: "no_such_key"});
|
35
|
+
}
|
36
|
+
}
|
37
|
+
else
|
38
|
+
{
|
39
|
+
if (onComplete)
|
40
|
+
{
|
41
|
+
onComplete(store[key]);
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
this.set = function(key, value, onComplete, onError)
|
47
|
+
{
|
48
|
+
store[key] = value;
|
49
|
+
fs.writeFile(".store", JSON.stringify(store), function()
|
50
|
+
{
|
51
|
+
if (onComplete)
|
52
|
+
{
|
53
|
+
onComplete(key);
|
54
|
+
}
|
55
|
+
})
|
56
|
+
}
|
57
|
+
|
58
|
+
this.list = function(prefix, start_after, onComplete, onError)
|
59
|
+
{
|
60
|
+
var result = [];
|
61
|
+
var start = true;
|
62
|
+
if (start_after)
|
63
|
+
{
|
64
|
+
start = false;
|
65
|
+
}
|
66
|
+
var count = 0;
|
67
|
+
var keys = Object.keys(store);
|
68
|
+
for (var i in keys)
|
69
|
+
{
|
70
|
+
var x = keys[i];
|
71
|
+
if (x === start_after)
|
72
|
+
{
|
73
|
+
start = true;
|
74
|
+
}
|
75
|
+
|
76
|
+
if (start && x.indexOf(prefix) === 0)
|
77
|
+
{
|
78
|
+
result.push(x);
|
79
|
+
count += 1;
|
80
|
+
}
|
81
|
+
};
|
82
|
+
|
83
|
+
if (onComplete)
|
84
|
+
{
|
85
|
+
onComplete(result);
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
return this;
|
59
90
|
}
|
60
91
|
|
61
92
|
var Store = new Storage();
|
@@ -66,34 +97,40 @@ var response_sent = false;
|
|
66
97
|
|
67
98
|
var server = http.createServer(function(req, res) {
|
68
99
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
100
|
+
var request = {
|
101
|
+
_native_req: req,
|
102
|
+
url: req.url,
|
103
|
+
method: req.method,
|
104
|
+
params: {}
|
105
|
+
}
|
75
106
|
|
76
|
-
|
107
|
+
router(request, res, function(err) {
|
77
108
|
|
78
|
-
|
79
|
-
|
80
|
-
|
109
|
+
res.statusCode = 404;
|
110
|
+
res.end(JSON.stringify({message: "File not found"}));
|
111
|
+
});
|
81
112
|
});
|
82
113
|
|
114
|
+
function decode_component(str) {
|
115
|
+
str = str.replace(/\+/g, '%20');
|
116
|
+
str = decodeURIComponent(str);
|
117
|
+
return str;
|
118
|
+
}
|
119
|
+
|
83
120
|
function parseQuery(queryString) {
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
121
|
+
try
|
122
|
+
{
|
123
|
+
var res = JSON.parse(queryString)
|
124
|
+
return res;
|
125
|
+
}
|
126
|
+
catch(e) { }
|
127
|
+
var query = {};
|
128
|
+
var pairs = (queryString[0] === '?' ? queryString.substr(1) : queryString).split('&');
|
129
|
+
for (var i = 0; i < pairs.length; i++) {
|
130
|
+
var pair = pairs[i].split('=');
|
131
|
+
query[decode_component(pair[0])] = decode_component(pair[1] || '');
|
132
|
+
}
|
133
|
+
return query;
|
97
134
|
}
|
98
135
|
|
99
136
|
{{ SCRIPT }}
|
@@ -101,114 +138,114 @@ function parseQuery(queryString) {
|
|
101
138
|
// Simulate API Gateway Lambda Proxy Event
|
102
139
|
function prepare(handler)
|
103
140
|
{
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
141
|
+
return function(request, res)
|
142
|
+
{
|
143
|
+
var body = [];
|
144
|
+
var req = request._native_req;
|
145
|
+
|
146
|
+
function callback(exception, response)
|
147
|
+
{
|
148
|
+
if (response.headers)
|
149
|
+
{
|
150
|
+
for (var key in response.headers)
|
151
|
+
{
|
152
|
+
res.setHeader(key, response.headers[key]);
|
153
|
+
}
|
154
|
+
}
|
155
|
+
res.statusCode = response.statusCode || 404;
|
156
|
+
res.end(response.body || null);
|
157
|
+
}
|
158
|
+
|
159
|
+
req.on('data', function(chunk) {
|
160
|
+
body.push(chunk);
|
161
|
+
|
162
|
+
}).on('end', function() {
|
163
|
+
|
164
|
+
var completed_body = Buffer.concat(body).toString();
|
165
|
+
|
166
|
+
var parsed_url = url.parse(req.url, true);
|
167
|
+
|
168
|
+
var headers = {};
|
169
|
+
|
170
|
+
headers["Accept"] = "*/*";
|
171
|
+
headers["CloudFront-Forwarded-Proto"] = "https";
|
172
|
+
headers["CloudFront-Is-Desktop-Viewer"] = "true";
|
173
|
+
headers["CloudFront-Is-Mobile-Viewer"] = "false";
|
174
|
+
headers["CloudFront-Is-SmartTV-Viewer"] = "false";
|
175
|
+
headers["CloudFront-Is-Tablet-Viewer"] = "false";
|
176
|
+
headers["CloudFront-Viewer-Country"] = "US";
|
177
|
+
headers["Content-Type"] = "";
|
178
|
+
headers["Host"] = "";
|
179
|
+
headers["User-Agent"] = "";
|
180
|
+
headers["Via"] = "1.1 1234567890abcdefghijklmnopqrstuv.cloudfront.net (CloudFront)";
|
181
|
+
headers["X-Amz-Cf-Id"] = "0000000000000000000000000-000000000-000000000000000000==";
|
182
|
+
headers["X-Amzn-Trace-Id"] = "Root=1-00000000-ffffffffffffffffffffffff";
|
183
|
+
headers["X-Forwarded-For"] = req.connection.remoteAddress;
|
184
|
+
headers["X-Forwarded-Port"] = "443";
|
185
|
+
headers["X-Forwarded-Proto"] = "https";
|
186
|
+
|
187
|
+
for(var key in req.headers)
|
188
|
+
{
|
189
|
+
var uppercased = key.replace(/(^|-)[a-z]/g, function(text){ return text.toUpperCase(); });
|
190
|
+
|
191
|
+
headers[uppercased] = req.headers[key];
|
192
|
+
}
|
193
|
+
|
194
|
+
var request_event = {
|
195
|
+
resource: "/{proxy+}",
|
196
|
+
path: parsed_url.pathname,
|
197
|
+
httpMethod: req.method,
|
198
|
+
headers: headers,
|
199
|
+
queryStringParameters: url.parse(req.url, true).query,
|
200
|
+
pathParameters: request.params,
|
201
|
+
stageVariables: null,
|
202
|
+
requestContext: {
|
203
|
+
path: parsed_url.pathname,
|
204
|
+
accountId: "000000000000",
|
205
|
+
resourceId: "123abc",
|
206
|
+
stage: "test",
|
207
|
+
requestId: "00000000-0000-0000-0000-000000000000",
|
208
|
+
identity: {
|
209
|
+
cognitoIdentityId: null,
|
210
|
+
accountId: null,
|
211
|
+
cognitoIdentityId: null,
|
212
|
+
caller: null,
|
213
|
+
apiKey: "",
|
214
|
+
sourceIp: req.connection.remoteAddress,
|
215
|
+
accessKey: null,
|
216
|
+
cognitoAuthenticationType: null,
|
217
|
+
cognitoAuthenticationProvider: null,
|
218
|
+
userArn: null,
|
219
|
+
userAgent: headers["User-Agent"],
|
220
|
+
user: null
|
221
|
+
|
222
|
+
},
|
223
|
+
resourcePath: "/{proxy+}",
|
224
|
+
httpMethod: req.method,
|
225
|
+
apiId: "12345abcde"
|
226
|
+
},
|
227
|
+
|
228
|
+
body: completed_body,
|
229
|
+
isBase64Encoded: false
|
230
|
+
|
231
|
+
};
|
232
|
+
|
233
|
+
req._native_req = undefined;
|
234
|
+
|
235
|
+
try
|
236
|
+
{
|
237
|
+
handler(request_event, callback);
|
238
|
+
}
|
239
|
+
catch (e)
|
240
|
+
{
|
241
|
+
console.log(e);
|
242
|
+
callback(e, {
|
243
|
+
statusCode: 500,
|
244
|
+
body: JSON.stringify({message: "Internal Server Error"}, null, 2)
|
245
|
+
});
|
246
|
+
}
|
247
|
+
});
|
248
|
+
};
|
212
249
|
}
|
213
250
|
|
214
251
|
// {{ ROUTES }}
|