diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..bb56daf
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,31 @@
+# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.
+
+# Ignore git directory.
+/.git/
+
+# Ignore bundler config.
+/.bundle
+
+# Ignore all environment files (except templates).
+/.env*
+!/.env*.erb
+
+# Ignore all default key files.
+/config/master.key
+/config/credentials/*.key
+
+# Ignore all logfiles and tempfiles.
+/log/*
+/tmp/*
+!/log/.keep
+!/tmp/.keep
+
+# Ignore pidfiles, but keep the directory.
+/tmp/pids/*
+!/tmp/pids/.keep
+
+# Ignore storage (uploaded files in development and any SQLite databases).
+/storage/*
+!/storage/.keep
+/tmp/storage/*
+!/tmp/storage/.keep
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..8dc4323
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,9 @@
+# See https://git-scm.com/docs/gitattributes for more about git attribute files.
+
+# Mark the database schema as having been generated.
+db/schema.rb linguist-generated
+
+# Mark any vendored files as having been vendored.
+vendor/* linguist-vendored
+config/credentials/*.yml.enc diff=rails_credentials
+config/credentials.yml.enc diff=rails_credentials
diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml
new file mode 100644
index 0000000..560212b
--- /dev/null
+++ b/.github/workflows/linters.yml
@@ -0,0 +1,30 @@
+name: Linters
+
+on: pull_request
+
+env:
+ FORCE_COLOR: 1
+
+jobs:
+ rubocop:
+ name: Rubocop
+ runs-on: ubuntu-22.04
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-ruby@v1
+ with:
+ ruby-version: 3.1.x
+ - name: Setup Rubocop
+ run: |
+ gem install --no-document rubocop -v '>= 1.0, < 2.0' # https://docs.rubocop.org/en/stable/installation/
+ [ -f .rubocop.yml ] || wget https://raw.githubusercontent.com/microverseinc/linters-config/master/ror/.rubocop.yml
+ - name: Rubocop Report
+ run: rubocop --color
+ nodechecker:
+ name: node_modules checker
+ runs-on: ubuntu-22.04
+ steps:
+ - uses: actions/checkout@v3
+ - name: Check node_modules existence
+ run: |
+ if [ -d "node_modules/" ]; then echo -e "\e[1;31mThe node_modules/ folder was pushed to the repo. Please remove it from the GitHub repository and try again."; echo -e "\e[1;32mYou can set up a .gitignore file with this folder included on it to prevent this from happening in the future." && exit 1; fi
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..dadea69
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,34 @@
+# See https://help.github.com/articles/ignoring-files for more about ignoring files.
+#
+# If you find yourself ignoring temporary files generated by your text editor
+# or operating system, you probably want to add a global ignore instead:
+# git config --global core.excludesfile '~/.gitignore_global'
+
+# Ignore bundler config.
+/.bundle
+
+# Ignore all environment files (except templates).
+/.env*
+!/.env*.erb
+
+# Ignore all logfiles and tempfiles.
+/log/*
+/tmp/*
+!/log/.keep
+!/tmp/.keep
+
+# Ignore pidfiles, but keep the directory.
+/tmp/pids/*
+!/tmp/pids/
+!/tmp/pids/.keep
+
+# Ignore storage (uploaded files in development and any SQLite databases).
+/storage/*
+!/storage/.keep
+/tmp/storage/*
+!/tmp/storage/
+!/tmp/storage/.keep
+
+# Ignore master key for decrypting credentials and more.
+/config/master.key
+.env
\ No newline at end of file
diff --git a/.rspec b/.rspec
new file mode 100644
index 0000000..c99d2e7
--- /dev/null
+++ b/.rspec
@@ -0,0 +1 @@
+--require spec_helper
diff --git a/.rubocop.yml b/.rubocop.yml
new file mode 100644
index 0000000..5f4f67e
--- /dev/null
+++ b/.rubocop.yml
@@ -0,0 +1,62 @@
+AllCops:
+ NewCops: enable
+ Exclude:
+ - 'db/**/*'
+ - 'bin/*'
+ - 'config/**/*'
+ - 'Guardfile'
+ - 'Rakefile'
+ - 'node_modules/**/*'
+
+ DisplayCopNames: true
+
+Layout/LineLength:
+ Max: 125
+Metrics/MethodLength:
+ Include:
+ - 'app/controllers/*'
+ - 'app/models/*'
+ Max: 20
+Metrics/AbcSize:
+ Include:
+ - 'app/controllers/*'
+ - 'app/models/*'
+ Max: 50
+Metrics/ClassLength:
+ Max: 150
+Metrics/BlockLength:
+ AllowedMethods: ['describe']
+ Max: 40
+
+Style/Documentation:
+ Enabled: false
+Style/ClassAndModuleChildren:
+ Enabled: false
+Style/EachForSimpleLoop:
+ Enabled: false
+Style/AndOr:
+ Enabled: false
+Style/DefWithParentheses:
+ Enabled: false
+Style/FrozenStringLiteralComment:
+ EnforcedStyle: never
+
+Layout/EndOfLine:
+ Enabled: False
+Layout/HashAlignment:
+ EnforcedColonStyle: key
+Layout/ExtraSpacing:
+ AllowForAlignment: false
+Layout/MultilineMethodCallIndentation:
+ Enabled: true
+ EnforcedStyle: indented
+Lint/RaiseException:
+ Enabled: false
+Lint/StructNewOverride:
+ Enabled: false
+Style/HashEachMethods:
+ Enabled: false
+Style/HashTransformKeys:
+ Enabled: false
+Style/HashTransformValues:
+ Enabled: false
diff --git a/.ruby-version b/.ruby-version
new file mode 100644
index 0000000..9e79f6c
--- /dev/null
+++ b/.ruby-version
@@ -0,0 +1 @@
+ruby-3.2.2
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..c11422b
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,64 @@
+# syntax = docker/dockerfile:1
+
+# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
+ARG RUBY_VERSION=3.2.2
+FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base
+
+# Rails app lives here
+WORKDIR /rails
+
+# Set production environment
+ENV RAILS_ENV="production" \
+ BUNDLE_DEPLOYMENT="1" \
+ BUNDLE_PATH="/usr/local/bundle" \
+ BUNDLE_WITHOUT="development"
+
+
+# Throw-away build stage to reduce size of final image
+FROM base as build
+
+# Install packages needed to build gems
+RUN apt-get update -qq && \
+ apt-get install --no-install-recommends -y build-essential git libpq-dev libvips pkg-config
+
+# Install application gems
+COPY Gemfile Gemfile.lock ./
+RUN bundle install && \
+ rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
+ bundle exec bootsnap precompile --gemfile
+
+# Copy application code
+COPY . .
+
+# Precompile bootsnap code for faster boot times
+RUN bundle exec bootsnap precompile app/ lib/
+
+# Adjust binfiles to be executable on Linux
+RUN chmod +x bin/* && \
+ sed -i "s/\r$//g" bin/* && \
+ sed -i 's/ruby\.exe$/ruby/' bin/*
+
+
+# Final stage for app image
+FROM base
+
+# Install packages needed for deployment
+RUN apt-get update -qq && \
+ apt-get install --no-install-recommends -y curl libvips postgresql-client && \
+ rm -rf /var/lib/apt/lists /var/cache/apt/archives
+
+# Copy built artifacts: gems, application
+COPY --from=build /usr/local/bundle /usr/local/bundle
+COPY --from=build /rails /rails
+
+# Run and own only the runtime files as a non-root user for security
+RUN useradd rails --create-home --shell /bin/bash && \
+ chown -R rails:rails db log storage tmp
+USER rails:rails
+
+# Entrypoint prepares the database.
+ENTRYPOINT ["/rails/bin/docker-entrypoint"]
+
+# Start the server by default, this can be overwritten at runtime
+EXPOSE 3000
+CMD ["./bin/rails", "server"]
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000..8953448
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,56 @@
+source 'https://rubygems.org'
+
+ruby '3.2.2'
+
+# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
+gem 'faker', '~> 2.20'
+gem 'rails', '~> 7.1.1'
+gem 'rspec-rails'
+gem 'rswag'
+# gem 'rswag-api'
+# gem 'rswag-ui'
+# Use postgresql as the database for Active Record
+gem 'pg', '~> 1.1'
+
+# Use the Puma web server [https://github.com/puma/puma]
+gem 'puma', '>= 5.0'
+
+# Build JSON APIs with ease [https://github.com/rails/jbuilder]
+# gem "jbuilder"
+
+# Use Redis adapter to run Action Cable in production
+# gem "redis", ">= 4.0.1"
+
+# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
+# gem "kredis"
+
+gem 'devise'
+gem 'devise-jwt'
+gem 'jsonapi-serializer'
+# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
+# gem "bcrypt", "~> 3.1.7"
+
+# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
+gem 'tzinfo-data', platforms: %i[windows jruby]
+
+# Reduces boot times through caching; required in config/boot.rb
+gem 'bootsnap', require: false
+
+# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
+# gem "image_processing", "~> 1.2"
+
+# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin Ajax possible
+gem 'rack-cors'
+
+group :development, :test do
+ # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
+ gem 'debug', platforms: %i[mri windows]
+ gem 'dotenv-rails'
+end
+
+group :development do
+ # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
+ # gem "spring"
+ # gem 'rspec-rails'
+ # gem 'rswag-specs'
+end
diff --git a/Gemfile.lock b/Gemfile.lock
new file mode 100644
index 0000000..bed5804
--- /dev/null
+++ b/Gemfile.lock
@@ -0,0 +1,295 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ actioncable (7.1.1)
+ actionpack (= 7.1.1)
+ activesupport (= 7.1.1)
+ nio4r (~> 2.0)
+ websocket-driver (>= 0.6.1)
+ zeitwerk (~> 2.6)
+ actionmailbox (7.1.1)
+ actionpack (= 7.1.1)
+ activejob (= 7.1.1)
+ activerecord (= 7.1.1)
+ activestorage (= 7.1.1)
+ activesupport (= 7.1.1)
+ mail (>= 2.7.1)
+ net-imap
+ net-pop
+ net-smtp
+ actionmailer (7.1.1)
+ actionpack (= 7.1.1)
+ actionview (= 7.1.1)
+ activejob (= 7.1.1)
+ activesupport (= 7.1.1)
+ mail (~> 2.5, >= 2.5.4)
+ net-imap
+ net-pop
+ net-smtp
+ rails-dom-testing (~> 2.2)
+ actionpack (7.1.1)
+ actionview (= 7.1.1)
+ activesupport (= 7.1.1)
+ nokogiri (>= 1.8.5)
+ rack (>= 2.2.4)
+ rack-session (>= 1.0.1)
+ rack-test (>= 0.6.3)
+ rails-dom-testing (~> 2.2)
+ rails-html-sanitizer (~> 1.6)
+ actiontext (7.1.1)
+ actionpack (= 7.1.1)
+ activerecord (= 7.1.1)
+ activestorage (= 7.1.1)
+ activesupport (= 7.1.1)
+ globalid (>= 0.6.0)
+ nokogiri (>= 1.8.5)
+ actionview (7.1.1)
+ activesupport (= 7.1.1)
+ builder (~> 3.1)
+ erubi (~> 1.11)
+ rails-dom-testing (~> 2.2)
+ rails-html-sanitizer (~> 1.6)
+ activejob (7.1.1)
+ activesupport (= 7.1.1)
+ globalid (>= 0.3.6)
+ activemodel (7.1.1)
+ activesupport (= 7.1.1)
+ activerecord (7.1.1)
+ activemodel (= 7.1.1)
+ activesupport (= 7.1.1)
+ timeout (>= 0.4.0)
+ activestorage (7.1.1)
+ actionpack (= 7.1.1)
+ activejob (= 7.1.1)
+ activerecord (= 7.1.1)
+ activesupport (= 7.1.1)
+ marcel (~> 1.0)
+ activesupport (7.1.1)
+ base64
+ bigdecimal
+ concurrent-ruby (~> 1.0, >= 1.0.2)
+ connection_pool (>= 2.2.5)
+ drb
+ i18n (>= 1.6, < 2)
+ minitest (>= 5.1)
+ mutex_m
+ tzinfo (~> 2.0)
+ addressable (2.8.5)
+ public_suffix (>= 2.0.2, < 6.0)
+ base64 (0.1.1)
+ bcrypt (3.1.19)
+ bigdecimal (3.1.4)
+ bootsnap (1.17.0)
+ msgpack (~> 1.2)
+ builder (3.2.4)
+ concurrent-ruby (1.2.2)
+ connection_pool (2.4.1)
+ crass (1.0.6)
+ date (3.3.3)
+ debug (1.8.0)
+ irb (>= 1.5.0)
+ reline (>= 0.3.1)
+ devise (4.9.3)
+ bcrypt (~> 3.0)
+ orm_adapter (~> 0.1)
+ railties (>= 4.1.0)
+ responders
+ warden (~> 1.2.3)
+ devise-jwt (0.11.0)
+ devise (~> 4.0)
+ warden-jwt_auth (~> 0.8)
+ diff-lcs (1.5.0)
+ dotenv (2.8.1)
+ dotenv-rails (2.8.1)
+ dotenv (= 2.8.1)
+ railties (>= 3.2)
+ drb (2.1.1)
+ ruby2_keywords
+ dry-auto_inject (1.0.1)
+ dry-core (~> 1.0)
+ zeitwerk (~> 2.6)
+ dry-configurable (1.1.0)
+ dry-core (~> 1.0, < 2)
+ zeitwerk (~> 2.6)
+ dry-core (1.0.1)
+ concurrent-ruby (~> 1.0)
+ zeitwerk (~> 2.6)
+ erubi (1.12.0)
+ faker (2.23.0)
+ i18n (>= 1.8.11, < 2)
+ globalid (1.2.1)
+ activesupport (>= 6.1)
+ i18n (1.14.1)
+ concurrent-ruby (~> 1.0)
+ io-console (0.6.0)
+ irb (1.8.3)
+ rdoc
+ reline (>= 0.3.8)
+ json-schema (3.0.0)
+ addressable (>= 2.8)
+ jsonapi-serializer (2.2.0)
+ activesupport (>= 4.2)
+ jwt (2.7.1)
+ loofah (2.21.4)
+ crass (~> 1.0.2)
+ nokogiri (>= 1.12.0)
+ mail (2.8.1)
+ mini_mime (>= 0.1.1)
+ net-imap
+ net-pop
+ net-smtp
+ marcel (1.0.2)
+ mini_mime (1.1.5)
+ minitest (5.20.0)
+ msgpack (1.7.2)
+ mutex_m (0.1.2)
+ net-imap (0.4.3)
+ date
+ net-protocol
+ net-pop (0.1.2)
+ net-protocol
+ net-protocol (0.2.1)
+ timeout
+ net-smtp (0.4.0)
+ net-protocol
+ nio4r (2.5.9)
+ nokogiri (1.15.4-x64-mingw-ucrt)
+ racc (~> 1.4)
+ nokogiri (1.15.4-x86_64-darwin)
+ racc (~> 1.4)
+ nokogiri (1.15.4-x86_64-linux)
+ racc (~> 1.4)
+ orm_adapter (0.5.0)
+ pg (1.5.4)
+ pg (1.5.4-x64-mingw-ucrt)
+ psych (5.1.1.1)
+ stringio
+ public_suffix (5.0.3)
+ puma (6.4.0)
+ nio4r (~> 2.0)
+ racc (1.7.2)
+ rack (3.0.8)
+ rack-cors (2.0.1)
+ rack (>= 2.0.0)
+ rack-session (2.0.0)
+ rack (>= 3.0.0)
+ rack-test (2.1.0)
+ rack (>= 1.3)
+ rackup (2.1.0)
+ rack (>= 3)
+ webrick (~> 1.8)
+ rails (7.1.1)
+ actioncable (= 7.1.1)
+ actionmailbox (= 7.1.1)
+ actionmailer (= 7.1.1)
+ actionpack (= 7.1.1)
+ actiontext (= 7.1.1)
+ actionview (= 7.1.1)
+ activejob (= 7.1.1)
+ activemodel (= 7.1.1)
+ activerecord (= 7.1.1)
+ activestorage (= 7.1.1)
+ activesupport (= 7.1.1)
+ bundler (>= 1.15.0)
+ railties (= 7.1.1)
+ rails-dom-testing (2.2.0)
+ activesupport (>= 5.0.0)
+ minitest
+ nokogiri (>= 1.6)
+ rails-html-sanitizer (1.6.0)
+ loofah (~> 2.21)
+ nokogiri (~> 1.14)
+ railties (7.1.1)
+ actionpack (= 7.1.1)
+ activesupport (= 7.1.1)
+ irb
+ rackup (>= 1.0.0)
+ rake (>= 12.2)
+ thor (~> 1.0, >= 1.2.2)
+ zeitwerk (~> 2.6)
+ rake (13.1.0)
+ rdoc (6.5.0)
+ psych (>= 4.0.0)
+ reline (0.3.9)
+ io-console (~> 0.5)
+ responders (3.1.1)
+ actionpack (>= 5.2)
+ railties (>= 5.2)
+ rspec-core (3.12.2)
+ rspec-support (~> 3.12.0)
+ rspec-expectations (3.12.3)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.12.0)
+ rspec-mocks (3.12.6)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.12.0)
+ rspec-rails (6.0.3)
+ actionpack (>= 6.1)
+ activesupport (>= 6.1)
+ railties (>= 6.1)
+ rspec-core (~> 3.12)
+ rspec-expectations (~> 3.12)
+ rspec-mocks (~> 3.12)
+ rspec-support (~> 3.12)
+ rspec-support (3.12.1)
+ rswag (2.11.0)
+ rswag-api (= 2.11.0)
+ rswag-specs (= 2.11.0)
+ rswag-ui (= 2.11.0)
+ rswag-api (2.11.0)
+ railties (>= 3.1, < 7.2)
+ rswag-specs (2.11.0)
+ activesupport (>= 3.1, < 7.2)
+ json-schema (>= 2.2, < 4.0)
+ railties (>= 3.1, < 7.2)
+ rspec-core (>= 2.14)
+ rswag-ui (2.11.0)
+ actionpack (>= 3.1, < 7.2)
+ railties (>= 3.1, < 7.2)
+ ruby2_keywords (0.0.5)
+ stringio (3.0.8)
+ thor (1.3.0)
+ timeout (0.4.0)
+ tzinfo (2.0.6)
+ concurrent-ruby (~> 1.0)
+ tzinfo-data (1.2023.3)
+ tzinfo (>= 1.0.0)
+ warden (1.2.9)
+ rack (>= 2.0.9)
+ warden-jwt_auth (0.8.0)
+ dry-auto_inject (>= 0.8, < 2)
+ dry-configurable (>= 0.13, < 2)
+ jwt (~> 2.1)
+ warden (~> 1.2)
+ webrick (1.8.1)
+ websocket-driver (0.7.6)
+ websocket-extensions (>= 0.1.0)
+ websocket-extensions (0.1.5)
+ zeitwerk (2.6.12)
+
+PLATFORMS
+ x64-mingw-ucrt
+ x86_64-darwin-20
+ x86_64-linux
+
+DEPENDENCIES
+ bootsnap
+ debug
+ devise
+ devise-jwt
+ dotenv-rails
+ faker (~> 2.20)
+ jsonapi-serializer
+ pg (~> 1.1)
+ puma (>= 5.0)
+ rack-cors
+ rails (~> 7.1.1)
+ rspec-rails
+ rswag
+ tzinfo-data
+
+RUBY VERSION
+ ruby 3.2.2p53
+
+BUNDLED WITH
+ 2.4.20
diff --git a/LICENSE b/LICENSE
index 85e3bd5..40f4d8d 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2023 Chongtham Ruby Devi
+Copyright (c) 2023 Chongtham Ruby Devi, Yonas Henok and Riley Manda
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..833a265
--- /dev/null
+++ b/README.md
@@ -0,0 +1,305 @@
+
+
+
+
JetLogix
+
+
+
ER Diagrma
+
+
+
+
+
+
+
+
+
+
+# π Table of Contents
+
+- [π About the Project](#about-project)
+ - [π Front End](#front-end)
+ - [π Built With](#built-with)
+ - [Tech Stack](#tech-stack)
+ - [Key Features](#key-features)
+ - [π Live Demo](#live-demo)
+- [π» Getting Started](#getting-started)
+ - [Setup](#setup)
+ - [Prerequisites](#prerequisites)
+ - [Install](#install)
+ - [Usage](#usage)
+ - [Setup .ENV](#setup-env)
+ - [Run tests](#run-tests)
+ - [Deployment](#triangular_flag_on_post-deployment)
+- [π Kanban Board ](#kanban-board)
+- [π₯ Authors](#authors)
+- [π Future Features](#future-features)
+- [π€ Contributing](#contributing)
+- [βοΈ Show your support](#support)
+- [π Acknowledgements](#acknowledgements)
+- [π Attribution](#attribution)
+- [β FAQ](#faq)
+- [π License](#license)
+
+
+
+# π [JetLogix]
+
+JetLogixβs backend is a robust Rails application utilizing PostgreSQL database, managing private jet reservations. It exposes efficient API endpoints to JetLogix front, providing access to the applicationβs database and ensuring secure storage and retrieval private jets, user's, and reservation data.
+
+## π FrontEnd
+
+[Click here to see the JetLogix front end](https://github.com/rubydevi/jetlogix-frontend)
+
+## π Built With
+
+### Tech Stack
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+### Key Features
+
+> Exposes robust API endpoints to manage and access the applicationβs rich database.
+
+> Controllers to manage jets and reservations, allowing CRUD (Create, Read, Update, Delete) operations.
+
+> Secure user authentication and profile management
+> API documentation
+
+
+
+
+
+## π Live Demo
+
+> Live Demo of this application:
+
+- [Live Demo Link](https://jetlogix.onrender.com/)
+
+(back to top)
+
+
+
+## π» Getting Started
+
+To get a local copy up and running, follow these steps.
+
+### Prerequisites
+
+In order to run this project you need:
+
+### Setup
+
+Clone this repository to your desired folder:
+
+```sh
+ cd my-folder
+ git clone https://github.com/rubydevi/jetlogix-backend.git
+```
+
+### Install
+
+Install this project with:
+
+```sh
+ cd my-project
+
+ bundle install
+```
+
+### setup-env
+
+1. create an env file by running the following command
+
+```sh
+ touch .env
+```
+
+Or create the .env file manually at the root of the application.
+
+2. open databse.yml file and Find the default: &default section in the file and copy the credentials into your .env file:
+
+```sh
+ DATABASE_USERNAME=your_username
+ DATABASE_PASSWORD=your_password
+```
+
+### Usage
+
+To run the project, you will need to execute:
+
+```sh
+ rails credentials:edit
+
+ rails db:create
+
+ rails db:migrate
+
+ rails db:seed
+
+ rails s
+```
+
+### Run tests
+
+To run tests, run the following command:
+
+```sh
+ rails db:migrate RAILS_ENV=test
+ rspec spec/model/
+```
+
+
+
+
+
+(back to top)
+
+## π Kanban Board
+
+- [Kanban board](https://github.com/rubydevi/jetlogix-backend/projects/1)
+
+- [Kanban board initial state ](https://user-images.githubusercontent.com/112550568/279359779-a877a136-d14e-4813-8868-68b5b7aec9e6.png)
+
+- We are a team of 3 members as indicated in the authors section
+
+
+
+
+## π₯ Authors
+
+π€ Chongtham Ruby Devi
+
+- GitHub: [@rubydevi](https://github.com/rubydevi)
+- LinkedIn: [@Chongtham Ruby Devi](https://www.linkedin.com/in/chongtham-bhoomika/)
+
+π€ Yonas Henok
+
+- GitHub: [@YonasHenok](https://github.com/Yonashenok)
+- Twitter: [@YonasHenok3](https://www.twitter.com/YonasHenok3)
+- LinkedIn: [@Yonas Henok](https://www.linkedin.com/in/yonas-henok/)
+
+π€ Riley Manda
+
+- GitHub: [@RileyManda](https://github.com/RileyManda)
+- Twitter: [@rilecodez](https://twitter.com/rileycodez)
+- LinkedIn: [rileymanda](https://www.linkedin.com/in/rileymanda/)
+
+(back to top)
+
+
+
+## π Future Features
+
+> Video Presentation demo of the project
+
+> Deploy the application on render
+
+(back to top)
+
+
+
+## π€ Contributing
+
+Contributions, issues, and feature requests are welcome!
+
+Feel free to check the [issues page](https://github.com/rubydevi/jetlogix-backend/issues).
+
+(back to top)
+
+
+
+
+
+## Show your support π
+
+Thank you for taking the time to explore this project! Your support means a lot to me. If you find my project valuable and would like to contribute, here is one way you can support me:
+
+- Star the project βοΈ: Show your appreciation by starring this GitHub repository. It helps increase visibility and lets others know that the project is well-received.
+
+- Fork the project π΄ π£: If you're interested in making improvements or adding new features, feel free to fork the project. You can work on your own version and even submit pull requests to suggest changes.
+
+- Share with others πΊοΈ: Spread the word about this project. Share it on social media, mention it in relevant forums or communities, or recommend it to colleagues and friends who might find it useful.
+
+(back to top)
+
+
+
+## π Acknowledgments
+
+We would like to express my sincere gratitude to [Microverse](https://github.com/microverseinc), the dedicated reviewers, and collaborators. Your unwavering support, feedback, and collaborative efforts have played an immense role in making this journey a resounding success.
+A big thank you to [Murat Korkmaz](https://www.behance.net/muratk) for the providing the UX design inspiration for this project.
+
+(back to top)
+
+
+
+## β FAQ
+
+- **Question_1**
+
+ Do I have to use the vs code specifically?
+
+ - Answer_1
+
+ You can use any one of your favortite or prefered editors
+
+(back to top)
+
+
+
+## π₯ Attribution
+
+- This application's front-end UI design is based on the original design by: [Murat Korkmaz](https://www.behance.net/muratk)
+
+
+
+## π License
+
+[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](./LICENSE)
+
+(back to top)
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..9a5ea73
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,6 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require_relative "config/application"
+
+Rails.application.load_tasks
diff --git a/app-logo.png b/app-logo.png
new file mode 100644
index 0000000..fcc8f01
Binary files /dev/null and b/app-logo.png differ
diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb
new file mode 100644
index 0000000..d672697
--- /dev/null
+++ b/app/channels/application_cable/channel.rb
@@ -0,0 +1,4 @@
+module ApplicationCable
+ class Channel < ActionCable::Channel::Base
+ end
+end
diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb
new file mode 100644
index 0000000..0ff5442
--- /dev/null
+++ b/app/channels/application_cable/connection.rb
@@ -0,0 +1,4 @@
+module ApplicationCable
+ class Connection < ActionCable::Connection::Base
+ end
+end
diff --git a/app/controllers/aeroplanes_controller.rb b/app/controllers/aeroplanes_controller.rb
new file mode 100644
index 0000000..6a281af
--- /dev/null
+++ b/app/controllers/aeroplanes_controller.rb
@@ -0,0 +1,46 @@
+class AeroplanesController < ApplicationController
+ before_action :set_aeroplane, only: %i[show update destroy]
+ before_action :authenticate_user!
+
+ # GET /aeroplanes
+ def index
+ @aeroplanes = Aeroplane.all
+
+ render json: @aeroplanes
+ end
+
+ # GET /aeroplanes/1
+ def show
+ render json: @aeroplane
+ end
+
+ # POST /aeroplanes
+ def create
+ @aeroplane = Aeroplane.new(aeroplane_params)
+ # @aeroplane.user = User.id
+
+ if @aeroplane.save
+ render json: @aeroplane, status: :created, location: @aeroplane
+ else
+ render json: { errors: @aeroplane.errors.full_messages }, status: :unprocessable_entity
+ end
+ end
+
+ # DELETE /aeroplanes/1
+ def destroy
+ @aeroplane.destroy!
+ end
+
+ private
+
+ # Use callbacks to share common setup or constraints between actions.
+ def set_aeroplane
+ @aeroplane = Aeroplane.find(params[:id])
+ end
+
+ # Only allow a list of trusted parameters through.
+ def aeroplane_params
+ params.require(:aeroplane).permit(:name, :model, :image, :description, :number_of_seats, :location, :fee,
+ :reserved)
+ end
+end
diff --git a/app/controllers/api/v1/aeroplanes_controller.rb b/app/controllers/api/v1/aeroplanes_controller.rb
new file mode 100644
index 0000000..45cbe37
--- /dev/null
+++ b/app/controllers/api/v1/aeroplanes_controller.rb
@@ -0,0 +1,47 @@
+class Api::V1::AeroplanesController < ApplicationController
+ # GET /aeroplanes
+ def index
+ @aeroplanes = Aeroplane.all
+ render json: { aeroplanes: @aeroplanes }
+ end
+
+ # GET /aeroplanes/1
+ def show
+ @aeroplane = Aeroplane.find(params[:id])
+ render json: @aeroplane
+ end
+
+ def create
+ @aeroplane = Aeroplane.new(aeroplane_params)
+
+ if @aeroplane.save
+ render json: @aeroplane, status: :created
+ else
+ render json: @aeroplane.errors, status: :unprocessable_entity
+ end
+ end
+
+ # DELETE /aeroplanes/1
+ def destroy
+ @aeroplane = Aeroplane.find(params[:id])
+
+ if @aeroplane.destroy
+ render json: { message: 'Aeroplane deleted successfully' }, status: :no_content
+ else
+ render json: { error: 'Failed to delete aeroplane' }, status: :unprocessable_entity
+ end
+ end
+
+ private
+
+ # Use callbacks to share common setup or constraints between actions.
+ def set_aeroplane
+ @aeroplane = Aeroplane.find(params[:id])
+ end
+
+ # Only allow a list of trusted parameters through.
+ def aeroplane_params
+ params.require(:aeroplane).permit(:name, :model, :image, :description, :number_of_seats, :location, :fee,
+ :reserved)
+ end
+end
diff --git a/app/controllers/api/v1/reservations_controller.rb b/app/controllers/api/v1/reservations_controller.rb
new file mode 100644
index 0000000..2417569
--- /dev/null
+++ b/app/controllers/api/v1/reservations_controller.rb
@@ -0,0 +1,57 @@
+class Api::V1::ReservationsController < ApplicationController
+ before_action :authenticate_user!
+ before_action :set_reservation, only: %i[show update destroy]
+
+ # GET /reservations
+ def index
+ @reservations = Reservation.all
+ render json: @reservations
+ end
+
+ # GET /reservations/1
+ def show
+ render json: @reservation
+ end
+
+ # POST /reservations
+ def create
+ @reservation = Reservation.new(reservation_params)
+
+ if @reservation.save
+ render json: @reservation, status: :created
+ else
+ render json: @reservation.errors, status: :unprocessable_entity
+ end
+ end
+
+ # PATCH/PUT /reservations/1
+ def update
+ if @reservation.update(reservation_params)
+ render json: @reservation
+ else
+ render json: @reservation.errors, status: :unprocessable_entity
+ end
+ end
+
+ # DELETE /reservations/1
+ def destroy
+ if @reservation.destroy!
+ render json: { message: 'Reservation deleted successfully' }, status: :no_content
+ else
+ render json: { error: 'Failed to delete Reservation' }, status: :unprocessable_entity
+ end
+ end
+
+ private
+
+ # Use callbacks to share common setup or constraints between actions.
+ def set_reservation
+ @reservation = Reservation.find(params[:id])
+ end
+
+ # Only allow a list of trusted parameters through.
+ def reservation_params
+ params.require(:reservation).permit(:reserved_date, :start_time, :end_time, :total_cost, :start_location,
+ :destination, :user_id, :aeroplane_id, :name)
+ end
+end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
new file mode 100644
index 0000000..de0cea4
--- /dev/null
+++ b/app/controllers/application_controller.rb
@@ -0,0 +1,10 @@
+class ApplicationController < ActionController::API
+ before_action :update_allowed_parameters, if: :devise_controller?
+
+ def update_allowed_parameters
+ devise_parameter_sanitizer.permit(:sign_up) { |u| u.permit(:name, :email, :password) }
+ devise_parameter_sanitizer.permit(:account_update) do |u|
+ u.permit(:name, :email, :password, :current_password)
+ end
+ end
+end
diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/app/controllers/concerns/rack_session_fix.rb b/app/controllers/concerns/rack_session_fix.rb
new file mode 100644
index 0000000..f4e6cfd
--- /dev/null
+++ b/app/controllers/concerns/rack_session_fix.rb
@@ -0,0 +1,17 @@
+module RackSessionFix
+ extend ActiveSupport::Concern
+ class FakeRackSession < Hash
+ def enabled?
+ false
+ end
+ end
+ included do
+ before_action :set_fake_rack_session_for_devise
+
+ private
+
+ def set_fake_rack_session_for_devise
+ request.env['rack.session'] ||= FakeRackSession.new
+ end
+ end
+end
diff --git a/app/controllers/reservations_controller.rb b/app/controllers/reservations_controller.rb
new file mode 100644
index 0000000..113b037
--- /dev/null
+++ b/app/controllers/reservations_controller.rb
@@ -0,0 +1,48 @@
+class ReservationsController < ApplicationController
+ before_action :set_reservation, only: %i[show update destroy]
+
+ # GET /reservations
+ def index
+ @reservations = Reservation.all
+
+ render json: @reservations
+ end
+
+ # GET /reservations/1
+ def show
+ render json: @reservation
+ end
+
+ # POST /reservations
+ def create
+ @reservation = Reservation.new(reservation_params)
+
+ if @reservation.save
+ render json: @reservation, status: :created, location: @reservation
+ else
+ render json: @reservation.errors, status: :unprocessable_entity
+ end
+ end
+
+ # PATCH/PUT /reservations/1
+ def update
+ if @reservation.update(reservation_params)
+ render json: @reservation
+ else
+ render json: @reservation.errors, status: :unprocessable_entity
+ end
+ end
+
+ private
+
+ # Use callbacks to share common setup or constraints between actions.
+ def set_reservation
+ @reservation = Reservation.find(params[:id])
+ end
+
+ # Only allow a list of trusted parameters through.
+ def reservation_params
+ params.require(:reservation).permit(:reserved_date, :start_time, :end_time, :total_cost, :start_location,
+ :destination, :user_id, :aeroplane_id, :name)
+ end
+end
diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb
new file mode 100644
index 0000000..caf0a2e
--- /dev/null
+++ b/app/controllers/users/registrations_controller.rb
@@ -0,0 +1,80 @@
+class Users::RegistrationsController < Devise::RegistrationsController
+ include RackSessionFix
+ respond_to :json
+ # before_action :configure_sign_up_params, only: [:create]
+ # before_action :configure_account_update_params, only: [:update]
+
+ # GET /resource/sign_up
+ # def new
+ # super
+ # end
+
+ # POST /resource
+ # def create
+ # super
+ # end
+
+ # GET /resource/edit
+ # def edit
+ # super
+ # end
+
+ # PUT /resource
+ # def update
+ # super
+ # end
+
+ # DELETE /resource
+ # def destroy
+ # super
+ # end
+
+ # GET /resource/cancel
+ # Forces the session data which is usually expired after sign
+ # in to be expired now. This is useful if the user wants to
+ # cancel oauth signing in/up in the middle of the process,
+ # removing all OAuth session data.
+ # def cancel
+ # super
+ # end
+
+ # protected
+
+ # If you have extra params to permit, append them to the sanitizer.
+ # def configure_sign_up_params
+ # devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])
+ # end
+
+ # If you have extra params to permit, append them to the sanitizer.
+ # def configure_account_update_params
+ # devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
+ # end
+
+ # The path used after sign up.
+ # def after_sign_up_path_for(resource)
+ # super(resource)
+ # end
+
+ # The path used after sign up for inactive accounts.
+ # def after_inactive_sign_up_path_for(resource)
+ # super(resource)
+ # end
+ private
+
+ def respond_with(resource, _opts = {})
+ if request.method == 'POST' && resource.persisted?
+ render json: {
+ status: { code: 200, message: 'Signed up sucessfully.' },
+ data: UserSerializer.new(resource).serializable_hash[:data][:attributes]
+ }, status: :ok
+ elsif request.method == 'DELETE'
+ render json: {
+ status: { code: 200, message: 'Account deleted successfully.' }
+ }, status: :ok
+ else
+ render json: {
+ status: { code: 422, message: "User couldn't be created . #{resource.errors.full_messages.to_sentence}" }
+ }, status: :unprocessable_entity
+ end
+ end
+end
diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb
new file mode 100644
index 0000000..88df83d
--- /dev/null
+++ b/app/controllers/users/sessions_controller.rb
@@ -0,0 +1,49 @@
+class Users::SessionsController < Devise::SessionsController
+ include RackSessionFix
+ respond_to :json
+ # before_action :configure_sign_in_params, only: [:create]
+
+ # GET /resource/sign_in
+ # def new
+ # super
+ # end
+
+ # POST /resource/sign_in
+ # def create
+ # super
+ # end
+
+ # DELETE /resource/sign_out
+ # def destroy
+ # super
+ # end
+
+ # protected
+
+ # If you have extra params to permit, append them to the sanitizer.
+ # def configure_sign_in_params
+ # devise_parameter_sanitizer.permit(:sign_in, keys: [:attribute])
+ # end
+ private
+
+ def respond_with(resource, _opts = {})
+ render json: {
+ status: { code: 200, message: 'Logged in sucessfully.' },
+ data: UserSerializer.new(resource).serializable_hash[:data][:attributes]
+ }, status: :ok
+ end
+
+ def respond_to_on_destroy
+ if current_user
+ render json: {
+ status: 200,
+ message: 'logged out successfully'
+ }, status: :ok
+ else
+ render json: {
+ status: 401,
+ message: "Couldn't find an active session."
+ }, status: :unauthorized
+ end
+ end
+end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
new file mode 100644
index 0000000..c227359
--- /dev/null
+++ b/app/controllers/users_controller.rb
@@ -0,0 +1,52 @@
+class UsersController < ApplicationController
+ before_action :set_user, only: %i[show update destroy]
+
+ # GET /users
+ def index
+ @users = User.all
+
+ render json: @users
+ end
+
+ # GET /users/1
+ def show
+ render json: @user
+ end
+
+ # POST /users
+ def create
+ @user = User.new(user_params)
+
+ if @user.save
+ render json: @user, status: :created, location: @user
+ else
+ render json: @user.errors, status: :unprocessable_entity
+ end
+ end
+
+ # PATCH/PUT /users/1
+ def update
+ if @user.update(user_params)
+ render json: @user
+ else
+ render json: @user.errors, status: :unprocessable_entity
+ end
+ end
+
+ # DELETE /users/1
+ def destroy
+ @user.destroy!
+ end
+
+ private
+
+ # Use callbacks to share common setup or constraints between actions.
+ def set_user
+ @user = User.find(params[:id])
+ end
+
+ # Only allow a list of trusted parameters through.
+ def user_params
+ params.require(:user).permit(:name)
+ end
+end
diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb
new file mode 100644
index 0000000..d394c3d
--- /dev/null
+++ b/app/jobs/application_job.rb
@@ -0,0 +1,7 @@
+class ApplicationJob < ActiveJob::Base
+ # Automatically retry jobs that encountered a deadlock
+ # retry_on ActiveRecord::Deadlocked
+
+ # Most jobs are safe to ignore if the underlying records are no longer available
+ # discard_on ActiveJob::DeserializationError
+end
diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb
new file mode 100644
index 0000000..286b223
--- /dev/null
+++ b/app/mailers/application_mailer.rb
@@ -0,0 +1,4 @@
+class ApplicationMailer < ActionMailer::Base
+ default from: 'from@example.com'
+ layout 'mailer'
+end
diff --git a/app/models/aeroplane.rb b/app/models/aeroplane.rb
new file mode 100644
index 0000000..4b50035
--- /dev/null
+++ b/app/models/aeroplane.rb
@@ -0,0 +1,11 @@
+class Aeroplane < ApplicationRecord
+ has_many :reservations, dependent: :destroy
+
+ validates :name, presence: true
+ validates :model, presence: true
+ validates :image, presence: true
+ validates :description, presence: true
+ validates :number_of_seats, presence: true
+ validates :location, presence: true
+ validates :fee, numericality: { greater_than_or_equal_to: 0 }
+end
diff --git a/app/models/application_record.rb b/app/models/application_record.rb
new file mode 100644
index 0000000..b63caeb
--- /dev/null
+++ b/app/models/application_record.rb
@@ -0,0 +1,3 @@
+class ApplicationRecord < ActiveRecord::Base
+ primary_abstract_class
+end
diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/app/models/reservation.rb b/app/models/reservation.rb
new file mode 100644
index 0000000..7ab037b
--- /dev/null
+++ b/app/models/reservation.rb
@@ -0,0 +1,9 @@
+class Reservation < ApplicationRecord
+ belongs_to :user
+ belongs_to :aeroplane
+
+ validates :user, presence: true
+ validates :aeroplane, presence: true
+ validates :destination, presence: true
+ validates :reserved_date, presence: true
+end
diff --git a/app/models/user.rb b/app/models/user.rb
new file mode 100644
index 0000000..8a89197
--- /dev/null
+++ b/app/models/user.rb
@@ -0,0 +1,11 @@
+class User < ApplicationRecord
+ include Devise::JWT::RevocationStrategies::JTIMatcher
+ # Include default devise modules. Others available are:
+ # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
+ devise :database_authenticatable, :registerable,
+ :validatable, :jwt_authenticatable, jwt_revocation_strategy: self
+
+ has_many :reservations, foreign_key: 'user_id', dependent: :destroy
+
+ validates :name, presence: true
+end
diff --git a/app/serializers/user_serializer.rb b/app/serializers/user_serializer.rb
new file mode 100644
index 0000000..4ffa29a
--- /dev/null
+++ b/app/serializers/user_serializer.rb
@@ -0,0 +1,8 @@
+class UserSerializer
+ include JSONAPI::Serializer
+ attributes :id, :email, :created_at, :name, :role
+
+ attribute :created_date do |user|
+ user.created_at&.strftime('%m/%d/%Y')
+ end
+end
diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb
new file mode 100644
index 0000000..3aac900
--- /dev/null
+++ b/app/views/layouts/mailer.html.erb
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+ <%= yield %>
+
+
diff --git a/app/views/layouts/mailer.text.erb b/app/views/layouts/mailer.text.erb
new file mode 100644
index 0000000..37f0bdd
--- /dev/null
+++ b/app/views/layouts/mailer.text.erb
@@ -0,0 +1 @@
+<%= yield %>
diff --git a/bin/bundle b/bin/bundle
new file mode 100644
index 0000000..42c7fd7
--- /dev/null
+++ b/bin/bundle
@@ -0,0 +1,109 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'bundle' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require "rubygems"
+
+m = Module.new do
+ module_function
+
+ def invoked_as_script?
+ File.expand_path($0) == File.expand_path(__FILE__)
+ end
+
+ def env_var_version
+ ENV["BUNDLER_VERSION"]
+ end
+
+ def cli_arg_version
+ return unless invoked_as_script? # don't want to hijack other binstubs
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
+ bundler_version = nil
+ update_index = nil
+ ARGV.each_with_index do |a, i|
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
+ bundler_version = a
+ end
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
+ bundler_version = $1
+ update_index = i
+ end
+ bundler_version
+ end
+
+ def gemfile
+ gemfile = ENV["BUNDLE_GEMFILE"]
+ return gemfile if gemfile && !gemfile.empty?
+
+ File.expand_path("../Gemfile", __dir__)
+ end
+
+ def lockfile
+ lockfile =
+ case File.basename(gemfile)
+ when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
+ else "#{gemfile}.lock"
+ end
+ File.expand_path(lockfile)
+ end
+
+ def lockfile_version
+ return unless File.file?(lockfile)
+ lockfile_contents = File.read(lockfile)
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
+ Regexp.last_match(1)
+ end
+
+ def bundler_requirement
+ @bundler_requirement ||=
+ env_var_version ||
+ cli_arg_version ||
+ bundler_requirement_for(lockfile_version)
+ end
+
+ def bundler_requirement_for(version)
+ return "#{Gem::Requirement.default}.a" unless version
+
+ bundler_gem_version = Gem::Version.new(version)
+
+ bundler_gem_version.approximate_recommendation
+ end
+
+ def load_bundler!
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
+
+ activate_bundler
+ end
+
+ def activate_bundler
+ gem_error = activation_error_handling do
+ gem "bundler", bundler_requirement
+ end
+ return if gem_error.nil?
+ require_error = activation_error_handling do
+ require "bundler/version"
+ end
+ return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
+ warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
+ exit 42
+ end
+
+ def activation_error_handling
+ yield
+ nil
+ rescue StandardError, LoadError => e
+ e
+ end
+end
+
+m.load_bundler!
+
+if m.invoked_as_script?
+ load Gem.bin_path("bundler", "bundle")
+end
diff --git a/bin/bundle.cmd b/bin/bundle.cmd
new file mode 100644
index 0000000..32a58d8
--- /dev/null
+++ b/bin/bundle.cmd
@@ -0,0 +1,112 @@
+@ruby -x "%~f0" %*
+@exit /b %ERRORLEVEL%
+
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'bundle' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require "rubygems"
+
+m = Module.new do
+ module_function
+
+ def invoked_as_script?
+ File.expand_path($0) == File.expand_path(__FILE__)
+ end
+
+ def env_var_version
+ ENV["BUNDLER_VERSION"]
+ end
+
+ def cli_arg_version
+ return unless invoked_as_script? # don't want to hijack other binstubs
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
+ bundler_version = nil
+ update_index = nil
+ ARGV.each_with_index do |a, i|
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
+ bundler_version = a
+ end
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
+ bundler_version = $1
+ update_index = i
+ end
+ bundler_version
+ end
+
+ def gemfile
+ gemfile = ENV["BUNDLE_GEMFILE"]
+ return gemfile if gemfile && !gemfile.empty?
+
+ File.expand_path("../Gemfile", __dir__)
+ end
+
+ def lockfile
+ lockfile =
+ case File.basename(gemfile)
+ when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
+ else "#{gemfile}.lock"
+ end
+ File.expand_path(lockfile)
+ end
+
+ def lockfile_version
+ return unless File.file?(lockfile)
+ lockfile_contents = File.read(lockfile)
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
+ Regexp.last_match(1)
+ end
+
+ def bundler_requirement
+ @bundler_requirement ||=
+ env_var_version ||
+ cli_arg_version ||
+ bundler_requirement_for(lockfile_version)
+ end
+
+ def bundler_requirement_for(version)
+ return "#{Gem::Requirement.default}.a" unless version
+
+ bundler_gem_version = Gem::Version.new(version)
+
+ bundler_gem_version.approximate_recommendation
+ end
+
+ def load_bundler!
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
+
+ activate_bundler
+ end
+
+ def activate_bundler
+ gem_error = activation_error_handling do
+ gem "bundler", bundler_requirement
+ end
+ return if gem_error.nil?
+ require_error = activation_error_handling do
+ require "bundler/version"
+ end
+ return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
+ warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
+ exit 42
+ end
+
+ def activation_error_handling
+ yield
+ nil
+ rescue StandardError, LoadError => e
+ e
+ end
+end
+
+m.load_bundler!
+
+if m.invoked_as_script?
+ load Gem.bin_path("bundler", "bundle")
+end
diff --git a/bin/docker-entrypoint b/bin/docker-entrypoint
new file mode 100644
index 0000000..67ef493
--- /dev/null
+++ b/bin/docker-entrypoint
@@ -0,0 +1,8 @@
+#!/bin/bash -e
+
+# If running the rails server then create or migrate existing database
+if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then
+ ./bin/rails db:prepare
+fi
+
+exec "${@}"
diff --git a/bin/rails b/bin/rails
new file mode 100644
index 0000000..7bcc36e
--- /dev/null
+++ b/bin/rails
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby.exe
+APP_PATH = File.expand_path("../config/application", __dir__)
+require_relative "../config/boot"
+require "rails/commands"
diff --git a/bin/rake b/bin/rake
new file mode 100644
index 0000000..01f7fc0
--- /dev/null
+++ b/bin/rake
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby.exe
+require_relative "../config/boot"
+require "rake"
+Rake.application.run
diff --git a/bin/setup b/bin/setup
new file mode 100644
index 0000000..11696f3
--- /dev/null
+++ b/bin/setup
@@ -0,0 +1,33 @@
+#!/usr/bin/env ruby.exe
+require "fileutils"
+
+# path to your application root.
+APP_ROOT = File.expand_path("..", __dir__)
+
+def system!(*args)
+ system(*args, exception: true)
+end
+
+FileUtils.chdir APP_ROOT do
+ # This script is a way to set up or update your development environment automatically.
+ # This script is idempotent, so that you can run it at any time and get an expectable outcome.
+ # Add necessary setup steps to this file.
+
+ puts "== Installing dependencies =="
+ system! "gem install bundler --conservative"
+ system("bundle check") || system!("bundle install")
+
+ # puts "\n== Copying sample files =="
+ # unless File.exist?("config/database.yml")
+ # FileUtils.cp "config/database.yml.sample", "config/database.yml"
+ # end
+
+ puts "\n== Preparing database =="
+ system! "bin/rails db:prepare"
+
+ puts "\n== Removing old logs and tempfiles =="
+ system! "bin/rails log:clear tmp:clear"
+
+ puts "\n== Restarting application server =="
+ system! "bin/rails restart"
+end
diff --git a/config.ru b/config.ru
new file mode 100644
index 0000000..ad1fbf2
--- /dev/null
+++ b/config.ru
@@ -0,0 +1,6 @@
+# This file is used by Rack-based servers to start the application.
+
+require_relative 'config/environment'
+
+run Rails.application
+Rails.application.load_server
diff --git a/config/application.rb b/config/application.rb
new file mode 100644
index 0000000..52b93b2
--- /dev/null
+++ b/config/application.rb
@@ -0,0 +1,32 @@
+require_relative "boot"
+
+require "rails/all"
+
+# Require the gems listed in Gemfile, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(*Rails.groups)
+
+module JetlogixBackend
+ class Application < Rails::Application
+ # Initialize configuration defaults for originally generated Rails version.
+ config.load_defaults 7.1
+
+ # Please, add to the `ignore` list any other `lib` subdirectories that do
+ # not contain `.rb` files, or that should not be reloaded or eager loaded.
+ # Common ones are `templates`, `generators`, or `middleware`, for example.
+ config.autoload_lib(ignore: %w(assets tasks))
+
+ # Configuration for the application, engines, and railties goes here.
+ #
+ # These settings can be overridden in specific environments using the files
+ # in config/environments, which are processed later.
+ #
+ # config.time_zone = "Central Time (US & Canada)"
+ # config.eager_load_paths << Rails.root.join("extras")
+ config.secret_key_base = 'xYSAU6vmI3i/K0oCgUuiBvDlRsDpHMVkECbPmjCATpJg/aB21TULOdp+PtmUn2ClEEq4nQnWmSYjBuVDDvN+8/pu4JvYEtn9zVtXKFgGn9Au133sjPDmQTyDqfdgx9dPtVSTJd5eNcFLx6xYCrzkQ8IsWAi4uQK+DgHn1ON2ghwwgzERWGB0HL3GepVhfeQUN5RE1BRmd4PkviRWP7uqWOjiIpr4/kf8FUhjljZYFNcPt6sq7AEA3kq9KoTVBfoJSPGriLjRhSrkhbEboJ9ANO6kloSQEWTZ0wA5k89iUwYY3sXBDSDSyRNbxexyYOfmQuoSRnX68PYc2rNAKLB107lNsNNlI1quzY9IB7ANP+cqTMwO89bPW7JVmKnp3zL23WkIfrh8zBUYO1mAVlZyC74Usaun--FR8YlH7KQiGFyBDL--TiQ4F+N1CusgWprwTf6Nyw=='
+ # Only loads a smaller set of middleware suitable for API only apps.
+ # Middleware like session, flash, cookies can be added back manually.
+ # Skip views, helpers and assets when generating a new resource.
+ config.api_only = true
+ end
+end
diff --git a/config/boot.rb b/config/boot.rb
new file mode 100644
index 0000000..988a5dd
--- /dev/null
+++ b/config/boot.rb
@@ -0,0 +1,4 @@
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
+
+require "bundler/setup" # Set up gems listed in the Gemfile.
+require "bootsnap/setup" # Speed up boot time by caching expensive operations.
diff --git a/config/cable.yml b/config/cable.yml
new file mode 100644
index 0000000..0d0a2db
--- /dev/null
+++ b/config/cable.yml
@@ -0,0 +1,10 @@
+development:
+ adapter: async
+
+test:
+ adapter: test
+
+production:
+ adapter: redis
+ url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
+ channel_prefix: jetlogix_backend_production
diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc
new file mode 100644
index 0000000..81287f1
--- /dev/null
+++ b/config/credentials.yml.enc
@@ -0,0 +1 @@
+VB3sNFERqzX4uqWwCzAUvhh9gn32ynd3z5Z53TRusG8/if9tTfo5bFW6peQstMJ2biYuMridqcn4wyhl+3rX9TVgr3lmWDSvbRkIBeEcI2vscAb61eRPps44a0IzDLtbP0ok+9ECgAw+LfBKpeoKXymmmPGkjDOc1nfjZwxKsYj79/yC6UiZfODVbPQ0bv/qxq67rDoZorDl2KPt48HnWuUuMoG+8LwISi9Oad+e8Z5ZrDu+93nIRu0706wqffx11xrIRzqTjQm5+KwHX/y25N2PxwK9Bde27Kz5NuQURxm1yDfEZJJA08aPVXan6IxmlEDhmWFcarm9nRQUtr6keiz/EgyPE71F99cG4y5xahENVEeFBtc4bRAEo2O6TEpiaCsfe926xaJLTT4wZXyYz3/Dwlo7--BEFaqjiMRqtcqRBZ--MzJAf8jUO34Crhq9BSx1iQ==
\ No newline at end of file
diff --git a/config/database.yml b/config/database.yml
new file mode 100644
index 0000000..036f38c
--- /dev/null
+++ b/config/database.yml
@@ -0,0 +1,88 @@
+# PostgreSQL. Versions 9.3 and up are supported.
+#
+# Install the pg driver:
+# gem install pg
+# On macOS with Homebrew:
+# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
+# On Windows:
+# gem install pg
+# Choose the win32 build.
+# Install PostgreSQL and put its /bin directory on your path.
+#
+# Configure Using Gemfile
+# gem "pg"
+#
+default: &default
+ adapter: postgresql
+ encoding: unicode
+ # For details on connection pooling, see Rails configuration guide
+ # https://guides.rubyonrails.org/configuring.html#database-pooling
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
+
+development:
+ <<: *default
+ database: jetlogix_backend_development
+ username: <%= ENV["DATABASE_USERNAME"] %>
+ password: <%= ENV["DATABASE_PASSWORD"] %>
+
+ # The specified database role being used to connect to PostgreSQL.
+ # To create additional roles in PostgreSQL see `$ createuser --help`.
+ # When left blank, PostgreSQL will use the default role. This is
+ # the same name as the operating system user running Rails.
+ #username: jetlogix_backend
+
+ # The password associated with the PostgreSQL role (username).
+ #password:
+
+ # Connect on a TCP socket. Omitted by default since the client uses a
+ # domain socket that doesn't need configuration. Windows does not have
+ # domain sockets, so uncomment these lines.
+ host: localhost
+
+ # The TCP port the server listens on. Defaults to 5432.
+ # If your server runs on a different port number, change accordingly.
+ port: 5432
+
+ # Schema search path. The server defaults to $user,public
+ #schema_search_path: myapp,sharedapp,public
+
+ # Minimum log levels, in increasing order:
+ # debug5, debug4, debug3, debug2, debug1,
+ # log, notice, warning, error, fatal, and panic
+ # Defaults to warning.
+ #min_messages: notice
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ <<: *default
+ database: jetlogix_backend_test
+ username: <%= ENV["DATABASE_USERNAME"] %>
+ password: <%= ENV["DATABASE_PASSWORD"] %>
+
+# As with config/credentials.yml, you never want to store sensitive information,
+# like your database password, in your source code. If your source code is
+# ever seen by anyone, they now have access to your database.
+#
+# Instead, provide the password or a full connection URL as an environment
+# variable when you boot the app. For example:
+#
+# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
+#
+# If the connection URL is provided in the special DATABASE_URL environment
+# variable, Rails will automatically merge its configuration values on top of
+# the values provided in this file. Alternatively, you can specify a connection
+# URL environment variable explicitly:
+#
+# production:
+# url: <%= ENV["MY_APP_DATABASE_URL"] %>
+#
+# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
+# for a full overview on how database connection configuration can be specified.
+#
+production:
+ <<: *default
+ database: jetlogix_backend_production
+ username: jetlogix_backend
+ password: <%= ENV["JETLOGIX_BACKEND_DATABASE_PASSWORD"] %>
diff --git a/config/environment.rb b/config/environment.rb
new file mode 100644
index 0000000..cac5315
--- /dev/null
+++ b/config/environment.rb
@@ -0,0 +1,5 @@
+# Load the Rails application.
+require_relative "application"
+
+# Initialize the Rails application.
+Rails.application.initialize!
diff --git a/config/environments/development.rb b/config/environments/development.rb
new file mode 100644
index 0000000..8b03b13
--- /dev/null
+++ b/config/environments/development.rb
@@ -0,0 +1,72 @@
+require "active_support/core_ext/integer/time"
+
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # In the development environment your application's code is reloaded any time
+ # it changes. This slows down response time but is perfect for development
+ # since you don't have to restart the web server when you make code changes.
+ config.action_mailer.default_url_options = { host: 'localhost', port: 4000 }
+ config.enable_reloading = true
+
+ # Do not eager load code on boot.
+ config.eager_load = false
+
+ # Show full error reports.
+ config.consider_all_requests_local = true
+
+ # Enable server timing
+ config.server_timing = true
+
+ # Enable/disable caching. By default caching is disabled.
+ # Run rails dev:cache to toggle caching.
+ if Rails.root.join("tmp/caching-dev.txt").exist?
+ config.cache_store = :memory_store
+ config.public_file_server.headers = {
+ "Cache-Control" => "public, max-age=#{2.days.to_i}"
+ }
+ else
+ config.action_controller.perform_caching = false
+
+ config.cache_store = :null_store
+ end
+
+ # Store uploaded files on the local file system (see config/storage.yml for options).
+ config.active_storage.service = :local
+
+ # Don't care if the mailer can't send.
+ config.action_mailer.raise_delivery_errors = false
+
+ config.action_mailer.perform_caching = false
+
+ # Print deprecation notices to the Rails logger.
+ config.active_support.deprecation = :log
+
+ # Raise exceptions for disallowed deprecations.
+ config.active_support.disallowed_deprecation = :raise
+
+ # Tell Active Support which deprecation messages to disallow.
+ config.active_support.disallowed_deprecation_warnings = []
+
+ # Raise an error on page load if there are pending migrations.
+ config.active_record.migration_error = :page_load
+
+ # Highlight code that triggered database queries in logs.
+ config.active_record.verbose_query_logs = true
+
+ # Highlight code that enqueued background job in logs.
+ config.active_job.verbose_enqueue_logs = true
+
+
+ # Raises error for missing translations.
+ # config.i18n.raise_on_missing_translations = true
+
+ # Annotate rendered view with file names.
+ # config.action_view.annotate_rendered_view_with_filenames = true
+
+ # Uncomment if you wish to allow Action Cable access from any origin.
+ # config.action_cable.disable_request_forgery_protection = true
+
+ # Raise error when a before_action's only/except options reference missing actions
+ config.action_controller.raise_on_missing_callback_actions = true
+end
diff --git a/config/environments/production.rb b/config/environments/production.rb
new file mode 100644
index 0000000..95c05b3
--- /dev/null
+++ b/config/environments/production.rb
@@ -0,0 +1,90 @@
+require "active_support/core_ext/integer/time"
+
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # Code is not reloaded between requests.
+ config.enable_reloading = false
+
+ # Eager load code on boot. This eager loads most of Rails and
+ # your application in memory, allowing both threaded web servers
+ # and those relying on copy on write to perform better.
+ # Rake tasks automatically ignore this option for performance.
+ config.eager_load = true
+
+ # Full error reports are disabled and caching is turned on.
+ config.consider_all_requests_local = false
+
+ # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
+ # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
+ # config.require_master_key = true
+
+ # Enable static file serving from the `/public` folder (turn off if using NGINX/Apache for it).
+ config.public_file_server.enabled = true
+
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
+ # config.asset_host = "http://assets.example.com"
+
+ # Specifies the header that your server uses for sending files.
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
+ # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
+
+ # Store uploaded files on the local file system (see config/storage.yml for options).
+ config.active_storage.service = :local
+
+ # Mount Action Cable outside main process or domain.
+ # config.action_cable.mount_path = nil
+ # config.action_cable.url = "wss://example.com/cable"
+ # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
+
+ # Assume all access to the app is happening through a SSL-terminating reverse proxy.
+ # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies.
+ # config.assume_ssl = true
+
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
+ config.force_ssl = true
+
+ # Log to STDOUT by default
+ config.logger = ActiveSupport::Logger.new(STDOUT)
+ .tap { |logger| logger.formatter = ::Logger::Formatter.new }
+ .then { |logger| ActiveSupport::TaggedLogging.new(logger) }
+
+ # Prepend all log lines with the following tags.
+ config.log_tags = [ :request_id ]
+
+ # Info include generic and useful information about system operation, but avoids logging too much
+ # information to avoid inadvertent exposure of personally identifiable information (PII). If you
+ # want to log everything, set the level to "debug".
+ config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
+
+ # Use a different cache store in production.
+ # config.cache_store = :mem_cache_store
+
+ # Use a real queuing backend for Active Job (and separate queues per environment).
+ # config.active_job.queue_adapter = :resque
+ # config.active_job.queue_name_prefix = "jetlogix_backend_production"
+
+ config.action_mailer.perform_caching = false
+
+ # Ignore bad email addresses and do not raise email delivery errors.
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
+ # config.action_mailer.raise_delivery_errors = false
+
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation cannot be found).
+ config.i18n.fallbacks = true
+
+ # Don't log any deprecations.
+ config.active_support.report_deprecations = false
+
+ # Do not dump schema after migrations.
+ config.active_record.dump_schema_after_migration = false
+
+ # Enable DNS rebinding protection and other `Host` header attacks.
+ # config.hosts = [
+ # "example.com", # Allow requests from example.com
+ # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
+ # ]
+ # Skip DNS rebinding protection for the default health check endpoint.
+ # config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
+end
diff --git a/config/environments/test.rb b/config/environments/test.rb
new file mode 100644
index 0000000..0dda9f9
--- /dev/null
+++ b/config/environments/test.rb
@@ -0,0 +1,64 @@
+require "active_support/core_ext/integer/time"
+
+# The test environment is used exclusively to run your application's
+# test suite. You never need to work with it otherwise. Remember that
+# your test database is "scratch space" for the test suite and is wiped
+# and recreated between test runs. Don't rely on the data there!
+
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # While tests run files are not watched, reloading is not necessary.
+ config.enable_reloading = false
+
+ # Eager loading loads your entire application. When running a single test locally,
+ # this is usually not necessary, and can slow down your test suite. However, it's
+ # recommended that you enable it in continuous integration systems to ensure eager
+ # loading is working properly before deploying your code.
+ config.eager_load = ENV["CI"].present?
+
+ # Configure public file server for tests with Cache-Control for performance.
+ config.public_file_server.enabled = true
+ config.public_file_server.headers = {
+ "Cache-Control" => "public, max-age=#{1.hour.to_i}"
+ }
+
+ # Show full error reports and disable caching.
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+ config.cache_store = :null_store
+
+ # Raise exceptions instead of rendering exception templates.
+ config.action_dispatch.show_exceptions = :rescuable
+
+ # Disable request forgery protection in test environment.
+ config.action_controller.allow_forgery_protection = false
+
+ # Store uploaded files on the local file system in a temporary directory.
+ config.active_storage.service = :test
+
+ config.action_mailer.perform_caching = false
+
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Print deprecation notices to the stderr.
+ config.active_support.deprecation = :stderr
+
+ # Raise exceptions for disallowed deprecations.
+ config.active_support.disallowed_deprecation = :raise
+
+ # Tell Active Support which deprecation messages to disallow.
+ config.active_support.disallowed_deprecation_warnings = []
+
+ # Raises error for missing translations.
+ # config.i18n.raise_on_missing_translations = true
+
+ # Annotate rendered view with file names.
+ # config.action_view.annotate_rendered_view_with_filenames = true
+
+ # Raise error when a before_action's only/except options reference missing actions
+ config.action_controller.raise_on_missing_callback_actions = true
+end
diff --git a/config/initializers/cors.rb b/config/initializers/cors.rb
new file mode 100644
index 0000000..60f4695
--- /dev/null
+++ b/config/initializers/cors.rb
@@ -0,0 +1,18 @@
+# Be sure to restart your server when you modify this file.
+
+# Avoid CORS issues when API is called from the frontend app.
+# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin Ajax requests.
+
+# Read more: https://github.com/cyu/rack-cors
+
+Rails.application.config.middleware.insert_before 0, Rack::Cors do
+ allow do
+ origins '*'
+ resource(
+ '*',
+ headers: :any,
+ expose: ['Authorization'],
+ methods: [:get, :patch, :put, :delete, :post, :options, :show]
+ )
+ end
+end
diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb
new file mode 100644
index 0000000..215418a
--- /dev/null
+++ b/config/initializers/devise.rb
@@ -0,0 +1,325 @@
+# frozen_string_literal: true
+
+# Assuming you have not yet modified this file, each configuration option below
+# is set to its default value. Note that some are commented out while others
+# are not: uncommented lines are intended to protect your configuration from
+# breaking changes in upgrades (i.e., in the event that future versions of
+# Devise change the default values for those options).
+#
+# Use this hook to configure devise mailer, warden hooks and so forth.
+# Many of these configuration options can be set straight in your model.
+Devise.setup do |config|
+ # The secret key used by Devise. Devise uses this key to generate
+ # random tokens. Changing this key will render invalid all existing
+ # confirmation, reset password and unlock tokens in the database.
+ # Devise will use the `secret_key_base` as its `secret_key`
+ # by default. You can change it below and use your own secret key.
+ # config.secret_key = 'acbf73622f72365ff5088346928c46456530262e40f90c6dc973bb43c1cf52cbd6fab6b6fba41e4b5cb5538a9b7cb47837fe08a80a4fe62013a12d44da7e76c7'
+
+ # ==> Controller configuration
+ # Configure the parent class to the devise controllers.
+ # config.parent_controller = 'DeviseController'
+
+ # ==> Mailer Configuration
+ # Configure the e-mail address which will be shown in Devise::Mailer,
+ # note that it will be overwritten if you use your own mailer class
+ # with default "from" parameter.
+ config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
+
+ # Configure the class responsible to send e-mails.
+ # config.mailer = 'Devise::Mailer'
+
+ # Configure the parent class responsible to send e-mails.
+ # config.parent_mailer = 'ActionMailer::Base'
+
+ # ==> ORM configuration
+ # Load and configure the ORM. Supports :active_record (default) and
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
+ # available as additional gems.
+ require 'devise/orm/active_record'
+
+ # ==> Configuration for any authentication mechanism
+ # Configure which keys are used when authenticating a user. The default is
+ # just :email. You can configure it to use [:username, :subdomain], so for
+ # authenticating a user, both parameters are required. Remember that those
+ # parameters are used only when authenticating and not when retrieving from
+ # session. If you need permissions, you should implement that in a before filter.
+ # You can also supply a hash where the value is a boolean determining whether
+ # or not authentication should be aborted when the value is not present.
+ # config.authentication_keys = [:email]
+
+ # Configure parameters from the request object used for authentication. Each entry
+ # given should be a request method and it will automatically be passed to the
+ # find_for_authentication method and considered in your model lookup. For instance,
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
+ # config.request_keys = []
+
+ # Configure which authentication keys should be case-insensitive.
+ # These keys will be downcased upon creating or modifying a user and when used
+ # to authenticate or find a user. Default is :email.
+ config.case_insensitive_keys = [:email]
+
+ # Configure which authentication keys should have whitespace stripped.
+ # These keys will have whitespace before and after removed upon creating or
+ # modifying a user and when used to authenticate or find a user. Default is :email.
+ config.strip_whitespace_keys = [:email]
+
+ # Tell if authentication through request.params is enabled. True by default.
+ # It can be set to an array that will enable params authentication only for the
+ # given strategies, for example, `config.params_authenticatable = [:database]` will
+ # enable it only for database (email + password) authentication.
+ # config.params_authenticatable = true
+
+ # Tell if authentication through HTTP Auth is enabled. False by default.
+ # It can be set to an array that will enable http authentication only for the
+ # given strategies, for example, `config.http_authenticatable = [:database]` will
+ # enable it only for database authentication.
+ # For API-only applications to support authentication "out-of-the-box", you will likely want to
+ # enable this with :database unless you are using a custom strategy.
+ # The supported strategies are:
+ # :database = Support basic authentication with authentication key + password
+ # config.http_authenticatable = false
+
+ # If 401 status code should be returned for AJAX requests. True by default.
+ # config.http_authenticatable_on_xhr = true
+
+ # The realm used in Http Basic Authentication. 'Application' by default.
+ # config.http_authentication_realm = 'Application'
+
+ # It will change confirmation, password recovery and other workflows
+ # to behave the same regardless if the e-mail provided was right or wrong.
+ # Does not affect registerable.
+ # config.paranoid = true
+
+ # By default Devise will store the user in session. You can skip storage for
+ # particular strategies by setting this option.
+ # Notice that if you are skipping storage for all authentication paths, you
+ # may want to disable generating routes to Devise's sessions controller by
+ # passing skip: :sessions to `devise_for` in your config/routes.rb
+ config.skip_session_storage = [:http_auth]
+
+ # By default, Devise cleans up the CSRF token on authentication to
+ # avoid CSRF token fixation attacks. This means that, when using AJAX
+ # requests for sign in and sign up, you need to get a new CSRF token
+ # from the server. You can disable this option at your own risk.
+ # config.clean_up_csrf_token_on_authentication = true
+
+ # When false, Devise will not attempt to reload routes on eager load.
+ # This can reduce the time taken to boot the app but if your application
+ # requires the Devise mappings to be loaded during boot time the application
+ # won't boot properly.
+ # config.reload_routes = true
+
+ # ==> Configuration for :database_authenticatable
+ # For bcrypt, this is the cost for hashing the password and defaults to 12. If
+ # using other algorithms, it sets how many times you want the password to be hashed.
+ # The number of stretches used for generating the hashed password are stored
+ # with the hashed password. This allows you to change the stretches without
+ # invalidating existing passwords.
+ #
+ # Limiting the stretches to just one in testing will increase the performance of
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
+ # a value less than 10 in other environments. Note that, for bcrypt (the default
+ # algorithm), the cost increases exponentially with the number of stretches (e.g.
+ # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
+ config.stretches = Rails.env.test? ? 1 : 12
+
+ # Set up a pepper to generate the hashed password.
+ # config.pepper = '96f416fcdf710195e0241af3a5f69051de25b0ef61ee99a760ed25542d0bb7c2b9ada0a1fcf518c9db5779812042bd4ec03c2307bf61d4c86787d3926a1a877d'
+
+ # Send a notification to the original email when the user's email is changed.
+ # config.send_email_changed_notification = false
+
+ # Send a notification email when the user's password is changed.
+ # config.send_password_change_notification = false
+
+ # ==> Configuration for :confirmable
+ # A period that the user is allowed to access the website even without
+ # confirming their account. For instance, if set to 2.days, the user will be
+ # able to access the website for two days without confirming their account,
+ # access will be blocked just in the third day.
+ # You can also set it to nil, which will allow the user to access the website
+ # without confirming their account.
+ # Default is 0.days, meaning the user cannot access the website without
+ # confirming their account.
+ # config.allow_unconfirmed_access_for = 2.days
+
+ # A period that the user is allowed to confirm their account before their
+ # token becomes invalid. For example, if set to 3.days, the user can confirm
+ # their account within 3 days after the mail was sent, but on the fourth day
+ # their account can't be confirmed with the token any more.
+ # Default is nil, meaning there is no restriction on how long a user can take
+ # before confirming their account.
+ # config.confirm_within = 3.days
+
+ # If true, requires any email changes to be confirmed (exactly the same way as
+ # initial account confirmation) to be applied. Requires additional unconfirmed_email
+ # db field (see migrations). Until confirmed, new email is stored in
+ # unconfirmed_email column, and copied to email column on successful confirmation.
+ config.reconfirmable = true
+
+ # Defines which key will be used when confirming an account
+ # config.confirmation_keys = [:email]
+
+ # ==> Configuration for :rememberable
+ # The time the user will be remembered without asking for credentials again.
+ # config.remember_for = 2.weeks
+
+ # Invalidates all the remember me tokens when the user signs out.
+ config.expire_all_remember_me_on_sign_out = true
+
+ # If true, extends the user's remember period when remembered via cookie.
+ # config.extend_remember_period = false
+
+ # Options to be passed to the created cookie. For instance, you can set
+ # secure: true in order to force SSL only cookies.
+ # config.rememberable_options = {}
+
+ # ==> Configuration for :validatable
+ # Range for password length.
+ config.password_length = 6..128
+
+ # Email regex used to validate email formats. It simply asserts that
+ # one (and only one) @ exists in the given string. This is mainly
+ # to give user feedback and not to assert the e-mail validity.
+ config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
+
+ # ==> Configuration for :timeoutable
+ # The time you want to timeout the user session without activity. After this
+ # time the user will be asked for credentials again. Default is 30 minutes.
+ # config.timeout_in = 30.minutes
+
+ # ==> Configuration for :lockable
+ # Defines which strategy will be used to lock an account.
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
+ # :none = No lock strategy. You should handle locking by yourself.
+ # config.lock_strategy = :failed_attempts
+
+ # Defines which key will be used when locking and unlocking an account
+ # config.unlock_keys = [:email]
+
+ # Defines which strategy will be used to unlock an account.
+ # :email = Sends an unlock link to the user email
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
+ # :both = Enables both strategies
+ # :none = No unlock strategy. You should handle unlocking by yourself.
+ # config.unlock_strategy = :both
+
+ # Number of authentication tries before locking an account if lock_strategy
+ # is failed attempts.
+ # config.maximum_attempts = 20
+
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
+ # config.unlock_in = 1.hour
+
+ # Warn on the last attempt before the account is locked.
+ # config.last_attempt_warning = true
+
+ # ==> Configuration for :recoverable
+ #
+ # Defines which key will be used when recovering the password for an account
+ # config.reset_password_keys = [:email]
+
+ # Time interval you can reset your password with a reset password key.
+ # Don't put a too small interval or your users won't have the time to
+ # change their passwords.
+ config.reset_password_within = 6.hours
+
+ # When set to false, does not sign a user in automatically after their password is
+ # reset. Defaults to true, so a user is signed in automatically after a reset.
+ # config.sign_in_after_reset_password = true
+
+ # ==> Configuration for :encryptable
+ # Allow you to use another hashing or encryption algorithm besides bcrypt (default).
+ # You can use :sha1, :sha512 or algorithms from others authentication tools as
+ # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
+ # for default behavior) and :restful_authentication_sha1 (then you should set
+ # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
+ #
+ # Require the `devise-encryptable` gem when using anything other than bcrypt
+ # config.encryptor = :sha512
+
+ # ==> Scopes configuration
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
+ # "users/sessions/new". It's turned off by default because it's slower if you
+ # are using only default views.
+ # config.scoped_views = false
+
+ # Configure the default scope given to Warden. By default it's the first
+ # devise role declared in your routes (usually :user).
+ # config.default_scope = :user
+
+ # Set this configuration to false if you want /users/sign_out to sign out
+ # only the current scope. By default, Devise signs out all scopes.
+ # config.sign_out_all_scopes = true
+
+ # ==> Navigation configuration
+ # Lists the formats that should be treated as navigational. Formats like
+ # :html should redirect to the sign in page when the user does not have
+ # access, but formats like :xml or :json, should return 401.
+ #
+ # If you have any extra navigational formats, like :iphone or :mobile, you
+ # should add them to the navigational formats lists.
+ #
+ # The "*/*" below is required to match Internet Explorer requests.
+ config.navigational_formats = []
+
+ # The default HTTP method used to sign out a resource. Default is :delete.
+ config.sign_out_via = :delete
+
+ # ==> OmniAuth
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
+ # up on your models and hooks.
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
+
+ # ==> Warden configuration
+ # If you want to use other strategies, that are not supported by Devise, or
+ # change the failure app, you can configure them inside the config.warden block.
+ #
+ # config.warden do |manager|
+ # manager.intercept_401 = false
+ # manager.default_strategies(scope: :user).unshift :some_external_strategy
+ # end
+
+ # ==> Mountable engine configurations
+ # When using Devise inside an engine, let's call it `MyEngine`, and this engine
+ # is mountable, there are some extra configurations to be taken into account.
+ # The following options are available, assuming the engine is mounted as:
+ #
+ # mount MyEngine, at: '/my_engine'
+ #
+ # The router that invoked `devise_for`, in the example above, would be:
+ # config.router_name = :my_engine
+ #
+ # When using OmniAuth, Devise cannot automatically set OmniAuth path,
+ # so you need to do it manually. For the users scope, it would be:
+ # config.omniauth_path_prefix = '/my_engine/users/auth'
+
+ # ==> Hotwire/Turbo configuration
+ # When using Devise with Hotwire/Turbo, the http status for error responses
+ # and some redirects must match the following. The default in Devise for existing
+ # apps is `200 OK` and `302 Found` respectively, but new apps are generated with
+ # these new defaults that match Hotwire/Turbo behavior.
+ # Note: These might become the new default in future versions of Devise.
+ config.responder.error_status = :unprocessable_entity
+ config.responder.redirect_status = :see_other
+ # ==> Configuration for :registerable
+
+ # When set to false, does not sign a user in automatically after their password is
+ # changed. Defaults to true, so a user is signed in automatically after changing a password.
+ # config.sign_in_after_change_password = true
+ # Rails.application.credentials.fetch(:secret_key_base)
+ # Rails.application.credentials.secret_key_base
+
+ config.jwt do |jwt|
+ jwt.secret = Rails.application.credentials.fetch(:secret_key_base)
+ jwt.dispatch_requests = [
+ ['POST', %r{^/login$}]
+ ]
+ jwt.revocation_requests = [
+ ['DELETE', %r{^/logout$}]
+ ]
+ jwt.expiration_time = 120.minutes.to_i
+ end
+end
diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb
new file mode 100644
index 0000000..c2d89e2
--- /dev/null
+++ b/config/initializers/filter_parameter_logging.rb
@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
+# Use this to limit dissemination of sensitive information.
+# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
+Rails.application.config.filter_parameters += [
+ :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
+]
diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb
new file mode 100644
index 0000000..3860f65
--- /dev/null
+++ b/config/initializers/inflections.rb
@@ -0,0 +1,16 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format. Inflections
+# are locale specific, and you may define rules for as many different
+# locales as you wish. All of these examples are active by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.plural /^(ox)$/i, "\\1en"
+# inflect.singular /^(ox)en/i, "\\1"
+# inflect.irregular "person", "people"
+# inflect.uncountable %w( fish sheep )
+# end
+
+# These inflection rules are supported but not enabled by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.acronym "RESTful"
+# end
diff --git a/config/initializers/rswag_api.rb b/config/initializers/rswag_api.rb
new file mode 100644
index 0000000..4d72f68
--- /dev/null
+++ b/config/initializers/rswag_api.rb
@@ -0,0 +1,14 @@
+Rswag::Api.configure do |c|
+
+ # Specify a root folder where Swagger JSON files are located
+ # This is used by the Swagger middleware to serve requests for API descriptions
+ # NOTE: If you're using rswag-specs to generate Swagger, you'll need to ensure
+ # that it's configured to generate files in the same folder
+ c.swagger_root = Rails.root.to_s + '/swagger'
+
+ # Inject a lambda function to alter the returned Swagger prior to serialization
+ # The function will have access to the rack env for the current request
+ # For example, you could leverage this to dynamically assign the "host" property
+ #
+ #c.swagger_filter = lambda { |swagger, env| swagger['host'] = env['HTTP_HOST'] }
+end
diff --git a/config/initializers/rswag_ui.rb b/config/initializers/rswag_ui.rb
new file mode 100644
index 0000000..0a768c1
--- /dev/null
+++ b/config/initializers/rswag_ui.rb
@@ -0,0 +1,16 @@
+Rswag::Ui.configure do |c|
+
+ # List the Swagger endpoints that you want to be documented through the
+ # swagger-ui. The first parameter is the path (absolute or relative to the UI
+ # host) to the corresponding endpoint and the second is a title that will be
+ # displayed in the document selector.
+ # NOTE: If you're using rspec-api to expose Swagger files
+ # (under swagger_root) as JSON or YAML endpoints, then the list below should
+ # correspond to the relative paths for those endpoints.
+
+ c.swagger_endpoint '/api-docs/v1/swagger.yaml', 'API V1 Docs'
+
+ # Add Basic Auth in case your API is private
+ # c.basic_auth_enabled = true
+ # c.basic_auth_credentials 'username', 'password'
+end
diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml
new file mode 100644
index 0000000..260e1c4
--- /dev/null
+++ b/config/locales/devise.en.yml
@@ -0,0 +1,65 @@
+# Additional translations at https://github.com/heartcombo/devise/wiki/I18n
+
+en:
+ devise:
+ confirmations:
+ confirmed: "Your email address has been successfully confirmed."
+ send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
+ send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
+ failure:
+ already_authenticated: "You are already signed in."
+ inactive: "Your account is not activated yet."
+ invalid: "Invalid %{authentication_keys} or password."
+ locked: "Your account is locked."
+ last_attempt: "You have one more attempt before your account is locked."
+ not_found_in_database: "Invalid %{authentication_keys} or password."
+ timeout: "Your session expired. Please sign in again to continue."
+ unauthenticated: "You need to sign in or sign up before continuing."
+ unconfirmed: "You have to confirm your email address before continuing."
+ mailer:
+ confirmation_instructions:
+ subject: "Confirmation instructions"
+ reset_password_instructions:
+ subject: "Reset password instructions"
+ unlock_instructions:
+ subject: "Unlock instructions"
+ email_changed:
+ subject: "Email Changed"
+ password_change:
+ subject: "Password Changed"
+ omniauth_callbacks:
+ failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
+ success: "Successfully authenticated from %{kind} account."
+ passwords:
+ no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
+ send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
+ send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
+ updated: "Your password has been changed successfully. You are now signed in."
+ updated_not_active: "Your password has been changed successfully."
+ registrations:
+ destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
+ signed_up: "Welcome! You have signed up successfully."
+ signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
+ signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
+ signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
+ update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address."
+ updated: "Your account has been updated successfully."
+ updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again."
+ sessions:
+ signed_in: "Signed in successfully."
+ signed_out: "Signed out successfully."
+ already_signed_out: "Signed out successfully."
+ unlocks:
+ send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
+ send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
+ unlocked: "Your account has been unlocked successfully. Please sign in to continue."
+ errors:
+ messages:
+ already_confirmed: "was already confirmed, please try signing in"
+ confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
+ expired: "has expired, please request a new one"
+ not_found: "not found"
+ not_locked: "was not locked"
+ not_saved:
+ one: "1 error prohibited this %{resource} from being saved:"
+ other: "%{count} errors prohibited this %{resource} from being saved:"
diff --git a/config/locales/en.yml b/config/locales/en.yml
new file mode 100644
index 0000000..6c349ae
--- /dev/null
+++ b/config/locales/en.yml
@@ -0,0 +1,31 @@
+# Files in the config/locales directory are used for internationalization and
+# are automatically loaded by Rails. If you want to use locales other than
+# English, add the necessary files in this directory.
+#
+# To use the locales, use `I18n.t`:
+#
+# I18n.t "hello"
+#
+# In views, this is aliased to just `t`:
+#
+# <%= t("hello") %>
+#
+# To use a different locale, set it with `I18n.locale`:
+#
+# I18n.locale = :es
+#
+# This would use the information in config/locales/es.yml.
+#
+# To learn more about the API, please read the Rails Internationalization guide
+# at https://guides.rubyonrails.org/i18n.html.
+#
+# Be aware that YAML interprets the following case-insensitive strings as
+# booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings
+# must be quoted to be interpreted as strings. For example:
+#
+# en:
+# "yes": yup
+# enabled: "ON"
+
+en:
+ hello: "Hello world"
diff --git a/config/puma.rb b/config/puma.rb
new file mode 100644
index 0000000..0474c2a
--- /dev/null
+++ b/config/puma.rb
@@ -0,0 +1,35 @@
+# This configuration file will be evaluated by Puma. The top-level methods that
+# are invoked here are part of Puma's configuration DSL. For more information
+# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
+
+# Puma can serve each request in a thread from an internal thread pool.
+# The `threads` method setting takes two numbers: a minimum and maximum.
+# Any libraries that use thread pools should be configured to match
+# the maximum value specified for Puma. Default is set to 5 threads for minimum
+# and maximum; this matches the default thread size of Active Record.
+max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
+min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
+threads min_threads_count, max_threads_count
+
+# Specifies that the worker count should equal the number of processors in production.
+if ENV["RAILS_ENV"] == "production"
+ require "concurrent-ruby"
+ worker_count = Integer(ENV.fetch("WEB_CONCURRENCY") { Concurrent.physical_processor_count })
+ workers worker_count if worker_count > 1
+end
+
+# Specifies the `worker_timeout` threshold that Puma will use to wait before
+# terminating a worker in development environments.
+worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
+
+# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
+port ENV.fetch("PORT") { 4000 }
+
+# Specifies the `environment` that Puma will run in.
+environment ENV.fetch("RAILS_ENV") { "development" }
+
+# Specifies the `pidfile` that Puma will use.
+pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
+
+# Allow puma to be restarted by `bin/rails restart` command.
+plugin :tmp_restart
diff --git a/config/routes.rb b/config/routes.rb
new file mode 100644
index 0000000..44aa836
--- /dev/null
+++ b/config/routes.rb
@@ -0,0 +1,30 @@
+Rails.application.routes.draw do
+ mount Rswag::Ui::Engine => '/api-docs'
+ mount Rswag::Api::Engine => '/api-docs'
+ devise_for :users, path: '', path_names: {
+ sign_in: 'login',
+ sign_out: 'logout',
+ registration: 'signup'
+ },
+ controllers: {
+ sessions: 'users/sessions',
+ registrations: 'users/registrations'
+ }
+
+ namespace :api do
+ namespace :v1 do
+ resources :users do
+ resources :reservations
+ resources :aeroplanes
+ end
+ end
+ end
+ # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
+
+ # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
+ # Can be used by load balancers and uptime monitors to verify that the app is live.
+ get "up" => "rails/health#show", as: :rails_health_check
+
+ # Defines the root path route ("/")
+ # root "posts#index"
+end
diff --git a/config/storage.yml b/config/storage.yml
new file mode 100644
index 0000000..4942ab6
--- /dev/null
+++ b/config/storage.yml
@@ -0,0 +1,34 @@
+test:
+ service: Disk
+ root: <%= Rails.root.join("tmp/storage") %>
+
+local:
+ service: Disk
+ root: <%= Rails.root.join("storage") %>
+
+# Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
+# amazon:
+# service: S3
+# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
+# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
+# region: us-east-1
+# bucket: your_own_bucket-<%= Rails.env %>
+
+# Remember not to checkin your GCS keyfile to a repository
+# google:
+# service: GCS
+# project: your_project
+# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
+# bucket: your_own_bucket-<%= Rails.env %>
+
+# Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
+# microsoft:
+# service: AzureStorage
+# storage_account_name: your_account_name
+# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
+# container: your_container_name-<%= Rails.env %>
+
+# mirror:
+# service: Mirror
+# primary: local
+# mirrors: [ amazon, google, microsoft ]
diff --git a/db/migrate/20231101100616_create_users.rb b/db/migrate/20231101100616_create_users.rb
new file mode 100644
index 0000000..0461b4d
--- /dev/null
+++ b/db/migrate/20231101100616_create_users.rb
@@ -0,0 +1,9 @@
+class CreateUsers < ActiveRecord::Migration[7.1]
+ def change
+ create_table :users do |t|
+ t.string :name
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20231101101057_create_aeroplanes.rb b/db/migrate/20231101101057_create_aeroplanes.rb
new file mode 100644
index 0000000..db39383
--- /dev/null
+++ b/db/migrate/20231101101057_create_aeroplanes.rb
@@ -0,0 +1,16 @@
+class CreateAeroplanes < ActiveRecord::Migration[7.1]
+ def change
+ create_table :aeroplanes do |t|
+ t.string :name
+ t.string :model
+ t.string :image
+ t.string :description
+ t.integer :number_of_seats
+ t.string :location
+ t.numeric :fee
+ t.boolean :reserved
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20231101102104_create_reservations.rb b/db/migrate/20231101102104_create_reservations.rb
new file mode 100644
index 0000000..9eda609
--- /dev/null
+++ b/db/migrate/20231101102104_create_reservations.rb
@@ -0,0 +1,15 @@
+class CreateReservations < ActiveRecord::Migration[7.1]
+ def change
+ create_table :reservations do |t|
+ t.date :reserved_date
+ t.timestamp :start_time
+ t.timestamp :end_time
+ t.string :start_location
+ t.string :destination
+ t.references :user, null: false, foreign_key: true
+ t.references :aeroplane, null: false, foreign_key: true
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20231101124222_add_devise_to_users.rb b/db/migrate/20231101124222_add_devise_to_users.rb
new file mode 100644
index 0000000..c919694
--- /dev/null
+++ b/db/migrate/20231101124222_add_devise_to_users.rb
@@ -0,0 +1,51 @@
+# frozen_string_literal: true
+
+class AddDeviseToUsers < ActiveRecord::Migration[7.1]
+ def self.up
+ change_table :users do |t|
+ ## Database authenticatable
+ t.string :email, null: false, default: ""
+ t.string :encrypted_password, null: false, default: ""
+
+ ## Recoverable
+ t.string :reset_password_token
+ t.datetime :reset_password_sent_at
+
+ ## Rememberable
+ t.datetime :remember_created_at
+
+ ## Trackable
+ # t.integer :sign_in_count, default: 0, null: false
+ # t.datetime :current_sign_in_at
+ # t.datetime :last_sign_in_at
+ # t.string :current_sign_in_ip
+ # t.string :last_sign_in_ip
+
+ ## Confirmable
+ # t.string :confirmation_token
+ # t.datetime :confirmed_at
+ # t.datetime :confirmation_sent_at
+ # t.string :unconfirmed_email # Only if using reconfirmable
+
+ ## Lockable
+ # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
+ # t.datetime :locked_at
+
+
+ # Uncomment below if timestamps were not included in your original model.
+ # t.timestamps null: false
+ end
+
+ add_index :users, :email, unique: true
+ add_index :users, :reset_password_token, unique: true
+ # add_index :users, :confirmation_token, unique: true
+ # add_index :users, :unlock_token, unique: true
+ end
+
+ def self.down
+ # By default, we don't want to make any assumption about how to roll back a migration when your
+ # model already existed. Please edit below which fields you would like to remove in this migration.
+ raise ActiveRecord::IrreversibleMigration
+ end
+end
diff --git a/db/migrate/20231101130613_add_jti_to_users.rb b/db/migrate/20231101130613_add_jti_to_users.rb
new file mode 100644
index 0000000..d17072b
--- /dev/null
+++ b/db/migrate/20231101130613_add_jti_to_users.rb
@@ -0,0 +1,6 @@
+class AddJtiToUsers < ActiveRecord::Migration[7.1]
+ def change
+ add_column :users, :jti, :string, null: false
+ add_index :users, :jti, unique: true
+ end
+end
diff --git a/db/migrate/20231102050731_add_role_to_users.rb b/db/migrate/20231102050731_add_role_to_users.rb
new file mode 100644
index 0000000..bfaa6b5
--- /dev/null
+++ b/db/migrate/20231102050731_add_role_to_users.rb
@@ -0,0 +1,5 @@
+class AddRoleToUsers < ActiveRecord::Migration[7.1]
+ def change
+ add_column :users, :role, :string, :default => 'user'
+ end
+end
diff --git a/db/migrate/20231110140727_add_name_to_reservations.rb b/db/migrate/20231110140727_add_name_to_reservations.rb
new file mode 100644
index 0000000..f8d9139
--- /dev/null
+++ b/db/migrate/20231110140727_add_name_to_reservations.rb
@@ -0,0 +1,5 @@
+class AddNameToReservations < ActiveRecord::Migration[7.1]
+ def change
+ add_column :reservations, :name, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 0000000..5505d5f
--- /dev/null
+++ b/db/schema.rb
@@ -0,0 +1,63 @@
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# This file is the source Rails uses to define your schema when running `bin/rails
+# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
+# be faster and is potentially less error prone than running all of your
+# migrations from scratch. Old migrations may fail to apply correctly if those
+# migrations use external dependencies or application code.
+#
+# It's strongly recommended that you check this file into your version control system.
+
+ActiveRecord::Schema[7.1].define(version: 2023_11_10_140727) do
+ # These are extensions that must be enabled in order to support this database
+ enable_extension "plpgsql"
+
+ create_table "aeroplanes", force: :cascade do |t|
+ t.string "name"
+ t.string "model"
+ t.string "image"
+ t.string "description"
+ t.integer "number_of_seats"
+ t.string "location"
+ t.decimal "fee"
+ t.boolean "reserved"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "reservations", force: :cascade do |t|
+ t.date "reserved_date"
+ t.datetime "start_time", precision: nil
+ t.datetime "end_time", precision: nil
+ t.string "start_location"
+ t.string "destination"
+ t.bigint "user_id", null: false
+ t.bigint "aeroplane_id", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "name"
+ t.index ["aeroplane_id"], name: "index_reservations_on_aeroplane_id"
+ t.index ["user_id"], name: "index_reservations_on_user_id"
+ end
+
+ create_table "users", force: :cascade do |t|
+ t.string "name"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "email", default: "", null: false
+ t.string "encrypted_password", default: "", null: false
+ t.string "reset_password_token"
+ t.datetime "reset_password_sent_at"
+ t.datetime "remember_created_at"
+ t.string "jti", null: false
+ t.string "role", default: "user"
+ t.index ["email"], name: "index_users_on_email", unique: true
+ t.index ["jti"], name: "index_users_on_jti", unique: true
+ t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
+ end
+
+ add_foreign_key "reservations", "aeroplanes"
+ add_foreign_key "reservations", "users"
+end
diff --git a/db/seeds.rb b/db/seeds.rb
new file mode 100644
index 0000000..2c865bb
--- /dev/null
+++ b/db/seeds.rb
@@ -0,0 +1,16 @@
+# This file should ensure the existence of records required to run the application in every environment (production,
+# development, test). The code here should be idempotent so that it can be executed at any point in every environment.
+# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
+#
+# Example:
+#
+# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name|
+# MovieGenre.find_or_create_by!(name: genre_name)
+# end
+# Create a dummy User
+User.create(name: 'John')
+
+# Create some sample aeroplanes
+Aeroplane.create(name: 'Aeroplane 1', model: 'https://images.unsplash.com/photo-1464037866556-6812c9d1c72e?auto=format&fit=crop&q=80&w=2070&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D', image: 'image1', description: 'yolo', number_of_seats: 100, location: 'test', fee: 90.0, reserved: true)
+Aeroplane.create(name: 'Aeroplane 2', model: 'https://images.unsplash.com/photo-1464037866556-6812c9d1c72e?auto=format&fit=crop&q=80&w=2070&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D', image: 'image1', description: 'yolo', number_of_seats: 100, location: 'test', fee: 90.0, reserved: true)
+Aeroplane.create(name: 'Aeroplane 3', model: 'https://images.unsplash.com/photo-1464037866556-6812c9d1c72e?auto=format&fit=crop&q=80&w=2070&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D', image: 'image1', description: 'yolo', number_of_seats: 100, location: 'test', fee: 90.0, reserved: true)
diff --git a/lib/tasks/.keep b/lib/tasks/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/log/.keep b/log/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/package-lock.json b/package-lock.json
new file mode 100644
index 0000000..7ab3710
--- /dev/null
+++ b/package-lock.json
@@ -0,0 +1,158 @@
+{
+ "name": "jetlogix-backend",
+ "lockfileVersion": 2,
+ "requires": true,
+ "packages": {
+ "": {
+ "dependencies": {
+ "react-hot-toast": "^2.4.1"
+ }
+ },
+ "node_modules/csstype": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz",
+ "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==",
+ "peer": true
+ },
+ "node_modules/goober": {
+ "version": "2.1.13",
+ "resolved": "https://registry.npmjs.org/goober/-/goober-2.1.13.tgz",
+ "integrity": "sha512-jFj3BQeleOoy7t93E9rZ2de+ScC4lQICLwiAQmKMg9F6roKGaLSHoCDYKkWlSafg138jejvq/mTdvmnwDQgqoQ==",
+ "peerDependencies": {
+ "csstype": "^3.0.10"
+ }
+ },
+ "node_modules/js-tokens": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
+ "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
+ "peer": true
+ },
+ "node_modules/loose-envify": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
+ "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
+ "peer": true,
+ "dependencies": {
+ "js-tokens": "^3.0.0 || ^4.0.0"
+ },
+ "bin": {
+ "loose-envify": "cli.js"
+ }
+ },
+ "node_modules/react": {
+ "version": "18.2.0",
+ "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz",
+ "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==",
+ "peer": true,
+ "dependencies": {
+ "loose-envify": "^1.1.0"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/react-dom": {
+ "version": "18.2.0",
+ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz",
+ "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==",
+ "peer": true,
+ "dependencies": {
+ "loose-envify": "^1.1.0",
+ "scheduler": "^0.23.0"
+ },
+ "peerDependencies": {
+ "react": "^18.2.0"
+ }
+ },
+ "node_modules/react-hot-toast": {
+ "version": "2.4.1",
+ "resolved": "https://registry.npmjs.org/react-hot-toast/-/react-hot-toast-2.4.1.tgz",
+ "integrity": "sha512-j8z+cQbWIM5LY37pR6uZR6D4LfseplqnuAO4co4u8917hBUvXlEqyP1ZzqVLcqoyUesZZv/ImreoCeHVDpE5pQ==",
+ "dependencies": {
+ "goober": "^2.1.10"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "peerDependencies": {
+ "react": ">=16",
+ "react-dom": ">=16"
+ }
+ },
+ "node_modules/scheduler": {
+ "version": "0.23.0",
+ "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz",
+ "integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==",
+ "peer": true,
+ "dependencies": {
+ "loose-envify": "^1.1.0"
+ }
+ }
+ },
+ "dependencies": {
+ "csstype": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz",
+ "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==",
+ "peer": true
+ },
+ "goober": {
+ "version": "2.1.13",
+ "resolved": "https://registry.npmjs.org/goober/-/goober-2.1.13.tgz",
+ "integrity": "sha512-jFj3BQeleOoy7t93E9rZ2de+ScC4lQICLwiAQmKMg9F6roKGaLSHoCDYKkWlSafg138jejvq/mTdvmnwDQgqoQ==",
+ "requires": {}
+ },
+ "js-tokens": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
+ "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
+ "peer": true
+ },
+ "loose-envify": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
+ "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
+ "peer": true,
+ "requires": {
+ "js-tokens": "^3.0.0 || ^4.0.0"
+ }
+ },
+ "react": {
+ "version": "18.2.0",
+ "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz",
+ "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==",
+ "peer": true,
+ "requires": {
+ "loose-envify": "^1.1.0"
+ }
+ },
+ "react-dom": {
+ "version": "18.2.0",
+ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz",
+ "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==",
+ "peer": true,
+ "requires": {
+ "loose-envify": "^1.1.0",
+ "scheduler": "^0.23.0"
+ }
+ },
+ "react-hot-toast": {
+ "version": "2.4.1",
+ "resolved": "https://registry.npmjs.org/react-hot-toast/-/react-hot-toast-2.4.1.tgz",
+ "integrity": "sha512-j8z+cQbWIM5LY37pR6uZR6D4LfseplqnuAO4co4u8917hBUvXlEqyP1ZzqVLcqoyUesZZv/ImreoCeHVDpE5pQ==",
+ "requires": {
+ "goober": "^2.1.10"
+ }
+ },
+ "scheduler": {
+ "version": "0.23.0",
+ "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz",
+ "integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==",
+ "peer": true,
+ "requires": {
+ "loose-envify": "^1.1.0"
+ }
+ }
+ }
+}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..7ec3947
--- /dev/null
+++ b/package.json
@@ -0,0 +1,5 @@
+{
+ "dependencies": {
+ "react-hot-toast": "^2.4.1"
+ }
+}
diff --git a/public/jetlogix-db-schema.png b/public/jetlogix-db-schema.png
new file mode 100644
index 0000000..185bca3
Binary files /dev/null and b/public/jetlogix-db-schema.png differ
diff --git a/public/robots.txt b/public/robots.txt
new file mode 100644
index 0000000..c19f78a
--- /dev/null
+++ b/public/robots.txt
@@ -0,0 +1 @@
+# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
diff --git a/spec/model/aeroplane_spec.rb b/spec/model/aeroplane_spec.rb
new file mode 100644
index 0000000..c6d7d19
--- /dev/null
+++ b/spec/model/aeroplane_spec.rb
@@ -0,0 +1,76 @@
+require 'rails_helper'
+
+RSpec.describe Aeroplane, type: :model do
+ describe 'validations' do
+ it 'name should be present' do
+ aeroplane = Aeroplane.new(model: 'ruby@mail.com',
+ image: 'image 1',
+ description: 'Description of the planes',
+ number_of_seats: 6,
+ location: 'Middle Earth',
+ fee: 60.0)
+ expect(aeroplane).to_not be_valid
+ end
+
+ it 'model should be present' do
+ aeroplane = Aeroplane.new(name: 'Dragon 1',
+ image: 'image 1',
+ description: 'Description of the planes',
+ number_of_seats: 6,
+ location: 'Middle Earth',
+ fee: 60.0)
+ expect(aeroplane).to_not be_valid
+ end
+
+ it 'image should be present' do
+ aeroplane = Aeroplane.new(name: 'Dragon 1',
+ model: 'Jet',
+ description: 'Description of the planes',
+ number_of_seats: 6,
+ location: 'Middle Earth',
+ fee: 60.0)
+ expect(aeroplane).to_not be_valid
+ end
+
+ it 'description should be present' do
+ aeroplane = Aeroplane.new(name: 'Dragon 1',
+ image: 'image 1',
+ model: 'Jet',
+ number_of_seats: 6,
+ location: 'Middle Earth',
+ fee: 60.0)
+ expect(aeroplane).to_not be_valid
+ end
+
+ it 'number_of_seats should be present' do
+ aeroplane = Aeroplane.new(name: 'Dragon 1',
+ image: 'image 1',
+ model: 'Jet',
+ description: 'Description of the planes',
+ location: 'Middle Earth',
+ fee: 60.0)
+ expect(aeroplane).to_not be_valid
+ end
+
+ it 'location should be present' do
+ aeroplane = Aeroplane.new(name: 'Dragon 1',
+ image: 'image 1',
+ model: 'Jet',
+ description: 'Description of the planes',
+ number_of_seats: 6,
+ fee: 60.0)
+ expect(aeroplane).to_not be_valid
+ end
+
+ it 'fee should be greater than 0' do
+ aeroplane = Aeroplane.new(name: 'Dragon 1',
+ image: 'image 1',
+ model: 'Jet',
+ description: 'Description of the planes',
+ number_of_seats: 6,
+ location: 'Middle Earth',
+ fee: -1)
+ expect(aeroplane).to_not be_valid
+ end
+ end
+end
diff --git a/spec/model/reservations_spec.rb b/spec/model/reservations_spec.rb
new file mode 100644
index 0000000..b0589b4
--- /dev/null
+++ b/spec/model/reservations_spec.rb
@@ -0,0 +1,40 @@
+require 'rails_helper'
+
+RSpec.describe Reservation, type: :model do
+ let(:user) do
+ User.new(name: 'bob', email: 'bob12@gmail.com', password: 'password12', password_confirmation: 'password12')
+ end
+ before { user.save }
+
+ let(:plane) do
+ Aeroplane.new(name: 'boning 777', model: 'ruby@mail.com', image: 'image 1', description: 'Description of the planes',
+ number_of_seats: 6, location: 'Middle Earth', fee: 60.0)
+ end
+ before { plane.save }
+ let(:reservation) do
+ Reservation.new(reserved_date: '2023-11-11', start_time: '18:24', end_time: '20:25', start_location: 'addis ababa',
+ destination: 'india', user_id: user.id, aeroplane_id: plane.id)
+ end
+ before { reservation.save }
+ context 'when testing the Reservation class' do
+ it 'should have user ' do
+ reservation.user_id = nil
+ expect(reservation).to_not be_valid
+ end
+ it 'should have areoplane ' do
+ reservation.aeroplane_id = nil
+ expect(reservation).to_not be_valid
+ end
+ it 'should have resevation date ' do
+ reservation.destination = nil
+ expect(reservation).to_not be_valid
+ end
+ it 'should have destination ' do
+ reservation.reserved_date = nil
+ expect(reservation).to_not be_valid
+ end
+ it 'should have pass if all valid ' do
+ expect(reservation).to be_valid
+ end
+ end
+end
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
new file mode 100644
index 0000000..6584c98
--- /dev/null
+++ b/spec/rails_helper.rb
@@ -0,0 +1,63 @@
+# This file is copied to spec/ when you run 'rails generate rspec:install'
+require 'spec_helper'
+ENV['RAILS_ENV'] ||= 'test'
+require_relative '../config/environment'
+# Prevent database truncation if the environment is production
+abort('The Rails environment is running in production mode!') if Rails.env.production?
+require 'rspec/rails'
+# Add additional requires below this line. Rails is not loaded until this point!
+
+# Requires supporting ruby files with custom matchers and macros, etc, in
+# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
+# run as spec files by default. This means that files in spec/support that end
+# in _spec.rb will both be required and run as specs, causing the specs to be
+# run twice. It is recommended that you do not name files matching this glob to
+# end with _spec.rb. You can configure this pattern with the --pattern
+# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
+#
+# The following line is provided for convenience purposes. It has the downside
+# of increasing the boot-up time by auto-requiring all files in the support
+# directory. Alternatively, in the individual `*_spec.rb` files, manually
+# require only the support files necessary.
+#
+# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }
+
+# Checks for pending migrations and applies them before tests are run.
+# If you are not using ActiveRecord, you can remove these lines.
+begin
+ ActiveRecord::Migration.maintain_test_schema!
+rescue ActiveRecord::PendingMigrationError => e
+ abort e.to_s.strip
+end
+RSpec.configure do |config|
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
+ config.fixture_path = "#{Rails.root}/spec/fixtures"
+
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
+ # examples within a transaction, remove the following line or assign false
+ # instead of true.
+ config.use_transactional_fixtures = true
+
+ # You can uncomment this line to turn off ActiveRecord support entirely.
+ # config.use_active_record = false
+
+ # RSpec Rails can automatically mix in different behaviours to your tests
+ # based on their file location, for example enabling you to call `get` and
+ # `post` in specs under `spec/controllers`.
+ #
+ # You can disable this behaviour by removing the line below, and instead
+ # explicitly tag your specs with their type, e.g.:
+ #
+ # RSpec.describe UsersController, type: :controller do
+ # # ...
+ # end
+ #
+ # The different available types are documented in the features, such as in
+ # https://rspec.info/features/6-0/rspec-rails
+ config.infer_spec_type_from_file_location!
+
+ # Filter lines from Rails gems in backtraces.
+ config.filter_rails_from_backtrace!
+ # arbitrary gems may also be filtered via:
+ # config.filter_gems_from_backtrace("gem name")
+end
diff --git a/spec/requests/aeroplanes_spec.rb b/spec/requests/aeroplanes_spec.rb
new file mode 100644
index 0000000..5a0e54e
--- /dev/null
+++ b/spec/requests/aeroplanes_spec.rb
@@ -0,0 +1,127 @@
+require 'rails_helper'
+
+# This spec was generated by rspec-rails when you ran the scaffold generator.
+# It demonstrates how one might use RSpec to test the controller code that
+# was generated by Rails when you ran the scaffold generator.
+#
+# It assumes that the implementation code is generated by the rails scaffold
+# generator. If you are using any extension libraries to generate different
+# controller code, this generated spec may or may not pass.
+#
+# It only uses APIs available in rails and/or rspec-rails. There are a number
+# of tools you can use to make these specs even more expressive, but we're
+# sticking to rails and rspec-rails APIs to keep things simple and stable.
+
+RSpec.describe '/aeroplanes', type: :request do
+ # This should return the minimal set of attributes required to create a valid
+ # Aeroplane. As you add validations to Aeroplane, be sure to
+ # adjust the attributes here as well.
+ let(:valid_attributes) do
+ skip('Add a hash of attributes valid for your model')
+ end
+
+ let(:invalid_attributes) do
+ skip('Add a hash of attributes invalid for your model')
+ end
+
+ # This should return the minimal set of values that should be in the headers
+ # in order to pass any filters (e.g. authentication) defined in
+ # AeroplanesController, or in your router and rack
+ # middleware. Be sure to keep this updated too.
+ let(:valid_headers) do
+ {}
+ end
+
+ describe 'GET /index' do
+ it 'renders a successful response' do
+ Aeroplane.create! valid_attributes
+ get aeroplanes_url, headers: valid_headers, as: :json
+ expect(response).to be_successful
+ end
+ end
+
+ describe 'GET /show' do
+ it 'renders a successful response' do
+ aeroplane = Aeroplane.create! valid_attributes
+ get aeroplane_url(aeroplane), as: :json
+ expect(response).to be_successful
+ end
+ end
+
+ describe 'POST /create' do
+ context 'with valid parameters' do
+ it 'creates a new Aeroplane' do
+ expect do
+ post aeroplanes_url,
+ params: { aeroplane: valid_attributes }, headers: valid_headers, as: :json
+ end.to change(Aeroplane, :count).by(1)
+ end
+
+ it 'renders a JSON response with the new aeroplane' do
+ post aeroplanes_url,
+ params: { aeroplane: valid_attributes }, headers: valid_headers, as: :json
+ expect(response).to have_http_status(:created)
+ expect(response.content_type).to match(a_string_including('application/json'))
+ end
+ end
+
+ context 'with invalid parameters' do
+ it 'does not create a new Aeroplane' do
+ expect do
+ post aeroplanes_url,
+ params: { aeroplane: invalid_attributes }, as: :json
+ end.to change(Aeroplane, :count).by(0)
+ end
+
+ it 'renders a JSON response with errors for the new aeroplane' do
+ post aeroplanes_url,
+ params: { aeroplane: invalid_attributes }, headers: valid_headers, as: :json
+ expect(response).to have_http_status(:unprocessable_entity)
+ expect(response.content_type).to match(a_string_including('application/json'))
+ end
+ end
+ end
+
+ describe 'PATCH /update' do
+ context 'with valid parameters' do
+ let(:new_attributes) do
+ skip('Add a hash of attributes valid for your model')
+ end
+
+ it 'updates the requested aeroplane' do
+ aeroplane = Aeroplane.create! valid_attributes
+ patch aeroplane_url(aeroplane),
+ params: { aeroplane: new_attributes }, headers: valid_headers, as: :json
+ aeroplane.reload
+ skip('Add assertions for updated state')
+ end
+
+ it 'renders a JSON response with the aeroplane' do
+ aeroplane = Aeroplane.create! valid_attributes
+ patch aeroplane_url(aeroplane),
+ params: { aeroplane: new_attributes }, headers: valid_headers, as: :json
+ expect(response).to have_http_status(:ok)
+ expect(response.content_type).to match(a_string_including('application/json'))
+ end
+ end
+
+ context 'with invalid parameters' do
+ it 'renders a JSON response with errors for the aeroplane' do
+ aeroplane = Aeroplane.create! valid_attributes
+ patch aeroplane_url(aeroplane),
+ params: { aeroplane: invalid_attributes }, headers: valid_headers, as: :json
+ expect(response).to have_http_status(:unprocessable_entity)
+ expect(response.content_type).to match(a_string_including('application/json'))
+ end
+ end
+ end
+
+ describe 'DELETE /destroy' do
+ it 'destroys the requested aeroplane' do
+ aeroplane = Aeroplane.create! valid_attributes
+ expect do
+ delete aeroplane_url(aeroplane), headers: valid_headers, as: :json
+ end.to change(Aeroplane, :count).by(-1)
+ end
+ end
+end
diff --git a/spec/requests/api/aeroplanes_spec.rb b/spec/requests/api/aeroplanes_spec.rb
new file mode 100644
index 0000000..e37c8eb
--- /dev/null
+++ b/spec/requests/api/aeroplanes_spec.rb
@@ -0,0 +1,107 @@
+require 'swagger_helper'
+
+describe '/aeroplanes/api' do
+ let(:user) do
+ {
+ id: 3,
+ name: 'Aeroplane 3',
+ email: 'ri@gmail.com',
+ password: 'https://images.unsplash.com/photo-1464037866556-6812c9d1c72e?auto=format&fit=crop&q=80&w=2070&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
+ role: 'user'
+
+ }
+ end
+
+ let(:aeroplane) do
+ {
+ name: 'Aeroplane 3',
+ model: 'Jet',
+ image: 'https://images.unsplash.com/photo-1464037866556-6812c9d1c72e?auto=format&fit=crop&q=80&w=2070&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
+ description: 'yolo',
+ number_of_seats: 6,
+ location: 'test',
+ fee: 90.0,
+ reserved: false
+
+ }
+ end
+
+ # index of aeroplanes
+ path '/api/v1/users/{user_id}/aeroplanes' do
+ get 'Retrieves aeroplanes' do
+ tags 'Aeroplanes'
+ produces 'application/json'
+ parameter name: :user_id, in: :path, type: :string, required: true
+ response '200', 'aeroplane found' do
+ run_test!
+ end
+ end
+ end
+
+ # create aeroplanes
+ path '/api/v1/users/{user_id}/aeroplanes' do
+ post 'Creates an Aeroplane' do
+ tags 'Aeroplanes'
+ consumes 'application/json'
+ parameter name: :user_id, in: :path, type: :string, required: true
+ parameter name: 'aeroplane', in: :body, schema: {
+ type: :object,
+ properties: {
+ name: { type: :string },
+ model: { type: :string },
+ image: { type: :string },
+ description: { type: :string },
+ number_of_seats: { type: :integer },
+ location: { type: :string },
+ fee: { type: :number },
+ reserved: { type: :boolean }
+ },
+ required: %w[name model image description number_of_seats location fee reserved]
+ }
+ response '200', 'aeroplane created' do
+ let(:aeroplane) do
+ {
+ name: 'Aeroplane 3',
+ model: 'Jet',
+ image: 'https://images.unsplash.com/photo-1464037866556-6812c9d1c72e?auto=format&fit=crop&q=80&w=2070&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
+ description: 'yolo',
+ number_of_seats: 6,
+ location: 'test',
+ fee: 90.0,
+ reserved: false
+ }
+ end
+ run_test!
+ end
+ end
+ end
+
+ # show aeroplanes
+ path '/api/v1/users/{user_id}/aeroplanes/{id}' do
+ get 'Retrieves an aeroplane' do
+ tags 'Aeroplanes'
+ produces 'application/json'
+ parameter name: :user_id, in: :path, type: :string, required: true
+ parameter name: :id, in: :path, type: :string, required: true
+ response '200', 'aeroplane found' do
+ run_test!
+ end
+ end
+ end
+
+ # delete aeroplanes
+ path '/api/v1/users/{user_id}/aeroplanes/{id}' do
+ delete 'Delete an aeroplane' do
+ tags 'Aeroplanes'
+ produces 'application/json'
+ parameter name: :user_id, in: :path, type: :string, required: true
+ parameter name: :id, in: :path, type: :string, required: true
+ response '204', 'Aeroplane deleted successfully' do
+ run_test!
+ end
+ response '404', 'Failed to delete aeroplane' do
+ run_test!
+ end
+ end
+ end
+end
diff --git a/spec/requests/api/reservations_spec.rb b/spec/requests/api/reservations_spec.rb
new file mode 100644
index 0000000..0ea6535
--- /dev/null
+++ b/spec/requests/api/reservations_spec.rb
@@ -0,0 +1,85 @@
+require 'swagger_helper'
+
+describe '/reservations' do
+ # This should return the minimal set of attributes required to create a valid
+ # Reservation. As you add validations to Reservation, be sure to
+ # adjust the attributes here as well.
+ # This should return the minimal set of values that should be in the headers
+ # in order to pass any filters (e.g. authentication) defined in
+ # ReservationsController, or in your router and rack
+ # middleware. Be sure to keep this updated too.
+ let(:user) do
+ {
+ id: 3,
+ name: 'Reservation 3',
+ email: 'ri@gmail.com',
+ password: 'https://images.unsplash.com/photo-1464037866556-6812c9d1c72e?auto=format&fit=crop&q=80&w=2070&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
+ role: 'user'
+
+ }
+ end
+
+ let(:reservation) do
+ {
+ reserved_date: '2021-04-20',
+ start_time: '2021-04-20 12:00:00',
+ end_time: '2021-04-20 13:00:00',
+ start_location: 'Test',
+ destination: 'Thailand',
+ user_id: 3,
+ aeroplane_id: 14
+
+ }
+ end
+
+ # index of reservations
+ path '/api/v1/users/{user_id}/reservations' do
+ get 'Retrieves reservations' do
+ tags 'Reservations'
+ produces 'application/json'
+ parameter name: :user_id, in: :path, type: :string, required: true
+ response '200', 'reservations found' do
+ run_test!
+ end
+ end
+ end
+
+ # Create Reservation
+ path '/api/v1/users/{user_id}/reservations' do
+ post 'Creates a Reservation' do
+ tags 'Reservations'
+ consumes 'application/json'
+ parameter name: :user_id, in: :path, type: :string, required: true
+ parameter name: 'reservations', in: :body, schema: {
+ type: :object,
+ properties: {
+ reserved_date: { type: :string, format: :datetime },
+ start_time: { type: :string, format: :datetime },
+ end_time: { type: :string, format: :datetime },
+ start_location: { type: :string },
+ destination: { type: :string },
+ user_id: { type: :number },
+ aeroplane_id: { type: :number }
+ },
+ required: %w[reserved_date destination user_id aeroplane_id]
+ }
+ response '200', 'reservations created' do
+ let(:reservations) do
+ {
+ reserved_date: '2021-04-20',
+ start_time: '2021-04-20 12:00:00',
+ end_time: '2021-04-20 13:00:00',
+ start_location: 'Test',
+ destination: 'Thailand',
+ user_id: 3,
+ aeroplane_id: 14
+ }
+ end
+ run_test!
+ end
+ response '422', 'Reservations creation failed' do
+ run_test!
+ end
+ end
+ end
+end
diff --git a/spec/requests/reservations_spec.rb b/spec/requests/reservations_spec.rb
new file mode 100644
index 0000000..20d0a72
--- /dev/null
+++ b/spec/requests/reservations_spec.rb
@@ -0,0 +1,127 @@
+require 'rails_helper'
+
+# This spec was generated by rspec-rails when you ran the scaffold generator.
+# It demonstrates how one might use RSpec to test the controller code that
+# was generated by Rails when you ran the scaffold generator.
+#
+# It assumes that the implementation code is generated by the rails scaffold
+# generator. If you are using any extension libraries to generate different
+# controller code, this generated spec may or may not pass.
+#
+# It only uses APIs available in rails and/or rspec-rails. There are a number
+# of tools you can use to make these specs even more expressive, but we're
+# sticking to rails and rspec-rails APIs to keep things simple and stable.
+
+RSpec.describe '/reservations', type: :request do
+ # This should return the minimal set of attributes required to create a valid
+ # Reservation. As you add validations to Reservation, be sure to
+ # adjust the attributes here as well.
+ let(:valid_attributes) do
+ skip('Add a hash of attributes valid for your model')
+ end
+
+ let(:invalid_attributes) do
+ skip('Add a hash of attributes invalid for your model')
+ end
+
+ # This should return the minimal set of values that should be in the headers
+ # in order to pass any filters (e.g. authentication) defined in
+ # ReservationsController, or in your router and rack
+ # middleware. Be sure to keep this updated too.
+ let(:valid_headers) do
+ {}
+ end
+
+ describe 'GET /index' do
+ it 'renders a successful response' do
+ Reservation.create! valid_attributes
+ get reservations_url, headers: valid_headers, as: :json
+ expect(response).to be_successful
+ end
+ end
+
+ describe 'GET /show' do
+ it 'renders a successful response' do
+ reservation = Reservation.create! valid_attributes
+ get reservation_url(reservation), as: :json
+ expect(response).to be_successful
+ end
+ end
+
+ describe 'POST /create' do
+ context 'with valid parameters' do
+ it 'creates a new Reservation' do
+ expect do
+ post reservations_url,
+ params: { reservation: valid_attributes }, headers: valid_headers, as: :json
+ end.to change(Reservation, :count).by(1)
+ end
+
+ it 'renders a JSON response with the new reservation' do
+ post reservations_url,
+ params: { reservation: valid_attributes }, headers: valid_headers, as: :json
+ expect(response).to have_http_status(:created)
+ expect(response.content_type).to match(a_string_including('application/json'))
+ end
+ end
+
+ context 'with invalid parameters' do
+ it 'does not create a new Reservation' do
+ expect do
+ post reservations_url,
+ params: { reservation: invalid_attributes }, as: :json
+ end.to change(Reservation, :count).by(0)
+ end
+
+ it 'renders a JSON response with errors for the new reservation' do
+ post reservations_url,
+ params: { reservation: invalid_attributes }, headers: valid_headers, as: :json
+ expect(response).to have_http_status(:unprocessable_entity)
+ expect(response.content_type).to match(a_string_including('application/json'))
+ end
+ end
+ end
+
+ describe 'PATCH /update' do
+ context 'with valid parameters' do
+ let(:new_attributes) do
+ skip('Add a hash of attributes valid for your model')
+ end
+
+ it 'updates the requested reservation' do
+ reservation = Reservation.create! valid_attributes
+ patch reservation_url(reservation),
+ params: { reservation: new_attributes }, headers: valid_headers, as: :json
+ reservation.reload
+ skip('Add assertions for updated state')
+ end
+
+ it 'renders a JSON response with the reservation' do
+ reservation = Reservation.create! valid_attributes
+ patch reservation_url(reservation),
+ params: { reservation: new_attributes }, headers: valid_headers, as: :json
+ expect(response).to have_http_status(:ok)
+ expect(response.content_type).to match(a_string_including('application/json'))
+ end
+ end
+
+ context 'with invalid parameters' do
+ it 'renders a JSON response with errors for the reservation' do
+ reservation = Reservation.create! valid_attributes
+ patch reservation_url(reservation),
+ params: { reservation: invalid_attributes }, headers: valid_headers, as: :json
+ expect(response).to have_http_status(:unprocessable_entity)
+ expect(response.content_type).to match(a_string_including('application/json'))
+ end
+ end
+ end
+
+ describe 'DELETE /destroy' do
+ it 'destroys the requested reservation' do
+ reservation = Reservation.create! valid_attributes
+ expect do
+ delete reservation_url(reservation), headers: valid_headers, as: :json
+ end.to change(Reservation, :count).by(-1)
+ end
+ end
+end
diff --git a/spec/requests/users_spec.rb b/spec/requests/users_spec.rb
new file mode 100644
index 0000000..3cc4f89
--- /dev/null
+++ b/spec/requests/users_spec.rb
@@ -0,0 +1,127 @@
+require 'rails_helper'
+
+# This spec was generated by rspec-rails when you ran the scaffold generator.
+# It demonstrates how one might use RSpec to test the controller code that
+# was generated by Rails when you ran the scaffold generator.
+#
+# It assumes that the implementation code is generated by the rails scaffold
+# generator. If you are using any extension libraries to generate different
+# controller code, this generated spec may or may not pass.
+#
+# It only uses APIs available in rails and/or rspec-rails. There are a number
+# of tools you can use to make these specs even more expressive, but we're
+# sticking to rails and rspec-rails APIs to keep things simple and stable.
+
+RSpec.describe '/users', type: :request do
+ # This should return the minimal set of attributes required to create a valid
+ # User. As you add validations to User, be sure to
+ # adjust the attributes here as well.
+ let(:valid_attributes) do
+ skip('Add a hash of attributes valid for your model')
+ end
+
+ let(:invalid_attributes) do
+ skip('Add a hash of attributes invalid for your model')
+ end
+
+ # This should return the minimal set of values that should be in the headers
+ # in order to pass any filters (e.g. authentication) defined in
+ # UsersController, or in your router and rack
+ # middleware. Be sure to keep this updated too.
+ let(:valid_headers) do
+ {}
+ end
+
+ describe 'GET /index' do
+ it 'renders a successful response' do
+ User.create! valid_attributes
+ get users_url, headers: valid_headers, as: :json
+ expect(response).to be_successful
+ end
+ end
+
+ describe 'GET /show' do
+ it 'renders a successful response' do
+ user = User.create! valid_attributes
+ get user_url(user), as: :json
+ expect(response).to be_successful
+ end
+ end
+
+ describe 'POST /create' do
+ context 'with valid parameters' do
+ it 'creates a new User' do
+ expect do
+ post users_url,
+ params: { user: valid_attributes }, headers: valid_headers, as: :json
+ end.to change(User, :count).by(1)
+ end
+
+ it 'renders a JSON response with the new user' do
+ post users_url,
+ params: { user: valid_attributes }, headers: valid_headers, as: :json
+ expect(response).to have_http_status(:created)
+ expect(response.content_type).to match(a_string_including('application/json'))
+ end
+ end
+
+ context 'with invalid parameters' do
+ it 'does not create a new User' do
+ expect do
+ post users_url,
+ params: { user: invalid_attributes }, as: :json
+ end.to change(User, :count).by(0)
+ end
+
+ it 'renders a JSON response with errors for the new user' do
+ post users_url,
+ params: { user: invalid_attributes }, headers: valid_headers, as: :json
+ expect(response).to have_http_status(:unprocessable_entity)
+ expect(response.content_type).to match(a_string_including('application/json'))
+ end
+ end
+ end
+
+ describe 'PATCH /update' do
+ context 'with valid parameters' do
+ let(:new_attributes) do
+ skip('Add a hash of attributes valid for your model')
+ end
+
+ it 'updates the requested user' do
+ user = User.create! valid_attributes
+ patch user_url(user),
+ params: { user: new_attributes }, headers: valid_headers, as: :json
+ user.reload
+ skip('Add assertions for updated state')
+ end
+
+ it 'renders a JSON response with the user' do
+ user = User.create! valid_attributes
+ patch user_url(user),
+ params: { user: new_attributes }, headers: valid_headers, as: :json
+ expect(response).to have_http_status(:ok)
+ expect(response.content_type).to match(a_string_including('application/json'))
+ end
+ end
+
+ context 'with invalid parameters' do
+ it 'renders a JSON response with errors for the user' do
+ user = User.create! valid_attributes
+ patch user_url(user),
+ params: { user: invalid_attributes }, headers: valid_headers, as: :json
+ expect(response).to have_http_status(:unprocessable_entity)
+ expect(response.content_type).to match(a_string_including('application/json'))
+ end
+ end
+ end
+
+ describe 'DELETE /destroy' do
+ it 'destroys the requested user' do
+ user = User.create! valid_attributes
+ expect do
+ delete user_url(user), headers: valid_headers, as: :json
+ end.to change(User, :count).by(-1)
+ end
+ end
+end
diff --git a/spec/routing/aeroplanes_routing_spec.rb b/spec/routing/aeroplanes_routing_spec.rb
new file mode 100644
index 0000000..2d9b1db
--- /dev/null
+++ b/spec/routing/aeroplanes_routing_spec.rb
@@ -0,0 +1,29 @@
+require 'rails_helper'
+
+RSpec.describe AeroplanesController, type: :routing do
+ describe 'routing' do
+ it 'routes to #index' do
+ expect(get: '/aeroplanes').to route_to('aeroplanes#index')
+ end
+
+ it 'routes to #show' do
+ expect(get: '/aeroplanes/1').to route_to('aeroplanes#show', id: '1')
+ end
+
+ it 'routes to #create' do
+ expect(post: '/aeroplanes').to route_to('aeroplanes#create')
+ end
+
+ it 'routes to #update via PUT' do
+ expect(put: '/aeroplanes/1').to route_to('aeroplanes#update', id: '1')
+ end
+
+ it 'routes to #update via PATCH' do
+ expect(patch: '/aeroplanes/1').to route_to('aeroplanes#update', id: '1')
+ end
+
+ it 'routes to #destroy' do
+ expect(delete: '/aeroplanes/1').to route_to('aeroplanes#destroy', id: '1')
+ end
+ end
+end
diff --git a/spec/routing/reservations_routing_spec.rb b/spec/routing/reservations_routing_spec.rb
new file mode 100644
index 0000000..78cbaff
--- /dev/null
+++ b/spec/routing/reservations_routing_spec.rb
@@ -0,0 +1,29 @@
+require 'rails_helper'
+
+RSpec.describe ReservationsController, type: :routing do
+ describe 'routing' do
+ it 'routes to #index' do
+ expect(get: '/reservations').to route_to('reservations#index')
+ end
+
+ it 'routes to #show' do
+ expect(get: '/reservations/1').to route_to('reservations#show', id: '1')
+ end
+
+ it 'routes to #create' do
+ expect(post: '/reservations').to route_to('reservations#create')
+ end
+
+ it 'routes to #update via PUT' do
+ expect(put: '/reservations/1').to route_to('reservations#update', id: '1')
+ end
+
+ it 'routes to #update via PATCH' do
+ expect(patch: '/reservations/1').to route_to('reservations#update', id: '1')
+ end
+
+ it 'routes to #destroy' do
+ expect(delete: '/reservations/1').to route_to('reservations#destroy', id: '1')
+ end
+ end
+end
diff --git a/spec/routing/users_routing_spec.rb b/spec/routing/users_routing_spec.rb
new file mode 100644
index 0000000..bc392dd
--- /dev/null
+++ b/spec/routing/users_routing_spec.rb
@@ -0,0 +1,29 @@
+require 'rails_helper'
+
+RSpec.describe UsersController, type: :routing do
+ describe 'routing' do
+ it 'routes to #index' do
+ expect(get: '/users').to route_to('users#index')
+ end
+
+ it 'routes to #show' do
+ expect(get: '/users/1').to route_to('users#show', id: '1')
+ end
+
+ it 'routes to #create' do
+ expect(post: '/users').to route_to('users#create')
+ end
+
+ it 'routes to #update via PUT' do
+ expect(put: '/users/1').to route_to('users#update', id: '1')
+ end
+
+ it 'routes to #update via PATCH' do
+ expect(patch: '/users/1').to route_to('users#update', id: '1')
+ end
+
+ it 'routes to #destroy' do
+ expect(delete: '/users/1').to route_to('users#destroy', id: '1')
+ end
+ end
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
new file mode 100644
index 0000000..dc50747
--- /dev/null
+++ b/spec/spec_helper.rb
@@ -0,0 +1,96 @@
+# This file was generated by the `rails generate rspec:install` command. Conventionally, all
+# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
+# The generated `.rspec` file contains `--require spec_helper` which will cause
+# this file to always be loaded, without a need to explicitly require it in any
+# files.
+#
+# Given that it is always loaded, you are encouraged to keep this file as
+# light-weight as possible. Requiring heavyweight dependencies from this file
+# will add to the boot time of your test suite on EVERY test run, even for an
+# individual file that may not need all of that loaded. Instead, consider making
+# a separate helper file that requires the additional dependencies and performs
+# the additional setup, and require it from the spec files that actually need
+# it.
+#
+# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
+RSpec.configure do |config|
+ # rspec-expectations config goes here. You can use an alternate
+ # assertion/expectation library such as wrong or the stdlib/minitest
+ # assertions if you prefer.
+ config.expect_with :rspec do |expectations|
+ # This option will default to `true` in RSpec 4. It makes the `description`
+ # and `failure_message` of custom matchers include text for helper methods
+ # defined using `chain`, e.g.:
+ # be_bigger_than(2).and_smaller_than(4).description
+ # # => "be bigger than 2 and smaller than 4"
+ # ...rather than:
+ # # => "be bigger than 2"
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
+ end
+
+ # rspec-mocks config goes here. You can use an alternate test double
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
+ config.mock_with :rspec do |mocks|
+ # Prevents you from mocking or stubbing a method that does not exist on
+ # a real object. This is generally recommended, and will default to
+ # `true` in RSpec 4.
+ mocks.verify_partial_doubles = true
+ end
+
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
+ # have no way to turn it off -- the option exists only for backwards
+ # compatibility in RSpec 3). It causes shared context metadata to be
+ # inherited by the metadata hash of host groups and examples, rather than
+ # triggering implicit auto-inclusion in groups with matching metadata.
+ config.shared_context_metadata_behavior = :apply_to_host_groups
+
+ # The settings below are suggested to provide a good initial experience
+ # with RSpec, but feel free to customize to your heart's content.
+ # # This allows you to limit a spec run to individual examples or groups
+ # # you care about by tagging them with `:focus` metadata. When nothing
+ # # is tagged with `:focus`, all examples get run. RSpec also provides
+ # # aliases for `it`, `describe`, and `context` that include `:focus`
+ # # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
+ # config.filter_run_when_matching :focus
+ #
+ # # Allows RSpec to persist some state between runs in order to support
+ # # the `--only-failures` and `--next-failure` CLI options. We recommend
+ # # you configure your source control system to ignore this file.
+ # config.example_status_persistence_file_path = "spec/examples.txt"
+ #
+ # # Limits the available syntax to the non-monkey patched syntax that is
+ # # recommended. For more details, see:
+ # # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/
+ # config.disable_monkey_patching!
+ #
+ # # This setting enables warnings. It's recommended, but in some cases may
+ # # be too noisy due to issues in dependencies.
+ # config.warnings = true
+ #
+ # # Many RSpec users commonly either run the entire suite or an individual
+ # # file, and it's useful to allow more verbose output when running an
+ # # individual spec file.
+ # if config.files_to_run.one?
+ # # Use the documentation formatter for detailed output,
+ # # unless a formatter has already been configured
+ # # (e.g. via a command-line flag).
+ # config.default_formatter = "doc"
+ # end
+ #
+ # # Print the 10 slowest examples and example groups at the
+ # # end of the spec run, to help surface which specs are running
+ # # particularly slow.
+ # config.profile_examples = 10
+ #
+ # # Run specs in random order to surface order dependencies. If you find an
+ # # order dependency and want to debug it, you can fix the order by providing
+ # # the seed, which is printed after each run.
+ # # --seed 1234
+ # config.order = :random
+ #
+ # # Seed global randomization in this process using the `--seed` CLI option.
+ # # Setting this allows you to use `--seed` to deterministically reproduce
+ # # test failures related to randomization by passing the same `--seed` value
+ # # as the one that triggered the failure.
+ # Kernel.srand config.seed
+end
diff --git a/spec/swagger_helper.rb b/spec/swagger_helper.rb
new file mode 100644
index 0000000..9f1bf73
--- /dev/null
+++ b/spec/swagger_helper.rb
@@ -0,0 +1,41 @@
+require 'rails_helper'
+
+RSpec.configure do |config|
+ # Specify a root folder where Swagger JSON files are generated
+ # NOTE: If you're using the rswag-api to serve API descriptions, you'll need
+ # to ensure that it's configured to serve Swagger from the same folder
+ config.swagger_root = Rails.root.join('swagger').to_s
+
+ # Define one or more Swagger documents and provide global metadata for each one
+ # When you run the 'rswag:specs:swaggerize' rake task, the complete Swagger will
+ # be generated at the provided relative path under swagger_root
+ # By default, the operations defined in spec files are added to the first
+ # document below. You can override this behavior by adding a swagger_doc tag to the
+ # the root example_group in your specs, e.g. describe '...', swagger_doc: 'v2/swagger.json'
+ config.swagger_docs = {
+ 'v1/swagger.yaml' => {
+ openapi: '3.0.1',
+ info: {
+ title: 'API V1',
+ version: 'v1'
+ },
+ paths: {},
+ servers: [
+ {
+ url: 'https://{defaultHost}',
+ variables: {
+ defaultHost: {
+ default: 'http://127.0.0.1:4000/'
+ }
+ }
+ }
+ ]
+ }
+ }
+
+ # Specify the format of the output Swagger file when running 'rswag:specs:swaggerize'.
+ # The swagger_docs configuration option has the filename including format in
+ # the key, this may want to be changed to avoid putting yaml in json files.
+ # Defaults to json. Accepts ':json' and ':yaml'.
+ config.swagger_format = :yaml
+end
diff --git a/storage/.keep b/storage/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/swagger/v1/swagger.yaml b/swagger/v1/swagger.yaml
new file mode 100644
index 0000000..a8815c7
--- /dev/null
+++ b/swagger/v1/swagger.yaml
@@ -0,0 +1,165 @@
+---
+openapi: 3.0.1
+info:
+ title: API V1
+ version: v1
+paths:
+ "/api/v1/users/{user_id}/aeroplanes":
+ get:
+ summary: Retrieves aeroplanes
+ tags:
+ - Aeroplanes
+ parameters:
+ - name: user_id
+ in: path
+ required: true
+ schema:
+ type: string
+ responses:
+ '200':
+ description: aeroplane found
+ post:
+ summary: Creates an Aeroplane
+ tags:
+ - Aeroplanes
+ parameters:
+ - name: user_id
+ in: path
+ required: true
+ schema:
+ type: string
+ responses:
+ '200':
+ description: aeroplane created
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ name:
+ type: string
+ model:
+ type: string
+ image:
+ type: string
+ description:
+ type: string
+ number_of_seats:
+ type: integer
+ location:
+ type: string
+ fee:
+ type: number
+ reserved:
+ type: boolean
+ required:
+ - name
+ - model
+ - image
+ - description
+ - number_of_seats
+ - location
+ - fee
+ - reserved
+ "/api/v1/users/{user_id}/aeroplanes/{id}":
+ get:
+ summary: Retrieves an aeroplane
+ tags:
+ - Aeroplanes
+ parameters:
+ - name: user_id
+ in: path
+ required: true
+ schema:
+ type: string
+ - name: id
+ in: path
+ required: true
+ schema:
+ type: string
+ responses:
+ '200':
+ description: aeroplane found
+ delete:
+ summary: Delete an aeroplane
+ tags:
+ - Aeroplanes
+ parameters:
+ - name: user_id
+ in: path
+ required: true
+ schema:
+ type: string
+ - name: id
+ in: path
+ required: true
+ schema:
+ type: string
+ responses:
+ '204':
+ description: Aeroplane deleted successfully
+ '404':
+ description: Failed to delete aeroplane
+ "/api/v1/users/{user_id}/reservations":
+ get:
+ summary: Retrieves reservations
+ tags:
+ - Reservations
+ parameters:
+ - name: user_id
+ in: path
+ required: true
+ schema:
+ type: string
+ responses:
+ '200':
+ description: reservations found
+ post:
+ summary: Creates a Reservation
+ tags:
+ - Reservations
+ parameters:
+ - name: user_id
+ in: path
+ required: true
+ schema:
+ type: string
+ responses:
+ '200':
+ description: reservations created
+ '422':
+ description: Reservations creation failed
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ reserved_date:
+ type: string
+ format: datetime
+ start_time:
+ type: string
+ format: datetime
+ end_time:
+ type: string
+ format: datetime
+ start_location:
+ type: string
+ destination:
+ type: string
+ user_id:
+ type: number
+ aeroplane_id:
+ type: number
+ required:
+ - reserved_date
+ - destination
+ - user_id
+ - aeroplane_id
+servers:
+- url: https://{defaultHost}
+ variables:
+ defaultHost:
+ default: http://127.0.0.1:4000/
diff --git a/tmp/.keep b/tmp/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/tmp/pids/.keep b/tmp/pids/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/tmp/storage/.keep b/tmp/storage/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/vendor/.keep b/vendor/.keep
new file mode 100644
index 0000000..e69de29