schemaless_rest_api 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/schemaless_rest_api/entities.rb +3 -0
- data/lib/schemaless_rest_api/mongo_client.rb +1 -0
- data/lib/schemaless_rest_api/rest_server.rb +5 -1
- data/lib/schemaless_rest_api/swagger_builder.rb +3 -3
- data/lib/schemaless_rest_api/version.rb +1 -1
- data/lib/schemaless_rest_api.rb +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f42e7bccaab28e6dc750c4351e18500689d1fb13a72bda6d0f1417cc5cef630
|
4
|
+
data.tar.gz: d47a29830a56c986c04bdc92c0c07758efcbe197de71a0183552af628ee66dc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 366cd2cf898fc3cca3ba5b90d29d44fa08e43b5a0a8154eec309c21d9a7012a8c2498912818f2251e664bf2568bfdbcead72ac59e6d837f6a844fd43b64b2a07
|
7
|
+
data.tar.gz: 65cfacda5630298c9e50165b3a2a5420ecf6965347f32f92226afcb6137716207732377714d9b59d7bdda228e5aacc6f23adb39a97ea0be062bc269804b61568
|
@@ -3,6 +3,8 @@
|
|
3
3
|
require "sinatra"
|
4
4
|
require "puma"
|
5
5
|
require "route_downcaser"
|
6
|
+
require "prometheus/middleware/collector"
|
7
|
+
require "prometheus/middleware/exporter"
|
6
8
|
require_relative "server_utils"
|
7
9
|
|
8
10
|
# Server with endpoints generated based on Entities with CRUD operations for them
|
@@ -11,6 +13,8 @@ class RestServer < Sinatra::Base
|
|
11
13
|
enable :logging if ENV["debug"] == "true"
|
12
14
|
set :bind, "0.0.0.0"
|
13
15
|
use RouteDowncaser::DowncaseRouteMiddleware
|
16
|
+
use Prometheus::Middleware::Collector
|
17
|
+
use Prometheus::Middleware::Exporter
|
14
18
|
helpers ServerUtils
|
15
19
|
|
16
20
|
before do
|
@@ -60,7 +64,7 @@ class RestServer < Sinatra::Base
|
|
60
64
|
|
61
65
|
get "/" do
|
62
66
|
summary = { models: Entities.models.keys.to_s,
|
63
|
-
docs_url: "<a href
|
67
|
+
docs_url: "<a href='#{ENV["base_path"]}/swagger'>Swagger docs</a>" }
|
64
68
|
summary[:db] = MongoClient.client.summary.to_s if ENV["mongodb"]
|
65
69
|
JSON.generate(summary)
|
66
70
|
rescue StandardError => e
|
@@ -13,7 +13,7 @@ class SwaggerBuilder
|
|
13
13
|
doc["info"] = build_info(models)
|
14
14
|
doc["host"] = host_with_port
|
15
15
|
doc["schemes"] = "http"
|
16
|
-
doc["basePath"] = "
|
16
|
+
doc["basePath"] = "/#{ENV["base_path"]}"
|
17
17
|
doc["paths"] = generate_paths_for models
|
18
18
|
JSON.generate(doc)
|
19
19
|
end
|
@@ -57,7 +57,7 @@ class SwaggerBuilder
|
|
57
57
|
}
|
58
58
|
},
|
59
59
|
get: {
|
60
|
-
parameters: [
|
60
|
+
parameters: [
|
61
61
|
{
|
62
62
|
name: "params",
|
63
63
|
description: "Any key can be used to filter #{model} by",
|
@@ -94,7 +94,7 @@ class SwaggerBuilder
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def paths_at_id(model)
|
97
|
-
{
|
97
|
+
{
|
98
98
|
get: {
|
99
99
|
description: "Data of #{model} at passed id",
|
100
100
|
parameters: id_params(model),
|
data/lib/schemaless_rest_api.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schemaless_rest_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Garratt
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongo
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: prometheus-client
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: puma
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|