-
-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Single Lambda Function for Controllers * For controllers, a single Lambda function is deployed going forward. * APIGW serves as proxy endpoint for requests to the single Lambda function. Techniquely, there are 2 APIGW endpoints. * Jobs and other classes still create a discrete lambda function per Ruby method. Jets Engines support * Jets Engines closely resemble Rails engines. * Use as many Rails middlewares as possible Jets Controllers are "ActionController and ActionView compatible." * View Scope has first-class citizens access to Jets Controller instances. * Breaking Change: `resources :posts` and `delete` route method routes to controller `destroy` method like rails instead of `delete` method. Jets Controllers now support: * around filters * cache control and etag caching support * content security policy * cookies support via actionpack * flash support * forgery protection improvements * importmap support * i18n support New Jets CLI structure that * Close to Rails CLI structure Jets Pro support * deploys, release history, rollback support * use jets-api gem Refactor CloudFormation Builders * Use CamelCase properties internally * Short name template filenames and class names without the _builder. * Fully qualify LambdaFunction logical id. Misc * Remove afterburner turbo and mega mode to prepare for container-based Rails support. * Autoloaders refactor. gem (Jets internal), main (user app), once (user app) * CORS via with middleware only. * Improve ActionMailer integration. Improve preview support. * logger active support logger and tagged logging support * dynamodb event conventional table namespace * enable iot rule by default bug fix * create named route methods for all CRUD actions * Jets.cache support Breaking changes: * Pass request.headers straight without downcase. IE: `X-Amzn-Trace-Id`. Introduce request.downcase_headers instead. * Jets.config.prewarm.concurrency option removed. * dynomite decoupling and integration improvements
- Loading branch information
Showing
887 changed files
with
20,485 additions
and
15,482 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Copyright (c) 2021 Tung Nguyen | ||
Copyright (c) Tung Nguyen | ||
|
||
MIT License | ||
|
||
|
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 was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
engines/internal/app/controllers/jets/application_controller.rb
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,28 @@ | ||
# frozen_string_literal: true | ||
|
||
class Jets::ApplicationController < Jets::Controller::Base # :nodoc: | ||
prepend_view_path File.expand_path("../../../app/views", __dir__) | ||
layout "application" | ||
|
||
before_action :disable_content_security_policy_nonce! | ||
|
||
content_security_policy do |policy| | ||
policy.script_src :self, :unsafe_inline | ||
policy.style_src :self, :unsafe_inline | ||
end | ||
|
||
private | ||
def require_local! | ||
unless local_request? | ||
render html: "<p>For security purposes, this information is only available to local requests.</p>".html_safe, status: :forbidden | ||
end | ||
end | ||
|
||
def local_request? | ||
Jets.application.config.consider_all_requests_local || request.local? | ||
end | ||
|
||
def disable_content_security_policy_nonce! | ||
request.content_security_policy_nonce_generator = nil | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Parent class for MountController | ||
class Jets::BareController < Jets::Controller::Base | ||
layout false | ||
abstract! | ||
skip_forgery_protection | ||
end |
55 changes: 55 additions & 0 deletions
55
engines/internal/app/controllers/jets/health_controller.rb
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,55 @@ | ||
# frozen_string_literal: true | ||
|
||
module Jets | ||
# Built-in Health Check Endpoint | ||
# | ||
# \Jets also comes with a built-in health check endpoint that is reachable at | ||
# the +/up+ path. This endpoint will return a 200 status code if the app has | ||
# booted with no exceptions, and a 500 status code otherwise. | ||
# | ||
# In production, many applications are required to report their status upstream, | ||
# whether it's to an uptime monitor that will page an engineer when things go | ||
# wrong, or a load balancer or Kubernetes controller used to determine a pod's | ||
# health. This health check is designed to be a one-size fits all that will work | ||
# in many situations. | ||
# | ||
# While any newly generated \Jets applications will have the health check at | ||
# +/up+, you can configure the path to be anything you'd like in your | ||
# <tt>"config/routes.rb"</tt>: | ||
# | ||
# Jets.application.routes.draw do | ||
# get "healthz" => "jets/health#show", as: :jets_health_check | ||
# end | ||
# | ||
# The health check will now be accessible via the +/healthz+ path. | ||
# | ||
# NOTE: This endpoint does not reflect the status of all of your application's | ||
# dependencies, such as the database or redis cluster. Replace | ||
# <tt>"jets/health#show"</tt> with your own controller action if you have | ||
# application specific needs. | ||
# | ||
# Think carefully about what you want to check as it can lead to situations | ||
# where your application is being restarted due to a third-party service going | ||
# bad. Ideally, you should design your application to handle those outages | ||
# gracefully. | ||
class HealthController < Jets::Controller::Base | ||
rescue_from(Exception) { render_down } | ||
|
||
def show | ||
render_up | ||
end | ||
|
||
private | ||
def render_up | ||
render html: html_status(color: "green") | ||
end | ||
|
||
def render_down | ||
render html: html_status(color: "red"), status: 500 | ||
end | ||
|
||
def html_status(color:) | ||
%(<!DOCTYPE html><html><body style="background-color: #{color}"></body></html>).html_safe | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# frozen_string_literal: true | ||
|
||
class Jets::InfoController < Jets::ApplicationController # :nodoc: | ||
prepend_view_path ActionDispatch::DebugView::RESCUES_TEMPLATE_PATH | ||
layout -> { request.xhr? ? false : "application" } | ||
|
||
before_action :require_local! | ||
|
||
def index | ||
redirect_to action: :routes | ||
end | ||
|
||
def properties | ||
@info = Jets::Info.to_html | ||
@page_title = "Properties" | ||
end | ||
|
||
def routes | ||
if path = params[:path] | ||
path = URI::DEFAULT_PARSER.escape path | ||
normalized_path = with_leading_slash path | ||
render json: { | ||
exact: match_route { |it| it.match normalized_path }, | ||
fuzzy: match_route { |it| it.spec.to_s.match path } | ||
} | ||
else | ||
@routes_table = routes_table | ||
@page_title = "Routes" | ||
end | ||
end | ||
|
||
private | ||
def routes_table | ||
text = Jets::Router::Help.new(format: "markdown").text | ||
Kramdown::Document.new(text).to_html | ||
end | ||
|
||
def match_route | ||
_routes.routes.filter_map { |route| route.path.spec.to_s if yield route.path } | ||
end | ||
|
||
def with_leading_slash(path) | ||
("/" + path).squeeze("/") | ||
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
Oops, something went wrong.