Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .ebextensions/00_setup_swap.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
commands:
setup_swap:
test: test ! -e /var/swapfile
command: |
/bin/dd if=/dev/zero of=/var/swapfile bs=1M count=2048
/bin/chmod 600 /var/swapfile
/sbin/mkswap /var/swapfile
/sbin/swapon /var/swapfile
6 changes: 6 additions & 0 deletions .ebextensions/01_set_vars.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
commands:
set_env_vars:
command: /opt/elasticbeanstalk/bin/get-config environment | jq -r 'to_entries | .[] | "export \(.key)=\"\(.value)\""' > /etc/profile.d/sh.local
packages:
yum:
jq: []
7 changes: 7 additions & 0 deletions .ebextensions/02_install_yarn.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
commands:
install_yarn:
command: |
set -e
npm i -g yarn
ln -s "$(npm bin --global)"/yarn /usr/bin/yarn
test: "! yarn -v"
12 changes: 12 additions & 0 deletions .ebextensions/03_alb_default_process.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
option_settings:
aws:elasticbeanstalk:environment:process:default:
DeregistrationDelay: '20'
HealthCheckInterval: '15'
HealthCheckPath: /okcomputer
HealthCheckTimeout: '5'
HealthyThresholdCount: '3'
UnhealthyThresholdCount: '5'
Port: '80'
Protocol: HTTP
StickinessEnabled: 'true'
StickinessLBCookieDuration: '43200'
3 changes: 3 additions & 0 deletions .ebextensions/04_update_bundler.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
commands:
update_bundler:
command: /usr/bin/gem install bundler -v 2.5.3
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-3.3.0
ruby-3.2.2
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.3.0'
ruby '3.2.2'

gem 'rails', '~> 7.1', '>= 7.1.3'

Expand Down
7 changes: 6 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ GEM
globalid (1.2.1)
activesupport (>= 6.1)
google-protobuf (3.25.2)
google-protobuf (3.25.2-aarch64-linux)
google-protobuf (3.25.2-arm64-darwin)
google-protobuf (3.25.2-x86-linux)
google-protobuf (3.25.2-x86_64-darwin)
google-protobuf (3.25.2-x86_64-linux)
hashie (5.0.0)
honeybadger (5.4.1)
httparty (0.21.0)
Expand Down Expand Up @@ -692,7 +697,7 @@ DEPENDENCIES
wicked_pdf (~> 2.7)

RUBY VERSION
ruby 3.3.0p0
ruby 3.2.2p53

BUNDLED WITH
2.5.3
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ Things you may want to cover:
* ...

curl -v -X POST http://localhost:3001/api/users/sign_up -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{"api_user": {"email":"[email protected]", "password":"123456", "password_confirmation":"123456"}}'

curl -v -X POST http://localhost:3001/api/users/sign_in -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{"api_user": {"email":"[email protected]", "password":"123456"}}'

curl -v -X DELETE http://localhost:3001/api/users/sign_out -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer XYZ'

curl -X GET 'localhost:3001/api/v1/users' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer XYZ'
curl -X GET 'localhost:3001/api/v1/users/1' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer XYZ'
curl -X GET 'localhost:3001/api/v1/current_user' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer XYZ'
curl -X GET http://localhost:3001/api/v1/users -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer XYZ'

curl -X GET http://localhost:3001/api/v1/users/1 -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer XYZ'

curl -X GET http://localhost:3001/api/v1/current_user -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer XYZ'
50 changes: 50 additions & 0 deletions app/controllers/api/v1/charts_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# frozen_string_literal: true

module Api
module V1
class ChartsController < AuthenticatedApplicationController
def data
render json: {
target: 46,
current: 34,
baseline: 452.18,
targetTonnes: 300,
firstStage: 55,
firstStageVehicle: 27,
firstStagePropulsion: 33,
firstStageAvionics: 20,
firstStageThermal: 10,
firstStageAuxiliary: 10,
firstStageDesign: 32,
firstStageManufacture: 20,
firstStageTesting: 5,
firstStageFlight: 15,
firstStageEnd: 28,
secondStage: 26,
secondStageVehicle: 33,
secondStagePropulsion: 20,
secondStageAvionics: 27,
secondStageThermal: 15,
secondStageAuxiliary: 5,
secondStageDesign: 18,
secondStageManufacture: 42,
secondStageTesting: 17,
secondStageFlight: 3,
secondStageEnd: 20,
fairing: 19,
fairingStageVehicle: 21,
fairingStagePropulsion: 39,
fairingStageAvionics: 7,
fairingStageThermal: 20,
fairingStageAuxiliary: 13,
fairingStageDesign: 10,
fairingStageManufacture: 50,
fairingStageTesting: 5,
fairingStageFlight: 10,
fairingStageEnd: 25,
accuracy: 64
}, status: :ok
end
end
end
end
4 changes: 2 additions & 2 deletions app/controllers/api/v1/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ module Api
module V1
class UsersController < AuthenticatedApplicationController
def index
render json: User.all.order(:created_at).map { |user| serialize!(user) }, status: :ok
render json: ApiUser.all.order(:created_at).map { |user| serialize!(user) }, status: :ok
end

def show
render json: serialize!(User.find_by_id(params[:id])), status: :ok
render json: serialize!(ApiUser.find_by_id(params[:id])), status: :ok
end

def current_user
Expand Down
4 changes: 3 additions & 1 deletion config/environments/staging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
# config.assume_ssl = true

# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = true
config.force_ssl = false

# Log to STDOUT by default
config.logger = ActiveSupport::Logger.new(STDOUT)
Expand All @@ -71,6 +71,8 @@
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "rails_template_production"

Rails.application.routes.default_url_options[:host] = "#{ENV['URL_PROTOCOL']}://#{ENV['URL_HOST']}/"

config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = {
host: ENV['URL_HOST'],
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,6 @@
['DELETE', %r{^/api/users/sign_out$}]
]

jwt.expiration_time = 30.minutes.to_i
jwt.expiration_time = 600.minutes.to_i
end
end
28 changes: 15 additions & 13 deletions config/initializers/letter_opener.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# frozen_string_literal: true

require 'letter_opener'
if Rails.env.development?
require 'letter_opener'

LetterOpener.configure do |config|
# To overrider the location for message storage.
# Default value is `tmp/letter_opener`
# config.location = Rails.root.join('tmp', 'my_mails')
LetterOpener.configure do |config|
# To overrider the location for message storage.
# Default value is `tmp/letter_opener`
# config.location = Rails.root.join('tmp', 'my_mails')

# To render only the message body, without any metadata or extra containers or styling.
# Default value is `:default` that renders styled message with showing useful metadata.
config.message_template = :default
# To render only the message body, without any metadata or extra containers or styling.
# Default value is `:default` that renders styled message with showing useful metadata.
config.message_template = :default

# To change default file URI scheme you can provide `file_uri_scheme` config.
# It might be useful when you use WSL (Windows Subsystem for Linux) and default
# scheme doesn't work for you.
# Default value is blank
# config.file_uri_scheme = 'file://///wsl$/Ubuntu-18.04'
# To change default file URI scheme you can provide `file_uri_scheme` config.
# It might be useful when you use WSL (Windows Subsystem for Linux) and default
# scheme doesn't work for you.
# Default value is blank
# config.file_uri_scheme = 'file://///wsl$/Ubuntu-18.04'
end
end
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
defaults format: :json do
resources :users, only: %i(index show)
get '/current_user', to: 'users#current_user'

get '/charts_data', to: 'charts#data'
end
end
end
Expand Down