lamby 4.1.0 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3381e11a58b68451710f0a2986e158e74a32f179f0c4e4c3e5d62093f7abfbc0
4
- data.tar.gz: 5b09b23df9166c2e382b36e6d6b0243a9ad8af23bebd9cb931201e2be085a657
3
+ metadata.gz: 5e14871823a1771774b2ad8abae4ee766caac88ff51acb308cacc8a178d41da4
4
+ data.tar.gz: 36178b6813cf8487f685ba4e5a74c7a983e2dd06db2d0d224023d7c64cc227e0
5
5
  SHA512:
6
- metadata.gz: 6ddab5c17140f08741f7315db4b31284d3455f1084d79fb3c60dead8cd719dbb2ee6ab08afa69949ff2a241d4978d80b77bbb959136139466e911cdc04394d2b
7
- data.tar.gz: 58d6653787f54724ea2491707fe08b0dce63eb70a1794c6547754f0f5f78e43aa2e24ca88620f864c46a19bcd1443e0646053eda6b56b0431abd8b8b803d0047
6
+ metadata.gz: 595d816933f71ed9003ae3261f61f2b52cee61c9791a19b054b9be81841eb3e3f541e60ce798911b91380fe812656b90611963d6b0386dfd9c6239952149c6e9
7
+ data.tar.gz: 3117f4172652685565693597fbe7cf7f1ba25cf85c34d04db679f057c5b3bbf4111d830b9f6e63db6ea47ff1c9d9b7fa6cd2ef8e05b89da62e60547f5591d81d
@@ -1,23 +1,33 @@
1
1
  name: CI/CD
2
2
  on: [push]
3
3
  jobs:
4
- test:
5
- runs-on: ubuntu-latest
4
+ image:
5
+ name: Image
6
+ runs-on: ubuntu-20.04
6
7
  steps:
7
- - name: Checkout
8
- uses: actions/checkout@v2
9
- - name: Login to GitHub Container Registry
10
- uses: docker/login-action@v2
8
+ - uses: actions/checkout@v3
9
+ - uses: docker/login-action@v2
11
10
  with:
12
11
  registry: ghcr.io
13
12
  username: ${{ github.repository_owner }}
14
13
  password: ${{ secrets.GITHUB_TOKEN }}
15
- - name: Build & Run Development Container
16
- uses: devcontainers/ci@v0.2
14
+ - uses: devcontainers/ci@v0.3
17
15
  with:
18
16
  push: always
19
- imageName: ghcr.io/customink/lamby-devcontainer
20
- cacheFrom: ghcr.io/customink/lamby-devcontainer
17
+ imageName: ghcr.io/rails-lambda/lamby-devcontainer
18
+ cacheFrom: ghcr.io/rails-lambda/lamby-devcontainer
19
+ runCmd: echo DONE!
20
+ test:
21
+ runs-on: ubuntu-20.04
22
+ needs: image
23
+ steps:
24
+ - name: Checkout
25
+ uses: actions/checkout@v3
26
+ - name: Setup & Test
27
+ uses: devcontainers/ci@v0.3
28
+ with:
29
+ push: never
30
+ cacheFrom: ghcr.io/rails-lambda/lamby-devcontainer
21
31
  env: |
22
32
  CI
23
33
  runCmd: |
data/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  See this http://keepachangelog.com link for information on how we want this documented formatted.
4
4
 
5
+ ## v4.2.0
6
+
7
+ ### Added
8
+
9
+ - Local Development Proxy Server. See #164
10
+
11
+ ## v4.1.1
12
+
13
+ ### Changed
14
+
15
+ - New lamby.cloud site and GitHub community organization.
16
+
5
17
  ## v4.1.0
6
18
 
7
19
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lamby (4.1.0)
4
+ lamby (4.2.0)
5
5
  rack
6
6
 
7
7
  GEM
@@ -170,6 +170,7 @@ GEM
170
170
  timeout (0.3.2)
171
171
  tzinfo (2.0.6)
172
172
  concurrent-ruby (~> 1.0)
173
+ webrick (1.8.1)
173
174
  websocket-driver (0.7.5)
174
175
  websocket-extensions (>= 0.1.0)
175
176
  websocket-extensions (0.1.5)
@@ -189,6 +190,7 @@ DEPENDENCIES
189
190
  pry
190
191
  rails
191
192
  rake
193
+ webrick
192
194
 
193
195
  BUNDLED WITH
194
196
  2.3.26
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # Lamby [![Actions Status](https://github.com/customink/lamby/workflows/CI/CD/badge.svg)](https://github.com/customink/lamby/actions) [![Codespaces](https://img.shields.io/badge/Codespaces-✅-black)](https://github.com/features/codespaces)
1
+ # Lamby [![Actions Status](https://github.com/rails-lambda/lamby/workflows/CI/CD/badge.svg)](https://github.com/rails-lambda/lamby/actions)
2
2
 
3
3
  <h2>Simple Rails &amp; AWS Lambda Integration using Rack</h2>
4
- <a href="https://lamby.custominktech.com"><img src="https://raw.githubusercontent.com/customink/lamby/master/images/social2.png" alt="Lamby: Simple Rails & AWS Lambda Integration using Rack." align="right" width="450" style="margin-left:1rem;margin-bottom:1rem;" /></a>
4
+ <a href="https://lamby.cloud"><img src="https://raw.githubusercontent.com/rails-lambda/lamby/master/images/social2.png" alt="Lamby: Simple Rails & AWS Lambda Integration using Rack." align="right" width="450" style="margin-left:1rem;margin-bottom:1rem;" /></a>
5
5
 
6
6
  Lamby is an [AWS Lambda Web Adapter](https://github.com/awslabs/aws-lambda-web-adapter) for Rack applications.
7
7
 
@@ -9,14 +9,16 @@ We support Lambda [Function URLs](https://docs.aws.amazon.com/lambda/latest/dg/l
9
9
 
10
10
  ## Quick Start
11
11
 
12
- https://lamby.custominktech.com/docs/quick-start
12
+ https://lamby.cloud/docs/quick-start
13
13
 
14
14
  ## Full Documentation
15
15
 
16
- https://lamby.custominktech.com/docs/anatomy
16
+ https://lamby.cloud/docs/anatomy
17
17
 
18
18
  ## Contributing
19
19
 
20
+ [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/rails-lambda/lamby)
21
+
20
22
  This project is built for [GitHub Codespaces](https://github.com/features/codespaces) using the [Development Container](https://containers.dev) specification. Once you have the repo cloned and setup with a dev container using either Codespaces or [VS Code](#using-vs-code), run the following commands. This will install packages and run tests.
21
23
 
22
24
  ```shell
@@ -30,6 +32,6 @@ If you have the [Visual Studio Code Dev Container](https://marketplace.visualstu
30
32
 
31
33
  ## Code of Conduct
32
34
 
33
- Everyone interacting in the Lamby project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/customink/lamby/blob/master/CODE_OF_CONDUCT.md).
35
+ Everyone interacting in the Lamby project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/rails-lambda/lamby/blob/master/CODE_OF_CONDUCT.md).
34
36
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/customink/lamby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/rails-lambda/lamby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
data/Rakefile CHANGED
@@ -5,7 +5,13 @@ require "rake/testtask"
5
5
  Rake::TestTask.new(:test) do |t|
6
6
  t.libs << "test"
7
7
  t.libs << "lib"
8
- t.test_files = FileList["test/**/*_test.rb"]
8
+ t.test_files = begin
9
+ if ENV['TEST_FILE']
10
+ [ENV['TEST_FILE']]
11
+ else
12
+ FileList["test/**/*_test.rb"]
13
+ end
14
+ end
9
15
  t.verbose = false
10
16
  t.warning = false
11
17
  end
data/lamby.gemspec CHANGED
@@ -7,10 +7,10 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "lamby"
8
8
  spec.version = Lamby::VERSION
9
9
  spec.authors = ["Ken Collins"]
10
- spec.email = ["kcollins@customink.com"]
10
+ spec.email = ["ken@metaskills.net"]
11
11
  spec.summary = %q{Simple Rails & AWS Lambda Integration using Rack}
12
12
  spec.description = %q{Simple Rails & AWS Lambda Integration using Rack and various utilities.}
13
- spec.homepage = "https://github.com/customink/lamby"
13
+ spec.homepage = "https://github.com/rails-lambda/lamby"
14
14
  spec.license = "MIT"
15
15
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
16
16
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
@@ -26,4 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency 'minitest-focus'
27
27
  spec.add_development_dependency 'mocha'
28
28
  spec.add_development_dependency 'pry'
29
+ spec.add_development_dependency 'webrick'
29
30
  end
@@ -0,0 +1,25 @@
1
+ module Lamby
2
+ # This class is used by the `lamby:proxy_server` Rake task to run a
3
+ # Rack server for local development proxy. Specifically, this class
4
+ # accepts a JSON respresentation of a Lambda context object converted
5
+ # to a Hash as the single arugment.
6
+ #
7
+ class ProxyContext
8
+ def initialize(data)
9
+ @data = data
10
+ end
11
+
12
+ def method_missing(method_name, *args, &block)
13
+ key = method_name.to_s
14
+ if @data.key?(key)
15
+ @data[key]
16
+ else
17
+ super
18
+ end
19
+ end
20
+
21
+ def respond_to_missing?(method_name, include_private = false)
22
+ @data.key?(method_name.to_s) || super
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,36 @@
1
+ module Lamby
2
+ class ProxyServer
3
+
4
+ METHOD_NOT_ALLOWED = <<-HEREDOC.strip
5
+ <h1>Method Not Allowed</h1>
6
+ <p>Please POST to this endpoint with an application/json content type and JSON payload of your Lambda's event and context.<p>
7
+ <p>Example: <code>{ "event": event, "context": context }</code></p>
8
+ HEREDOC
9
+
10
+ def call(env)
11
+ return method_not_allowed unless method_allowed?(env)
12
+ event, context = event_and_context(env)
13
+ lambda_to_rack Lamby.cmd(event: event, context: context)
14
+ end
15
+
16
+ private
17
+
18
+ def event_and_context(env)
19
+ data = env['rack.input'].dup.read
20
+ json = JSON.parse(data)
21
+ [ json['event'], Lamby::ProxyContext.new(json['context']) ]
22
+ end
23
+
24
+ def method_allowed?(env)
25
+ env['REQUEST_METHOD'] == 'POST' && env['CONTENT_TYPE'] == 'application/json'
26
+ end
27
+
28
+ def method_not_allowed
29
+ [405, {"Content-Type" => "text/html"}, [ METHOD_NOT_ALLOWED.dup ]]
30
+ end
31
+
32
+ def lambda_to_rack(response)
33
+ [ 200, {"Content-Type" => "application/json"}, [ response.to_json ] ]
34
+ end
35
+ end
36
+ end
data/lib/lamby/railtie.rb CHANGED
@@ -1,5 +1,9 @@
1
1
  module Lamby
2
2
  class Railtie < ::Rails::Railtie
3
3
  config.lamby = Lamby::Config.config
4
+
5
+ rake_tasks do
6
+ load 'lamby/tasks.rake'
7
+ end
4
8
  end
5
9
  end
@@ -0,0 +1,8 @@
1
+ namespace :lamby do
2
+ task :proxy_server => [:environment] do
3
+ require 'webrick'
4
+ port = ENV['LAMBY_PROXY_PORT'] || 3000
5
+ bind = ENV['LAMBY_PROXY_BIND'] || '0.0.0.0'
6
+ Rack::Handler::WEBrick.run Lamby::ProxyServer.new, Port: port, BindAddress: bind
7
+ end
8
+ end
data/lib/lamby/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lamby
2
- VERSION = '4.1.0'
2
+ VERSION = '4.2.0'
3
3
  end
data/lib/lamby.rb CHANGED
@@ -35,5 +35,7 @@ module Lamby
35
35
  end
36
36
 
37
37
  autoload :SsmParameterStore, 'lamby/ssm_parameter_store'
38
+ autoload :ProxyContext, 'lamby/proxy_context'
39
+ autoload :ProxyServer, 'lamby/proxy_server'
38
40
 
39
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lamby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Collins
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-23 00:00:00.000000000 Z
11
+ date: 2023-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -122,9 +122,23 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: webrick
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  description: Simple Rails & AWS Lambda Integration using Rack and various utilities.
126
140
  email:
127
- - kcollins@customink.com
141
+ - ken@metaskills.net
128
142
  executables: []
129
143
  extensions: []
130
144
  extra_rdoc_files: []
@@ -153,6 +167,8 @@ files:
153
167
  - lib/lamby/debug.rb
154
168
  - lib/lamby/handler.rb
155
169
  - lib/lamby/logger.rb
170
+ - lib/lamby/proxy_context.rb
171
+ - lib/lamby/proxy_server.rb
156
172
  - lib/lamby/rack.rb
157
173
  - lib/lamby/rack_alb.rb
158
174
  - lib/lamby/rack_http.rb
@@ -160,9 +176,10 @@ files:
160
176
  - lib/lamby/railtie.rb
161
177
  - lib/lamby/runner.rb
162
178
  - lib/lamby/ssm_parameter_store.rb
179
+ - lib/lamby/tasks.rake
163
180
  - lib/lamby/version.rb
164
181
  - vendor/.keep
165
- homepage: https://github.com/customink/lamby
182
+ homepage: https://github.com/rails-lambda/lamby
166
183
  licenses:
167
184
  - MIT
168
185
  metadata: {}
@@ -181,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
198
  - !ruby/object:Gem::Version
182
199
  version: '0'
183
200
  requirements: []
184
- rubygems_version: 3.4.12
201
+ rubygems_version: 3.3.26
185
202
  signing_key:
186
203
  specification_version: 4
187
204
  summary: Simple Rails & AWS Lambda Integration using Rack