micro_api 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +14 -0
- data/app/controllers/micro_api/application_controller.rb +4 -0
- data/app/controllers/micro_api/static_controller.rb +16 -0
- data/app/models/micro_api/application_record.rb +6 -0
- data/config/routes.rb +6 -0
- data/lib/micro_api/engine.rb +16 -0
- data/lib/micro_api/version.rb +3 -0
- data/lib/micro_api.rb +6 -0
- data/lib/tasks/micro_api_tasks.rake +4 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +25 -0
- data/spec/dummy/config/application.rb +41 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +51 -0
- data/spec/dummy/config/environments/production.rb +65 -0
- data/spec/dummy/config/environments/test.rb +50 -0
- data/spec/dummy/config/initializers/cors.rb +16 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +8 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/puma.rb +43 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config.ru +6 -0
- data/spec/rails_helper.rb +60 -0
- data/spec/requests/micro_api/static_spec.rb +25 -0
- data/spec/spec_helper.rb +97 -0
- data/spec/support/request_spec_helper.rb +7 -0
- metadata +159 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 760d9919d69b54e4fedf75c0d33c3e5fd92b40b90d276f0c5b03957e59c1cc03
|
4
|
+
data.tar.gz: f4d1dbd92376d089ba6e1dbc2ec68b4f4a7f19c9dd6da4c98c991533ec8dfc49
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6f18a322f332c97f230b3cd92dcd5a674b74556c3c3ddbccd45fc2afcd8546661924e61d8e7d70dcc09648eecf07baac78da4dc0517852b8081fbe778bb24831
|
7
|
+
data.tar.gz: 6fbe29b7dd071e6d80d7f64c28e32e9bf4f04c615a74fe9b6c954ac2b6df93aed373efec7ed66ec60ceffc0c2d1ed3a678ae37bc204be402d4e2cb3f8e21fda6
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2023 lelered
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# MicroApi
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem "micro_api"
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install micro_api
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
26
|
+
|
27
|
+
## License
|
28
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
|
3
|
+
load "rails/tasks/statistics.rake"
|
4
|
+
|
5
|
+
require "bundler/gem_tasks"
|
6
|
+
|
7
|
+
|
8
|
+
require 'rspec/core'
|
9
|
+
require 'rspec/core/rake_task'
|
10
|
+
|
11
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
12
|
+
RSpec::Core::RakeTask.new(:spec)
|
13
|
+
|
14
|
+
task :default => :spec
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module MicroApi
|
2
|
+
class StaticController < ApplicationController
|
3
|
+
def healthz
|
4
|
+
render json: { status: :ok }
|
5
|
+
end
|
6
|
+
|
7
|
+
def version
|
8
|
+
render json: {
|
9
|
+
ac: Rails.application.class.to_s.split("::").first, # app code
|
10
|
+
cenv: ENV.fetch("CLOUD_ENV", "local"), # cloud env
|
11
|
+
env: Rails.env, # rails env
|
12
|
+
itag: ENV.fetch("IMAGE_TAG", nil), # image tag
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/config/routes.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module MicroApi
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace MicroApi
|
4
|
+
config.generators.api_only = true
|
5
|
+
|
6
|
+
config.generators do |g|
|
7
|
+
g.test_framework :rspec,
|
8
|
+
controller_specs: true,
|
9
|
+
fixtures: false,
|
10
|
+
helper_specs: false,
|
11
|
+
request_specs: true,
|
12
|
+
routing_specs: true,
|
13
|
+
view_specs: false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/micro_api.rb
ADDED
data/spec/dummy/Rakefile
ADDED
data/spec/dummy/bin/rake
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "fileutils"
|
3
|
+
|
4
|
+
# path to your application root.
|
5
|
+
APP_ROOT = File.expand_path("..", __dir__)
|
6
|
+
|
7
|
+
def system!(*args)
|
8
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
9
|
+
end
|
10
|
+
|
11
|
+
FileUtils.chdir APP_ROOT do
|
12
|
+
# This script is a way to set up or update your development environment automatically.
|
13
|
+
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
|
14
|
+
# Add necessary setup steps to this file.
|
15
|
+
|
16
|
+
puts "== Installing dependencies =="
|
17
|
+
system! "gem install bundler --conservative"
|
18
|
+
system("bundle check") || system!("bundle install")
|
19
|
+
|
20
|
+
puts "\n== Removing old logs and tempfiles =="
|
21
|
+
system! "bin/rails log:clear tmp:clear"
|
22
|
+
|
23
|
+
puts "\n== Restarting application server =="
|
24
|
+
system! "bin/rails restart"
|
25
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative "boot"
|
2
|
+
|
3
|
+
require "rails"
|
4
|
+
# Pick the frameworks you want:
|
5
|
+
require "active_model/railtie"
|
6
|
+
# require "active_job/railtie"
|
7
|
+
# require "active_record/railtie"
|
8
|
+
# require "active_storage/engine"
|
9
|
+
require "action_controller/railtie"
|
10
|
+
# require "action_mailer/railtie"
|
11
|
+
# require "action_mailbox/engine"
|
12
|
+
# require "action_text/engine"
|
13
|
+
require "action_view/railtie"
|
14
|
+
# require "action_cable/engine"
|
15
|
+
# require "rails/test_unit/railtie"
|
16
|
+
|
17
|
+
# Require the gems listed in Gemfile, including any gems
|
18
|
+
# you've limited to :test, :development, or :production.
|
19
|
+
Bundler.require(*Rails.groups)
|
20
|
+
require "micro_api"
|
21
|
+
|
22
|
+
module Dummy
|
23
|
+
class Application < Rails::Application
|
24
|
+
config.load_defaults Rails::VERSION::STRING.to_f
|
25
|
+
|
26
|
+
# Configuration for the application, engines, and railties goes here.
|
27
|
+
#
|
28
|
+
# These settings can be overridden in specific environments using the files
|
29
|
+
# in config/environments, which are processed later.
|
30
|
+
#
|
31
|
+
# config.time_zone = "Central Time (US & Canada)"
|
32
|
+
# config.eager_load_paths << Rails.root.join("extras")
|
33
|
+
|
34
|
+
# Only loads a smaller set of middleware suitable for API only apps.
|
35
|
+
# Middleware like session, flash, cookies can be added back manually.
|
36
|
+
# Skip views, helpers and assets when generating a new resource.
|
37
|
+
config.api_only = true
|
38
|
+
|
39
|
+
config.hosts << "www.example.com"
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "active_support/core_ext/integer/time"
|
2
|
+
|
3
|
+
Rails.application.configure do
|
4
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
5
|
+
|
6
|
+
# In the development environment your application's code is reloaded any time
|
7
|
+
# it changes. This slows down response time but is perfect for development
|
8
|
+
# since you don't have to restart the web server when you make code changes.
|
9
|
+
config.cache_classes = false
|
10
|
+
|
11
|
+
# Do not eager load code on boot.
|
12
|
+
config.eager_load = false
|
13
|
+
|
14
|
+
# Show full error reports.
|
15
|
+
config.consider_all_requests_local = true
|
16
|
+
|
17
|
+
# Enable server timing
|
18
|
+
config.server_timing = true
|
19
|
+
|
20
|
+
# Enable/disable caching. By default caching is disabled.
|
21
|
+
# Run rails dev:cache to toggle caching.
|
22
|
+
if Rails.root.join("tmp/caching-dev.txt").exist?
|
23
|
+
config.cache_store = :memory_store
|
24
|
+
config.public_file_server.headers = {
|
25
|
+
"Cache-Control" => "public, max-age=#{2.days.to_i}"
|
26
|
+
}
|
27
|
+
else
|
28
|
+
config.action_controller.perform_caching = false
|
29
|
+
|
30
|
+
config.cache_store = :null_store
|
31
|
+
end
|
32
|
+
|
33
|
+
# Print deprecation notices to the Rails logger.
|
34
|
+
config.active_support.deprecation = :log
|
35
|
+
|
36
|
+
# Raise exceptions for disallowed deprecations.
|
37
|
+
config.active_support.disallowed_deprecation = :raise
|
38
|
+
|
39
|
+
# Tell Active Support which deprecation messages to disallow.
|
40
|
+
config.active_support.disallowed_deprecation_warnings = []
|
41
|
+
|
42
|
+
|
43
|
+
# Raises error for missing translations.
|
44
|
+
# config.i18n.raise_on_missing_translations = true
|
45
|
+
|
46
|
+
# Annotate rendered view with file names.
|
47
|
+
# config.action_view.annotate_rendered_view_with_filenames = true
|
48
|
+
|
49
|
+
# Uncomment if you wish to allow Action Cable access from any origin.
|
50
|
+
# config.action_cable.disable_request_forgery_protection = true
|
51
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require "active_support/core_ext/integer/time"
|
2
|
+
|
3
|
+
Rails.application.configure do
|
4
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
5
|
+
|
6
|
+
# Code is not reloaded between requests.
|
7
|
+
config.cache_classes = true
|
8
|
+
|
9
|
+
# Eager load code on boot. This eager loads most of Rails and
|
10
|
+
# your application in memory, allowing both threaded web servers
|
11
|
+
# and those relying on copy on write to perform better.
|
12
|
+
# Rake tasks automatically ignore this option for performance.
|
13
|
+
config.eager_load = true
|
14
|
+
|
15
|
+
# Full error reports are disabled and caching is turned on.
|
16
|
+
config.consider_all_requests_local = false
|
17
|
+
|
18
|
+
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
|
19
|
+
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
|
20
|
+
# config.require_master_key = true
|
21
|
+
|
22
|
+
# Disable serving static files from the `/public` folder by default since
|
23
|
+
# Apache or NGINX already handles this.
|
24
|
+
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
|
25
|
+
|
26
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
27
|
+
# config.asset_host = "http://assets.example.com"
|
28
|
+
|
29
|
+
# Specifies the header that your server uses for sending files.
|
30
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
|
31
|
+
# config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
|
32
|
+
|
33
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
34
|
+
# config.force_ssl = true
|
35
|
+
|
36
|
+
# Include generic and useful information about system operation, but avoid logging too much
|
37
|
+
# information to avoid inadvertent exposure of personally identifiable information (PII).
|
38
|
+
config.log_level = :info
|
39
|
+
|
40
|
+
# Prepend all log lines with the following tags.
|
41
|
+
config.log_tags = [ :request_id ]
|
42
|
+
|
43
|
+
# Use a different cache store in production.
|
44
|
+
# config.cache_store = :mem_cache_store
|
45
|
+
|
46
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
47
|
+
# the I18n.default_locale when a translation cannot be found).
|
48
|
+
config.i18n.fallbacks = true
|
49
|
+
|
50
|
+
# Don't log any deprecations.
|
51
|
+
config.active_support.report_deprecations = false
|
52
|
+
|
53
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
54
|
+
config.log_formatter = ::Logger::Formatter.new
|
55
|
+
|
56
|
+
# Use a different logger for distributed setups.
|
57
|
+
# require "syslog/logger"
|
58
|
+
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
|
59
|
+
|
60
|
+
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
61
|
+
logger = ActiveSupport::Logger.new(STDOUT)
|
62
|
+
logger.formatter = config.log_formatter
|
63
|
+
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "active_support/core_ext/integer/time"
|
2
|
+
|
3
|
+
# The test environment is used exclusively to run your application's
|
4
|
+
# test suite. You never need to work with it otherwise. Remember that
|
5
|
+
# your test database is "scratch space" for the test suite and is wiped
|
6
|
+
# and recreated between test runs. Don't rely on the data there!
|
7
|
+
|
8
|
+
Rails.application.configure do
|
9
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
10
|
+
|
11
|
+
# Turn false under Spring and add config.action_view.cache_template_loading = true.
|
12
|
+
config.cache_classes = true
|
13
|
+
|
14
|
+
# Eager loading loads your whole application. When running a single test locally,
|
15
|
+
# this probably isn't necessary. It's a good idea to do in a continuous integration
|
16
|
+
# system, or in some way before deploying your code.
|
17
|
+
config.eager_load = ENV["CI"].present?
|
18
|
+
|
19
|
+
# Configure public file server for tests with Cache-Control for performance.
|
20
|
+
config.public_file_server.enabled = true
|
21
|
+
config.public_file_server.headers = {
|
22
|
+
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
|
23
|
+
}
|
24
|
+
|
25
|
+
# Show full error reports and disable caching.
|
26
|
+
config.consider_all_requests_local = true
|
27
|
+
config.action_controller.perform_caching = false
|
28
|
+
config.cache_store = :null_store
|
29
|
+
|
30
|
+
# Raise exceptions instead of rendering exception templates.
|
31
|
+
config.action_dispatch.show_exceptions = false
|
32
|
+
|
33
|
+
# Disable request forgery protection in test environment.
|
34
|
+
config.action_controller.allow_forgery_protection = false
|
35
|
+
|
36
|
+
# Print deprecation notices to the stderr.
|
37
|
+
config.active_support.deprecation = :stderr
|
38
|
+
|
39
|
+
# Raise exceptions for disallowed deprecations.
|
40
|
+
config.active_support.disallowed_deprecation = :raise
|
41
|
+
|
42
|
+
# Tell Active Support which deprecation messages to disallow.
|
43
|
+
config.active_support.disallowed_deprecation_warnings = []
|
44
|
+
|
45
|
+
# Raises error for missing translations.
|
46
|
+
# config.i18n.raise_on_missing_translations = true
|
47
|
+
|
48
|
+
# Annotate rendered view with file names.
|
49
|
+
# config.action_view.annotate_rendered_view_with_filenames = true
|
50
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Avoid CORS issues when API is called from the frontend app.
|
4
|
+
# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests.
|
5
|
+
|
6
|
+
# Read more: https://github.com/cyu/rack-cors
|
7
|
+
|
8
|
+
# Rails.application.config.middleware.insert_before 0, Rack::Cors do
|
9
|
+
# allow do
|
10
|
+
# origins "example.com"
|
11
|
+
#
|
12
|
+
# resource "*",
|
13
|
+
# headers: :any,
|
14
|
+
# methods: [:get, :post, :put, :patch, :delete, :options, :head]
|
15
|
+
# end
|
16
|
+
# end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Configure parameters to be filtered from the log file. Use this to limit dissemination of
|
4
|
+
# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
|
5
|
+
# notations and behaviors.
|
6
|
+
Rails.application.config.filter_parameters += [
|
7
|
+
:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
|
8
|
+
]
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format. Inflections
|
4
|
+
# are locale specific, and you may define rules for as many different
|
5
|
+
# locales as you wish. All of these examples are active by default:
|
6
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
7
|
+
# inflect.plural /^(ox)$/i, "\\1en"
|
8
|
+
# inflect.singular /^(ox)en/i, "\\1"
|
9
|
+
# inflect.irregular "person", "people"
|
10
|
+
# inflect.uncountable %w( fish sheep )
|
11
|
+
# end
|
12
|
+
|
13
|
+
# These inflection rules are supported but not enabled by default:
|
14
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
15
|
+
# inflect.acronym "RESTful"
|
16
|
+
# end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Files in the config/locales directory are used for internationalization
|
2
|
+
# and are automatically loaded by Rails. If you want to use locales other
|
3
|
+
# than English, add the necessary files in this directory.
|
4
|
+
#
|
5
|
+
# To use the locales, use `I18n.t`:
|
6
|
+
#
|
7
|
+
# I18n.t "hello"
|
8
|
+
#
|
9
|
+
# In views, this is aliased to just `t`:
|
10
|
+
#
|
11
|
+
# <%= t("hello") %>
|
12
|
+
#
|
13
|
+
# To use a different locale, set it with `I18n.locale`:
|
14
|
+
#
|
15
|
+
# I18n.locale = :es
|
16
|
+
#
|
17
|
+
# This would use the information in config/locales/es.yml.
|
18
|
+
#
|
19
|
+
# The following keys must be escaped otherwise they will not be retrieved by
|
20
|
+
# the default I18n backend:
|
21
|
+
#
|
22
|
+
# true, false, on, off, yes, no
|
23
|
+
#
|
24
|
+
# Instead, surround them with single quotes.
|
25
|
+
#
|
26
|
+
# en:
|
27
|
+
# "true": "foo"
|
28
|
+
#
|
29
|
+
# To learn more, please read the Rails Internationalization guide
|
30
|
+
# available at https://guides.rubyonrails.org/i18n.html.
|
31
|
+
|
32
|
+
en:
|
33
|
+
hello: "Hello world"
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Puma can serve each request in a thread from an internal thread pool.
|
2
|
+
# The `threads` method setting takes two numbers: a minimum and maximum.
|
3
|
+
# Any libraries that use thread pools should be configured to match
|
4
|
+
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
5
|
+
# and maximum; this matches the default thread size of Active Record.
|
6
|
+
#
|
7
|
+
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
|
8
|
+
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
|
9
|
+
threads min_threads_count, max_threads_count
|
10
|
+
|
11
|
+
# Specifies the `worker_timeout` threshold that Puma will use to wait before
|
12
|
+
# terminating a worker in development environments.
|
13
|
+
#
|
14
|
+
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
|
15
|
+
|
16
|
+
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
|
17
|
+
#
|
18
|
+
port ENV.fetch("PORT") { 3000 }
|
19
|
+
|
20
|
+
# Specifies the `environment` that Puma will run in.
|
21
|
+
#
|
22
|
+
environment ENV.fetch("RAILS_ENV") { "development" }
|
23
|
+
|
24
|
+
# Specifies the `pidfile` that Puma will use.
|
25
|
+
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
|
26
|
+
|
27
|
+
# Specifies the number of `workers` to boot in clustered mode.
|
28
|
+
# Workers are forked web server processes. If using threads and workers together
|
29
|
+
# the concurrency of the application would be max `threads` * `workers`.
|
30
|
+
# Workers do not work on JRuby or Windows (both of which do not support
|
31
|
+
# processes).
|
32
|
+
#
|
33
|
+
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
|
34
|
+
|
35
|
+
# Use the `preload_app!` method when specifying a `workers` number.
|
36
|
+
# This directive tells Puma to first boot the application and load code
|
37
|
+
# before forking the application. This takes advantage of Copy On Write
|
38
|
+
# process behavior so workers use less memory.
|
39
|
+
#
|
40
|
+
# preload_app!
|
41
|
+
|
42
|
+
# Allow puma to be restarted by `bin/rails restart` command.
|
43
|
+
plugin :tmp_restart
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
require 'spec_helper'
|
3
|
+
ENV['RAILS_ENV'] ||= 'test'
|
4
|
+
# require_relative '../config/environment'
|
5
|
+
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
6
|
+
Dir[Rails.root.join('../support/**/*.rb')].each { |f| require f }
|
7
|
+
|
8
|
+
# Prevent database truncation if the environment is production
|
9
|
+
abort("The Rails environment is running in production mode!") if Rails.env.production?
|
10
|
+
require 'rspec/rails'
|
11
|
+
# Add additional requires below this line. Rails is not loaded until this point!
|
12
|
+
|
13
|
+
# Requires supporting ruby files with custom matchers and macros, etc, in
|
14
|
+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
15
|
+
# run as spec files by default. This means that files in spec/support that end
|
16
|
+
# in _spec.rb will both be required and run as specs, causing the specs to be
|
17
|
+
# run twice. It is recommended that you do not name files matching this glob to
|
18
|
+
# end with _spec.rb. You can configure this pattern with the --pattern
|
19
|
+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
20
|
+
#
|
21
|
+
# The following line is provided for convenience purposes. It has the downside
|
22
|
+
# of increasing the boot-up time by auto-requiring all files in the support
|
23
|
+
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
24
|
+
# require only the support files necessary.
|
25
|
+
#
|
26
|
+
# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }
|
27
|
+
|
28
|
+
RSpec.configure do |config|
|
29
|
+
# Remove this line to enable support for ActiveRecord
|
30
|
+
config.use_active_record = false
|
31
|
+
|
32
|
+
# If you enable ActiveRecord support you should uncomment these lines,
|
33
|
+
# note if you'd prefer not to run each example within a transaction, you
|
34
|
+
# should set use_transactional_fixtures to false.
|
35
|
+
#
|
36
|
+
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
37
|
+
# config.use_transactional_fixtures = true
|
38
|
+
|
39
|
+
# RSpec Rails can automatically mix in different behaviours to your tests
|
40
|
+
# based on their file location, for example enabling you to call `get` and
|
41
|
+
# `post` in specs under `spec/controllers`.
|
42
|
+
#
|
43
|
+
# You can disable this behaviour by removing the line below, and instead
|
44
|
+
# explicitly tag your specs with their type, e.g.:
|
45
|
+
#
|
46
|
+
# RSpec.describe UsersController, type: :controller do
|
47
|
+
# # ...
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# The different available types are documented in the features, such as in
|
51
|
+
# https://relishapp.com/rspec/rspec-rails/docs
|
52
|
+
config.infer_spec_type_from_file_location!
|
53
|
+
|
54
|
+
# Filter lines from Rails gems in backtraces.
|
55
|
+
config.filter_rails_from_backtrace!
|
56
|
+
# arbitrary gems may also be filtered via:
|
57
|
+
# config.filter_gems_from_backtrace("gem name")
|
58
|
+
|
59
|
+
config.include RequestSpecHelper, type: :request
|
60
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe "Statics", type: :request do
|
4
|
+
describe "GET /healthz" do
|
5
|
+
it "returns http success" do
|
6
|
+
get "/micro_api/healthz"
|
7
|
+
expect(response).to have_http_status(:success)
|
8
|
+
expect(response.header['Content-Type']).to include 'application/json'
|
9
|
+
expect(json).not_to be_empty
|
10
|
+
expect(json).to have_key('status')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "GET /version" do
|
15
|
+
it "returns http success" do
|
16
|
+
get "/micro_api/version"
|
17
|
+
expect(response).to have_http_status(:success)
|
18
|
+
expect(response.header['Content-Type']).to include 'application/json'
|
19
|
+
expect(json).not_to be_empty
|
20
|
+
expect(json).to have_key('env')
|
21
|
+
expect(json).to have_key('cenv')
|
22
|
+
expect(json).to have_key('itag')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
14
|
+
|
15
|
+
require 'simplecov'
|
16
|
+
SimpleCov.start
|
17
|
+
|
18
|
+
# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
19
|
+
RSpec.configure do |config|
|
20
|
+
# rspec-expectations config goes here. You can use an alternate
|
21
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
22
|
+
# assertions if you prefer.
|
23
|
+
config.expect_with :rspec do |expectations|
|
24
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
25
|
+
# and `failure_message` of custom matchers include text for helper methods
|
26
|
+
# defined using `chain`, e.g.:
|
27
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
28
|
+
# # => "be bigger than 2 and smaller than 4"
|
29
|
+
# ...rather than:
|
30
|
+
# # => "be bigger than 2"
|
31
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
32
|
+
end
|
33
|
+
|
34
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
35
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
36
|
+
config.mock_with :rspec do |mocks|
|
37
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
38
|
+
# a real object. This is generally recommended, and will default to
|
39
|
+
# `true` in RSpec 4.
|
40
|
+
mocks.verify_partial_doubles = true
|
41
|
+
end
|
42
|
+
|
43
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
44
|
+
# have no way to turn it off -- the option exists only for backwards
|
45
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
46
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
47
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
48
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
49
|
+
|
50
|
+
# The settings below are suggested to provide a good initial experience
|
51
|
+
# with RSpec, but feel free to customize to your heart's content.
|
52
|
+
=begin
|
53
|
+
# This allows you to limit a spec run to individual examples or groups
|
54
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
55
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
56
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
57
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
58
|
+
config.filter_run_when_matching :focus
|
59
|
+
|
60
|
+
# Allows RSpec to persist some state between runs in order to support
|
61
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
62
|
+
# you configure your source control system to ignore this file.
|
63
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
64
|
+
|
65
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
66
|
+
# recommended. For more details, see:
|
67
|
+
# https://relishapp.com/rspec/rspec-core/docs/configuration/zero-monkey-patching-mode
|
68
|
+
config.disable_monkey_patching!
|
69
|
+
|
70
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
71
|
+
# file, and it's useful to allow more verbose output when running an
|
72
|
+
# individual spec file.
|
73
|
+
if config.files_to_run.one?
|
74
|
+
# Use the documentation formatter for detailed output,
|
75
|
+
# unless a formatter has already been configured
|
76
|
+
# (e.g. via a command-line flag).
|
77
|
+
config.default_formatter = "doc"
|
78
|
+
end
|
79
|
+
|
80
|
+
# Print the 10 slowest examples and example groups at the
|
81
|
+
# end of the spec run, to help surface which specs are running
|
82
|
+
# particularly slow.
|
83
|
+
config.profile_examples = 10
|
84
|
+
|
85
|
+
# Run specs in random order to surface order dependencies. If you find an
|
86
|
+
# order dependency and want to debug it, you can fix the order by providing
|
87
|
+
# the seed, which is printed after each run.
|
88
|
+
# --seed 1234
|
89
|
+
config.order = :random
|
90
|
+
|
91
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
92
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
93
|
+
# test failures related to randomization by passing the same `--seed` value
|
94
|
+
# as the one that triggered the failure.
|
95
|
+
Kernel.srand config.seed
|
96
|
+
=end
|
97
|
+
end
|
metadata
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: micro_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ''
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-03-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec-rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubocop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: simplecov
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 7.0.4.3
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 7.0.4.3
|
69
|
+
description: Rails engine plugin that would like to help the startup of rails applications
|
70
|
+
oriented to microservices or, in general, to the cloud.
|
71
|
+
email:
|
72
|
+
- ''
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- MIT-LICENSE
|
78
|
+
- README.md
|
79
|
+
- Rakefile
|
80
|
+
- app/controllers/micro_api/application_controller.rb
|
81
|
+
- app/controllers/micro_api/static_controller.rb
|
82
|
+
- app/models/micro_api/application_record.rb
|
83
|
+
- config/routes.rb
|
84
|
+
- lib/micro_api.rb
|
85
|
+
- lib/micro_api/engine.rb
|
86
|
+
- lib/micro_api/version.rb
|
87
|
+
- lib/tasks/micro_api_tasks.rake
|
88
|
+
- spec/dummy/Rakefile
|
89
|
+
- spec/dummy/app/controllers/application_controller.rb
|
90
|
+
- spec/dummy/bin/rails
|
91
|
+
- spec/dummy/bin/rake
|
92
|
+
- spec/dummy/bin/setup
|
93
|
+
- spec/dummy/config.ru
|
94
|
+
- spec/dummy/config/application.rb
|
95
|
+
- spec/dummy/config/boot.rb
|
96
|
+
- spec/dummy/config/environment.rb
|
97
|
+
- spec/dummy/config/environments/development.rb
|
98
|
+
- spec/dummy/config/environments/production.rb
|
99
|
+
- spec/dummy/config/environments/test.rb
|
100
|
+
- spec/dummy/config/initializers/cors.rb
|
101
|
+
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
102
|
+
- spec/dummy/config/initializers/inflections.rb
|
103
|
+
- spec/dummy/config/locales/en.yml
|
104
|
+
- spec/dummy/config/puma.rb
|
105
|
+
- spec/dummy/config/routes.rb
|
106
|
+
- spec/rails_helper.rb
|
107
|
+
- spec/requests/micro_api/static_spec.rb
|
108
|
+
- spec/spec_helper.rb
|
109
|
+
- spec/support/request_spec_helper.rb
|
110
|
+
homepage: https://github.com/lelered/micro_api
|
111
|
+
licenses:
|
112
|
+
- MIT
|
113
|
+
metadata:
|
114
|
+
allowed_push_host: https://rubygems.org
|
115
|
+
homepage_uri: https://github.com/lelered/micro_api
|
116
|
+
source_code_uri: https://github.com/lelered/micro_api
|
117
|
+
changelog_uri: https://github.com/lelered/micro_api/blob/main/CHANGELOG.md
|
118
|
+
post_install_message:
|
119
|
+
rdoc_options: []
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
requirements: []
|
133
|
+
rubygems_version: 3.4.6
|
134
|
+
signing_key:
|
135
|
+
specification_version: 4
|
136
|
+
summary: Engine plugin for Ruby on Rails applications
|
137
|
+
test_files:
|
138
|
+
- spec/dummy/Rakefile
|
139
|
+
- spec/dummy/app/controllers/application_controller.rb
|
140
|
+
- spec/dummy/bin/rails
|
141
|
+
- spec/dummy/bin/rake
|
142
|
+
- spec/dummy/bin/setup
|
143
|
+
- spec/dummy/config/application.rb
|
144
|
+
- spec/dummy/config/boot.rb
|
145
|
+
- spec/dummy/config/environment.rb
|
146
|
+
- spec/dummy/config/environments/development.rb
|
147
|
+
- spec/dummy/config/environments/production.rb
|
148
|
+
- spec/dummy/config/environments/test.rb
|
149
|
+
- spec/dummy/config/initializers/cors.rb
|
150
|
+
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
151
|
+
- spec/dummy/config/initializers/inflections.rb
|
152
|
+
- spec/dummy/config/locales/en.yml
|
153
|
+
- spec/dummy/config/puma.rb
|
154
|
+
- spec/dummy/config/routes.rb
|
155
|
+
- spec/dummy/config.ru
|
156
|
+
- spec/rails_helper.rb
|
157
|
+
- spec/requests/micro_api/static_spec.rb
|
158
|
+
- spec/spec_helper.rb
|
159
|
+
- spec/support/request_spec_helper.rb
|