Skip to content

Commit 23fdf1b

Browse files
first commit
0 parents  commit 23fdf1b

32 files changed

+654
-0
lines changed

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*.gem
2+
.bundle
3+
.byebug_history
4+
.DS_Store
5+
.env*
6+
/node_modules
7+
/public/packs
8+
/public/packs-test
9+
bundled
10+
coverage
11+
pkg
12+
tmp

.jetskeep

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pack

.rspec

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--color
2+
--format documentation
3+
--require spec_helper

.ruby-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.5.1@serverless-ruby-simple-apis

Gemfile

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
source "https://rubygems.org"
2+
3+
gem "jets"
4+
5+
6+
# Include mysql2 gem if you are using ActiveRecord, remove if you are not
7+
gem "mysql2", "~> 0.5.2"
8+
9+
gem "dynomite"
10+
11+
group :development, :test do
12+
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
13+
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
14+
gem 'shotgun'
15+
gem 'rack'
16+
end
17+
18+
group :test do
19+
gem 'rspec' # rspec test group only or we get the "irb: warn: can't alias context from irb_context warning" when starting jets console
20+
gem 'launchy'
21+
gem 'capybara'
22+
end

Procfile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
local: dynamodb-local # port 8000
2+
admin: env AWS_ACCESS_KEY_ID=$DYNAMODB_ADMIN_AWS_ACCESS_KEY_ID PORT=8001 dynamodb-admin # port 8001
3+
# web: jets server # port 8888
4+
5+
# Using Procfile to just start local dynamodb services for now.
6+
# To start jets server for now use:
7+
# jets server

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Jets Project
2+
3+
This README would normally document whatever steps are necessary to get the application up and running.
4+
5+
Things you might want to cover:
6+
7+
* Dependencies
8+
* Configuration
9+
* Database setup
10+
* How to run the test suite
11+
* Deployment instructions

Rakefile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require 'jets'
2+
Jets.load_tasks
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class ApplicationController < Jets::Controller::Base
2+
end

app/helpers/application_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module ApplicationHelper
2+
end

app/jobs/application_job.rb

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class ApplicationJob < Jets::Job::Base
2+
# Adjust to increase the default timeout for all Job classes
3+
class_timeout 60
4+
end

app/models/application_item.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class ApplicationItem < Dynomite::Item
2+
end

app/models/application_record.rb

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class ApplicationRecord < ActiveRecord::Base
2+
self.abstract_class = true
3+
end

config.ru

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This file is used by Rack-based servers to start the application.
2+
3+
require "jets"
4+
Jets.boot
5+
run Jets.application

config/application.rb

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
Jets.application.configure do
2+
config.project_name = "serverless-ruby-simple-apis"
3+
config.mode = "api"
4+
5+
config.prewarm.enable = true # default is true
6+
# config.prewarm.rate = '30 minutes' # default is '30 minutes'
7+
# config.prewarm.concurrency = 2 # default is 2
8+
# config.prewarm.public_ratio = 3 # default is 3
9+
10+
# config.env_extra = 2 # can also set this with JETS_ENV_EXTRA
11+
# config.extra_autoload_paths = []
12+
13+
# config.asset_base_url = 'https://cloudfront.domain.com/assets' # example
14+
15+
# config.cors = true # for '*'' # defaults to false
16+
# config.cors = '*.mydomain.com' # for specific domain
17+
18+
# config.function.timeout = 30 # defaults to 30
19+
# config.function.role = "arn:aws:iam::#{Jets.aws.account}:role/service-role/pre-created"
20+
# config.function.memory_size = 1536
21+
22+
# config.api.endpoint_type = 'PRIVATE' # Default is 'EDGE' (https://docs.aws.amazon.com/apigateway/api-reference/link-relation/restapi-create/#endpointConfiguration)
23+
24+
# config.function.environment = {
25+
# global_app_key1: "global_app_value1",
26+
# global_app_key2: "global_app_value2",
27+
# }
28+
# More examples:
29+
# config.function.dead_letter_queue = { target_arn: "arn" }
30+
# config.function.vpc_config = {
31+
# security_group_ids: [ "sg-1", "sg-2" ],
32+
# subnet_ids: [ "subnet-1", "subnet-2" ]
33+
# }
34+
# The config.function settings to the CloudFormation Lambda Function properties.
35+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html
36+
# Underscored format can be used for keys to make it look more ruby-ish.
37+
38+
# Assets settings
39+
# The config.assets.folders are folders within the public folder that will be set
40+
# to public-read on s3 and served directly. IE: public/assets public/images public/packs
41+
# config.assets.folders = %w[assets images packs]
42+
# config.assets.max_age = 3600 # when to expire assets
43+
# config.assets.cache_control = nil # IE: "public, max-age=3600" # override max_age for more fine-grain control.
44+
# config.assets.base_url = nil # IE: https://cloudfront.com/my/base/path, defaults to the s3 bucket url
45+
# IE: https://s3-us-west-2.amazonaws.com/demo-dev-s3bucket-1inlzkvujq8zb
46+
47+
# config.api.endpoint_type = 'PRIVATE' # Default is 'EDGE' https://amzn.to/2r0Iu2L
48+
# config.api.authorization_type = "AWS_IAM" # default is 'NONE' https://amzn.to/2qZ7zLh
49+
50+
51+
# config.domain.hosted_zone_name = "example.com"
52+
# us-west-2 REGIONAL endpoint
53+
# config.domain.cert_arn = "arn:aws:acm:us-west-2:112233445566:certificate/8d8919ce-a710-4050-976b-b33da991e123"
54+
# us-east-1 EDGE endpoint
55+
# config.domain.cert_arn = "arn:aws:acm:us-east-1:112233445566:certificate/d68472ba-04f8-45ba-b9db-14f839d57123"
56+
# config.domain.endpoint_type = "EDGE"
57+
58+
# By default logger needs to log to $stderr for CloudWatch to receive Lambda messages, but for
59+
# local testing environment you may want to log these messages to 'test.log' file to keep your
60+
# testing suite output readable.
61+
# config.logger = Jets::Logger.new($strerr)
62+
end

config/database.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
default: &default
2+
adapter: mysql2
3+
encoding: utf8
4+
pool: <%= ENV["DB_POOL"] || 5 %>
5+
database: <%= ENV['DB_NAME'] || 'serverless-ruby-simple-apis_development' %>
6+
username: <%= ENV['DB_USER'] || 'root' %>
7+
password: <%= ENV['DB_PASS'] %>
8+
host: <%= ENV["DB_HOST"] %>
9+
url: <%= ENV['DATABASE_URL'] %> # takes higher precedence than other settings
10+
11+
development:
12+
<<: *default
13+
database: <%= ENV['DB_NAME'] || 'serverless-ruby-simple-apis_development' %>
14+
15+
test:
16+
<<: *default
17+
database: serverless-ruby-simple-apis_test
18+
19+
production:
20+
<<: *default
21+
database: serverless-ruby-simple-apis_production
22+
url: <%= ENV['DATABASE_URL'] %>

config/dynamodb.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Jets::Config.project_namespace is special value results in using the project namespace. Example :
2+
# table_namespace: <%= Jets.config.project_namespace %>
3+
# This is the default value.
4+
5+
development:
6+
table_namespace: <%= Jets.config.table_namespace %>
7+
# More examples:
8+
# table_namespace: demo-dev
9+
10+
endpoint: http://localhost:8000 # comment out if want to test with real dynamodb
11+
# on AWS. You can also set the DYNAMODB_ENDPOINT environment variable.
12+
# You can also are actually deploying a development environment is to
13+
# change bin/server and export DYNAMODB_ENDPOINT=http://localhost:8000 at the top
14+
# there.
15+
16+
test:
17+
# table_namespace: proj # do not include the env
18+
endpoint: http://localhost:8000
19+
table_namespace: <%= Jets.config.table_namespace %>
20+
21+
production:
22+
table_namespace: <%= Jets.config.table_namespace %>

config/environments/development.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Jets.application.configure do
2+
# Example:
3+
# config.function.memory_size = 1536
4+
5+
# config.action_mailer.raise_delivery_errors = false
6+
# Docs: http://rubyonjets.com/docs/email-sending/
7+
end

config/environments/production.rb

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Jets.application.configure do
2+
# Example:
3+
# config.function.memory_size = 2048
4+
5+
# Ignore bad email addresses and do not raise email delivery errors.
6+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
7+
# Docs: http://rubyonjets.com/docs/email-sending/
8+
# config.action_mailer.raise_delivery_errors = false
9+
end

config/environments/test.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Jets.application.configure do
2+
# Tell Action Mailer not to deliver emails to the real world.
3+
# The :test delivery method accumulates sent emails in the
4+
# ActionMailer::Base.deliveries array.
5+
# Docs: http://rubyonjets.com/docs/email-sending/
6+
config.action_mailer.delivery_method = :test
7+
end

config/routes.rb

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Jets.application.routes.draw do
2+
root "jets/public#show"
3+
4+
# The jets/public#show controller can serve static utf8 content out of the public folder.
5+
# Note, as part of the deploy process Jets uploads files in the public folder to s3
6+
# and serves them out of s3 directly. S3 is well suited to serve static assets.
7+
# More info here: http://rubyonjets.com/docs/assets-serving/
8+
any "*catchall", to: "jets/public#show"
9+
end

db/.gitkeep

Whitespace-only changes.

db/seeds.rb

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3.times do |i|
2+
Post.create(title: "Title #{i+1}")
3+
end
4+
puts "Seeding data completed"

public/404.html

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>The page you were looking for doesn't exist (404)</title>
5+
<meta name="viewport" content="width=device-width,initial-scale=1">
6+
<style>
7+
.rails-default-error-page {
8+
background-color: #EFEFEF;
9+
color: #2E2F30;
10+
text-align: center;
11+
font-family: arial, sans-serif;
12+
margin: 0;
13+
}
14+
15+
.rails-default-error-page div.dialog {
16+
width: 95%;
17+
max-width: 33em;
18+
margin: 4em auto 0;
19+
}
20+
21+
.rails-default-error-page div.dialog > div {
22+
border: 1px solid #CCC;
23+
border-right-color: #999;
24+
border-left-color: #999;
25+
border-bottom-color: #BBB;
26+
border-top: #B00100 solid 4px;
27+
border-top-left-radius: 9px;
28+
border-top-right-radius: 9px;
29+
background-color: white;
30+
padding: 7px 12% 0;
31+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32+
}
33+
34+
.rails-default-error-page h1 {
35+
font-size: 100%;
36+
color: #730E15;
37+
line-height: 1.5em;
38+
}
39+
40+
.rails-default-error-page div.dialog > p {
41+
margin: 0 0 1em;
42+
padding: 1em;
43+
background-color: #F7F7F7;
44+
border: 1px solid #CCC;
45+
border-right-color: #999;
46+
border-left-color: #999;
47+
border-bottom-color: #999;
48+
border-bottom-left-radius: 4px;
49+
border-bottom-right-radius: 4px;
50+
border-top-color: #DADADA;
51+
color: #666;
52+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53+
}
54+
</style>
55+
</head>
56+
57+
<body class="rails-default-error-page">
58+
<!-- This file lives in public/404.html -->
59+
<div class="dialog">
60+
<div>
61+
<h1>The page you were looking for doesn't exist.</h1>
62+
<p>You may have mistyped the address or the page may have moved.</p>
63+
</div>
64+
<p>If you are the application owner check the logs for more information.</p>
65+
</div>
66+
</body>
67+
</html>

public/422.html

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>The change you wanted was rejected (422)</title>
5+
<meta name="viewport" content="width=device-width,initial-scale=1">
6+
<style>
7+
.rails-default-error-page {
8+
background-color: #EFEFEF;
9+
color: #2E2F30;
10+
text-align: center;
11+
font-family: arial, sans-serif;
12+
margin: 0;
13+
}
14+
15+
.rails-default-error-page div.dialog {
16+
width: 95%;
17+
max-width: 33em;
18+
margin: 4em auto 0;
19+
}
20+
21+
.rails-default-error-page div.dialog > div {
22+
border: 1px solid #CCC;
23+
border-right-color: #999;
24+
border-left-color: #999;
25+
border-bottom-color: #BBB;
26+
border-top: #B00100 solid 4px;
27+
border-top-left-radius: 9px;
28+
border-top-right-radius: 9px;
29+
background-color: white;
30+
padding: 7px 12% 0;
31+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32+
}
33+
34+
.rails-default-error-page h1 {
35+
font-size: 100%;
36+
color: #730E15;
37+
line-height: 1.5em;
38+
}
39+
40+
.rails-default-error-page div.dialog > p {
41+
margin: 0 0 1em;
42+
padding: 1em;
43+
background-color: #F7F7F7;
44+
border: 1px solid #CCC;
45+
border-right-color: #999;
46+
border-left-color: #999;
47+
border-bottom-color: #999;
48+
border-bottom-left-radius: 4px;
49+
border-bottom-right-radius: 4px;
50+
border-top-color: #DADADA;
51+
color: #666;
52+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53+
}
54+
</style>
55+
</head>
56+
57+
<body class="rails-default-error-page">
58+
<!-- This file lives in public/422.html -->
59+
<div class="dialog">
60+
<div>
61+
<h1>The change you wanted was rejected.</h1>
62+
<p>Maybe you tried to change something you didn't have access to.</p>
63+
</div>
64+
<p>If you are the application owner check the logs for more information.</p>
65+
</div>
66+
</body>
67+
</html>

0 commit comments

Comments
 (0)