souls 0.24.2 → 0.24.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. checksums.yaml +4 -4
  2. data/lib/souls/version.rb +1 -1
  3. metadata +2 -191
  4. data/.gitignore +0 -15
  5. data/.irbrc +0 -3
  6. data/.rspec +0 -3
  7. data/.rubocop.yml +0 -152
  8. data/.ruby-version +0 -1
  9. data/.travis.yml +0 -6
  10. data/Gemfile +0 -13
  11. data/Gemfile.lock +0 -98
  12. data/Rakefile +0 -23
  13. data/Steepfile +0 -8
  14. data/apps/api/.env.sample +0 -7
  15. data/apps/api/.gitignore +0 -32
  16. data/apps/api/.irbrc +0 -4
  17. data/apps/api/.rspec +0 -3
  18. data/apps/api/.rubocop.yml +0 -132
  19. data/apps/api/.ruby-version +0 -1
  20. data/apps/api/CODE_OF_CONDUCT.md +0 -74
  21. data/apps/api/Dockerfile +0 -16
  22. data/apps/api/Dockerfile.dev +0 -17
  23. data/apps/api/Gemfile +0 -50
  24. data/apps/api/Gemfile.lock +0 -412
  25. data/apps/api/LICENSE.txt +0 -67
  26. data/apps/api/Procfile +0 -2
  27. data/apps/api/Procfile.dev +0 -2
  28. data/apps/api/README.md +0 -37
  29. data/apps/api/Rakefile +0 -5
  30. data/apps/api/app.rb +0 -114
  31. data/apps/api/app/engines/notification_engine.rb +0 -5
  32. data/apps/api/app/graphql/mutations/.keep +0 -0
  33. data/apps/api/app/graphql/mutations/base/article/create_article.rb +0 -30
  34. data/apps/api/app/graphql/mutations/base/article/delete_article.rb +0 -17
  35. data/apps/api/app/graphql/mutations/base/article/destroy_delete_article.rb +0 -17
  36. data/apps/api/app/graphql/mutations/base/article/update_article.rb +0 -30
  37. data/apps/api/app/graphql/mutations/base/article_category/create_article_category.rb +0 -21
  38. data/apps/api/app/graphql/mutations/base/article_category/delete_article_category.rb +0 -17
  39. data/apps/api/app/graphql/mutations/base/article_category/destroy_delete_article_category.rb +0 -17
  40. data/apps/api/app/graphql/mutations/base/article_category/update_article_category.rb +0 -21
  41. data/apps/api/app/graphql/mutations/base/user/create_user.rb +0 -31
  42. data/apps/api/app/graphql/mutations/base/user/delete_user.rb +0 -17
  43. data/apps/api/app/graphql/mutations/base/user/destroy_delete_user.rb +0 -17
  44. data/apps/api/app/graphql/mutations/base/user/update_user.rb +0 -31
  45. data/apps/api/app/graphql/mutations/base_mutation.rb +0 -65
  46. data/apps/api/app/graphql/mutations/managers/user_manager/add_user_role.rb +0 -22
  47. data/apps/api/app/graphql/mutations/managers/user_manager/remove_user_role.rb +0 -22
  48. data/apps/api/app/graphql/mutations/managers/user_manager/sign_in_user.rb +0 -45
  49. data/apps/api/app/graphql/queries/article.rb +0 -13
  50. data/apps/api/app/graphql/queries/article_categories.rb +0 -11
  51. data/apps/api/app/graphql/queries/article_category.rb +0 -13
  52. data/apps/api/app/graphql/queries/articles.rb +0 -11
  53. data/apps/api/app/graphql/queries/base_query.rb +0 -12
  54. data/apps/api/app/graphql/queries/me.rb +0 -11
  55. data/apps/api/app/graphql/queries/user.rb +0 -13
  56. data/apps/api/app/graphql/queries/users.rb +0 -11
  57. data/apps/api/app/graphql/resolvers/article_category_search.rb +0 -41
  58. data/apps/api/app/graphql/resolvers/article_search.rb +0 -57
  59. data/apps/api/app/graphql/resolvers/base.rb +0 -17
  60. data/apps/api/app/graphql/resolvers/user_search.rb +0 -63
  61. data/apps/api/app/graphql/souls_api_schema.rb +0 -43
  62. data/apps/api/app/graphql/types/.keep +0 -0
  63. data/apps/api/app/graphql/types/article_category_type.rb +0 -12
  64. data/apps/api/app/graphql/types/article_type.rb +0 -30
  65. data/apps/api/app/graphql/types/base/base_argument.rb +0 -4
  66. data/apps/api/app/graphql/types/base/base_enum.rb +0 -4
  67. data/apps/api/app/graphql/types/base/base_field.rb +0 -5
  68. data/apps/api/app/graphql/types/base/base_input_object.rb +0 -5
  69. data/apps/api/app/graphql/types/base/base_interface.rb +0 -7
  70. data/apps/api/app/graphql/types/base/base_object.rb +0 -6
  71. data/apps/api/app/graphql/types/base/base_scalar.rb +0 -4
  72. data/apps/api/app/graphql/types/base/base_union.rb +0 -4
  73. data/apps/api/app/graphql/types/base/mutation_type.rb +0 -26
  74. data/apps/api/app/graphql/types/base/query_type.rb +0 -18
  75. data/apps/api/app/graphql/types/connections/article_category_connection.rb +0 -3
  76. data/apps/api/app/graphql/types/connections/article_connection.rb +0 -3
  77. data/apps/api/app/graphql/types/connections/base_connection.rb +0 -14
  78. data/apps/api/app/graphql/types/connections/user_connection.rb +0 -3
  79. data/apps/api/app/graphql/types/edges/article_category_edge.rb +0 -5
  80. data/apps/api/app/graphql/types/edges/article_edge.rb +0 -5
  81. data/apps/api/app/graphql/types/edges/base_edge.rb +0 -4
  82. data/apps/api/app/graphql/types/edges/user_edge.rb +0 -5
  83. data/apps/api/app/graphql/types/user_type.rb +0 -24
  84. data/apps/api/app/models/article.rb +0 -4
  85. data/apps/api/app/models/article_category.rb +0 -3
  86. data/apps/api/app/models/user.rb +0 -19
  87. data/apps/api/app/policies/application_policy.rb +0 -40
  88. data/apps/api/app/policies/article_category_policy.rb +0 -31
  89. data/apps/api/app/policies/article_policy.rb +0 -31
  90. data/apps/api/app/policies/user_policy.rb +0 -35
  91. data/apps/api/app/utils/association_loader.rb +0 -50
  92. data/apps/api/app/utils/fire_store.rb +0 -9
  93. data/apps/api/app/utils/firebase_id_token.rb +0 -4
  94. data/apps/api/app/utils/json_web_token.rb +0 -13
  95. data/apps/api/app/utils/record_loader.rb +0 -10
  96. data/apps/api/app/utils/souls_helper.rb +0 -18
  97. data/apps/api/cloudbuild.yml +0 -32
  98. data/apps/api/config.ru +0 -17
  99. data/apps/api/config/database.yml +0 -33
  100. data/apps/api/config/souls.rb +0 -10
  101. data/apps/api/constants/areas.rb +0 -71
  102. data/apps/api/constants/column_name_ja.rb +0 -27
  103. data/apps/api/db/migrate/20200006095538_create_users.rb +0 -30
  104. data/apps/api/db/migrate/20200712180236_create_article_categories.rb +0 -12
  105. data/apps/api/db/migrate/20200714215521_create_articles.rb +0 -22
  106. data/apps/api/db/schema.rb +0 -78
  107. data/apps/api/db/seeds.rb +0 -44
  108. data/apps/api/github/workflows/delivery.yml +0 -81
  109. data/apps/api/log/.keep +0 -0
  110. data/apps/api/spec/factories/article_categories.rb +0 -9
  111. data/apps/api/spec/factories/articles.rb +0 -17
  112. data/apps/api/spec/factories/users.rb +0 -23
  113. data/apps/api/spec/models/article_category_spec.rb +0 -7
  114. data/apps/api/spec/models/article_spec.rb +0 -7
  115. data/apps/api/spec/models/user_spec.rb +0 -7
  116. data/apps/api/spec/mutations/base/article_category_spec.rb +0 -46
  117. data/apps/api/spec/mutations/base/article_spec.rb +0 -70
  118. data/apps/api/spec/mutations/base/user_spec.rb +0 -76
  119. data/apps/api/spec/policies/article_category_policy_spec.rb +0 -24
  120. data/apps/api/spec/policies/article_policy_spec.rb +0 -24
  121. data/apps/api/spec/policies/user_policy_spec.rb +0 -24
  122. data/apps/api/spec/queries/article_category_spec.rb +0 -39
  123. data/apps/api/spec/queries/article_spec.rb +0 -53
  124. data/apps/api/spec/queries/user_spec.rb +0 -59
  125. data/apps/api/spec/resolvers/article_category_search_spec.rb +0 -54
  126. data/apps/api/spec/resolvers/article_search_spec.rb +0 -68
  127. data/apps/api/spec/resolvers/user_search_spec.rb +0 -74
  128. data/apps/api/spec/spec_helper.rb +0 -110
  129. data/apps/api/tmp/.keep +0 -0
  130. data/apps/worker/.env.sample +0 -9
  131. data/apps/worker/.gitignore +0 -32
  132. data/apps/worker/.irbrc +0 -4
  133. data/apps/worker/.rspec +0 -3
  134. data/apps/worker/.rubocop.yml +0 -132
  135. data/apps/worker/.ruby-version +0 -1
  136. data/apps/worker/CODE_OF_CONDUCT.md +0 -74
  137. data/apps/worker/Dockerfile +0 -16
  138. data/apps/worker/Dockerfile.dev +0 -17
  139. data/apps/worker/Gemfile +0 -49
  140. data/apps/worker/Gemfile.lock +0 -396
  141. data/apps/worker/LICENSE.txt +0 -67
  142. data/apps/worker/Procfile +0 -1
  143. data/apps/worker/Procfile.dev +0 -1
  144. data/apps/worker/README.md +0 -37
  145. data/apps/worker/Rakefile +0 -5
  146. data/apps/worker/app.rb +0 -101
  147. data/apps/worker/app/engines/notification_engine.rb +0 -5
  148. data/apps/worker/app/graphql/mutations/.keep +0 -0
  149. data/apps/worker/app/graphql/mutations/base_mutation.rb +0 -16
  150. data/apps/worker/app/graphql/mutations/workers/send_user_mail_job.rb +0 -31
  151. data/apps/worker/app/graphql/souls_api_schema.rb +0 -43
  152. data/apps/worker/app/graphql/types/.keep +0 -0
  153. data/apps/worker/app/graphql/types/base/base_argument.rb +0 -4
  154. data/apps/worker/app/graphql/types/base/base_enum.rb +0 -4
  155. data/apps/worker/app/graphql/types/base/base_field.rb +0 -5
  156. data/apps/worker/app/graphql/types/base/base_input_object.rb +0 -5
  157. data/apps/worker/app/graphql/types/base/base_interface.rb +0 -7
  158. data/apps/worker/app/graphql/types/base/base_object.rb +0 -5
  159. data/apps/worker/app/graphql/types/base/base_scalar.rb +0 -4
  160. data/apps/worker/app/graphql/types/base/base_union.rb +0 -4
  161. data/apps/worker/app/graphql/types/base/mutation_type.rb +0 -12
  162. data/apps/worker/app/graphql/types/base/query_type.rb +0 -6
  163. data/apps/worker/app/models/article.rb +0 -4
  164. data/apps/worker/app/models/article_category.rb +0 -3
  165. data/apps/worker/app/models/user.rb +0 -19
  166. data/apps/worker/app/utils/fire_store.rb +0 -9
  167. data/apps/worker/app/utils/souls_helper.rb +0 -96
  168. data/apps/worker/cloudbuild.yml +0 -32
  169. data/apps/worker/config.ru +0 -17
  170. data/apps/worker/config/database.yml +0 -33
  171. data/apps/worker/config/souls.rb +0 -10
  172. data/apps/worker/db/migrate/20200006095538_create_users.rb +0 -30
  173. data/apps/worker/db/migrate/20200712180236_create_article_categories.rb +0 -12
  174. data/apps/worker/db/migrate/20200714215521_create_articles.rb +0 -22
  175. data/apps/worker/db/schema.rb +0 -78
  176. data/apps/worker/db/seeds.rb +0 -44
  177. data/apps/worker/github/workflows/delivery.yml +0 -81
  178. data/apps/worker/log/.keep +0 -0
  179. data/apps/worker/spec/factories/article_categories.rb +0 -9
  180. data/apps/worker/spec/factories/articles.rb +0 -17
  181. data/apps/worker/spec/factories/users.rb +0 -23
  182. data/apps/worker/spec/models/article_category_spec.rb +0 -7
  183. data/apps/worker/spec/models/article_spec.rb +0 -7
  184. data/apps/worker/spec/models/user_spec.rb +0 -7
  185. data/apps/worker/spec/spec_helper.rb +0 -110
  186. data/apps/worker/tmp/.keep +0 -0
  187. data/bin/console +0 -14
  188. data/bin/setup +0 -8
  189. data/config/souls.rb +0 -9
  190. data/db/schema.rb +0 -67
  191. data/rbs/init.rbs +0 -2
  192. data/souls.gemspec +0 -34
@@ -1,67 +0,0 @@
1
- Apache License
2
-
3
- Version 2.0, January 2004
4
-
5
- http://www.apache.org/licenses/
6
-
7
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
-
9
- 1. Definitions.
10
-
11
- "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
12
-
13
- "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
16
-
17
- "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
18
-
19
- "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
20
-
21
- "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
22
-
23
- "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
24
-
25
- "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
26
-
27
- "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
28
-
29
- "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
30
-
31
- 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
32
-
33
- 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
34
-
35
- 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
36
-
37
- You must give any other recipients of the Work or Derivative Works a copy of this License; and
38
- You must cause any modified files to carry prominent notices stating that You changed the files; and
39
- You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
40
- If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
41
-
42
- You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
43
- 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
44
-
45
- 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
46
-
47
- 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
48
-
49
- 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
50
-
51
- 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
52
-
53
- END OF TERMS AND CONDITIONS
54
-
55
- Copyright 2021 ELSOUL LABO B.V.
56
-
57
- Licensed under the Apache License, Version 2.0 (the "License");
58
- you may not use this file except in compliance with the License.
59
- You may obtain a copy of the License at
60
-
61
- http://www.apache.org/licenses/LICENSE-2.0
62
-
63
- Unless required by applicable law or agreed to in writing, software
64
- distributed under the License is distributed on an "AS IS" BASIS,
65
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
66
- See the License for the specific language governing permissions and
67
- limitations under the License.
data/apps/worker/Procfile DELETED
@@ -1 +0,0 @@
1
- web: bundle exec puma -p $PORT -e production
@@ -1 +0,0 @@
1
- web: bundle exec puma -p 3000 -e development
@@ -1,37 +0,0 @@
1
- # SOULs Serverless Pub/Sub Worker Boilerplate
2
- SOULs Serverless Pub/Sub Worker Boilerplate
3
-
4
- <p align="center">
5
-
6
- <a aria-label="Ruby logo" href="https://el-soul.com">
7
- <img src="https://badgen.net/badge/icon/Made%20by%20ELSOUL?icon=ruby&label&color=black&labelColor=black">
8
- </a>
9
- <br/>
10
- </p>
11
-
12
-
13
- ## SOULs Document
14
-
15
- - [SOULs Document](https://souls.elsoul.nl/)
16
-
17
-
18
-
19
-
20
-
21
- ## Development
22
-
23
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
-
25
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org/gems/souls).
26
-
27
- ## Contributing
28
-
29
- Bug reports and pull requests are welcome on GitHub at https://github.com/elsoul/souls_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
30
-
31
- ## License
32
-
33
- The gem is available as open source under the terms of the [Apache-2.0 License](https://www.apache.org/licenses/LICENSE-2.0).
34
-
35
- ## Code of Conduct
36
-
37
- Everyone interacting in the HotelPrice project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/elsoul/souls/blob/master/CODE_OF_CONDUCT.md).
data/apps/worker/Rakefile DELETED
@@ -1,5 +0,0 @@
1
- require "./app"
2
- require "sinatra/activerecord/rake"
3
- require "graphql/rake_task"
4
-
5
- GraphQL::RakeTask.new(schema_name: "SoulsApiSchema")
data/apps/worker/app.rb DELETED
@@ -1,101 +0,0 @@
1
- require "active_support"
2
- require "active_support/core_ext"
3
- require "erb"
4
- require "csv"
5
- require "jwt"
6
- require "json"
7
- require "sinatra"
8
- require "sinatra/base"
9
- require "sinatra/json"
10
- require "sinatra/activerecord"
11
- require "rack/contrib"
12
- require "zeitwerk"
13
- require "factory_bot"
14
- require "faker"
15
- require "dotenv/load"
16
- require "graphql"
17
- require "google/cloud/firestore"
18
- require "google/cloud/storage"
19
- require "google/cloud/pubsub"
20
- require "logger"
21
- require "base64"
22
- require "slack/ruby3"
23
- require "role_model"
24
- require "pundit"
25
- require "sendgrid-ruby"
26
- require "search_object"
27
- require "search_object/plugin/graphql"
28
- require "graphql/batch"
29
-
30
- ENV["RACK_ENV"] ||= "development"
31
- Dir["./config/*.rb"].each { |f| require f unless f.include?("souls.rb") }
32
- Dir["./constants/*.rb"].each { |f| require f }
33
-
34
- db_conf = YAML.safe_load(ERB.new(File.read("./config/database.yml")).result, permitted_classes: [Date], aliases: true)
35
- ActiveRecord::Base.establish_connection(db_conf[ENV["RACK_ENV"]])
36
- ActiveRecord::Base.default_timezone = :local
37
-
38
- loader = Zeitwerk::Loader.new
39
- loader.push_dir("#{Dir.pwd}/app/models")
40
- loader.push_dir("#{Dir.pwd}/app/utils")
41
- loader.push_dir("#{Dir.pwd}/app/engines")
42
-
43
- loader.collapse("#{__dir__}/app/types")
44
- loader.collapse("#{__dir__}/app/mutations")
45
- loader.collapse("#{__dir__}/app/graphql/types/base")
46
- loader.push_dir("#{Dir.pwd}/app/graphql")
47
- loader.setup
48
-
49
- class SoulsApi < Sinatra::Base
50
- include Pundit
51
- include SoulsHelper
52
- ::Logger.class_eval { alias_method :write, :<< }
53
- access_log = ::File.join(::File.dirname(::File.expand_path(__FILE__)), "log", "access.log")
54
- access_logger = ::Logger.new(access_log)
55
- error_logger = ::File.new(::File.join(::File.dirname(::File.expand_path(__FILE__)), "log", "error.log"), "a+")
56
- error_logger.sync = true
57
-
58
- use Rack::JSONBodyParser
59
- register Sinatra::ActiveRecordExtension
60
-
61
- configure :production, :development do
62
- set :logger, Logger.new($stdout)
63
- enable :logging
64
- use ::Rack::CommonLogger, access_logger
65
- end
66
-
67
- before { env["rack.errors"] = error_logger }
68
-
69
- error StandardError do
70
- StandardError.to_json
71
- end
72
-
73
- get "/" do
74
- message = { success: true, message: "SOULs Running!", env: ENV["RACK_ENV"] }
75
- json message
76
- end
77
-
78
- get "/db" do
79
- message = { success: true, message: "SOULs Running!", env: ENV["RACK_ENV"], db: User.first.username }
80
- json(message)
81
- rescue StandardError => e
82
- message = { error: e }
83
- json(message)
84
- end
85
-
86
- post "/endpoint" do
87
- query =
88
- if ENV["RACK_ENV"] == "production"
89
- Base64.decode64(params["message"]["data"]).force_encoding("UTF-8")
90
- else
91
- params[:query]
92
- end
93
-
94
- result = SoulsApiSchema.execute(query.to_s)
95
- json(result)
96
- rescue StandardError => e
97
- NotificationEngine.send_slack_error(e.backtrace)
98
- message = { error: e.backtrace }
99
- json(message)
100
- end
101
- end
@@ -1,5 +0,0 @@
1
- module NotificationEngine
2
- def self.send_slack_error(message = "hoi!")
3
- Slack::Ruby3.push(webhook_url: ENV["SLACK"], message: message)
4
- end
5
- end
File without changes
@@ -1,16 +0,0 @@
1
- module Mutations
2
- class BaseMutation < GraphQL::Schema::RelayClassicMutation
3
- argument_class Types::BaseArgument
4
- field_class Types::BaseField
5
- input_object_class Types::BaseInputObject
6
- object_class Types::BaseObject
7
-
8
- def production?
9
- ENV["RACK_ENV"] == "production"
10
- end
11
-
12
- def get_instance_id
13
- `curl http://metadata.google.internal/computeMetadata/v1/instance/id -H Metadata-Flavor:Google`
14
- end
15
- end
16
- end
@@ -1,31 +0,0 @@
1
- module Mutations
2
- module Workers
3
- class SendUserMailJob < BaseMutation
4
- description "Mail を送信します。"
5
- field :response, String, null: false
6
-
7
- argument :text, String, required: true
8
- argument :user_id, Integer, required: true
9
-
10
- def resolve(args)
11
- user = ::User.find(args[:user_id])
12
- html = ::ERB.new(" #{user.username} 様<br> #{args[:text]} ")
13
- mail = ::SendGrid::Mail.new
14
- to_email = user.email
15
- mail.from = ::SendGrid::Email.new(email: "no-reply@yourmail.com")
16
- mail.subject = "申込みありがとうございます☻"
17
- personalization = ::SendGrid::Personalization.new
18
- personalization.add_to(::SendGrid::Email.new(email: to_email, name: "申込者"))
19
- personalization.add_bcc(::SendGrid::Email.new(email: ENV["ADMIN_EMAIL"], name: "管理者"))
20
- mail.add_personalization(personalization)
21
- mail.add_content(::SendGrid::Content.new(type: "text/html", value: html.result))
22
- sg = ::SendGrid::API.new(api_key: ENV["SENDGRID"] || "")
23
- response = sg.client.mail._("send").post(request_body: mail.to_json)
24
- response.status_code
25
- { response: "Job done!" }
26
- rescue StandardError => e
27
- GraphQL::ExecutionError.new(e.to_s)
28
- end
29
- end
30
- end
31
- end
@@ -1,43 +0,0 @@
1
- class SoulsApiSchema < GraphQL::Schema
2
- default_max_page_size 100
3
- mutation(Types::MutationType)
4
- query(Types::QueryType)
5
- use GraphQL::Batch
6
-
7
- def self.id_from_object(object, _type_definition, _query_ctx)
8
- # Call your application"s UUID method here
9
- # It should return a string
10
- to_global_id(object.class.name, object.id)
11
- end
12
-
13
- def self.object_from_id(id, _query_ctx)
14
- class_name, item_id = from_global_id(id)
15
-
16
- # "Post" => Post.find(item_id)
17
- Object.const_get(class_name).find(item_id)
18
- end
19
-
20
- def self.resolve_type(_type, obj, _ctx)
21
- case obj
22
- when Article
23
- Types::ArticleType
24
- when User
25
- Types::UserType
26
- when ArticleCategory
27
- Types::ArticleCategoryType
28
- when JobConsole
29
- Types::JobConsoleType
30
- else
31
- GraphQL::ExecutionError.new("Unexpected object: #{obj}")
32
- end
33
- end
34
-
35
- def self.to_global_id(class_name, item_id)
36
- Base64.strict_encode64("#{class_name}:#{item_id}")
37
- end
38
-
39
- def self.from_global_id(global_id)
40
- token = Base64.decode64(global_id)
41
- token.split(":")
42
- end
43
- end
File without changes
@@ -1,4 +0,0 @@
1
- module Types
2
- class BaseArgument < GraphQL::Schema::Argument
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module Types
2
- class BaseEnum < GraphQL::Schema::Enum
3
- end
4
- end
@@ -1,5 +0,0 @@
1
- module Types
2
- class BaseField < GraphQL::Schema::Field
3
- argument_class Types::BaseArgument
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- module Types
2
- class BaseInputObject < GraphQL::Schema::InputObject
3
- argument_class Types::BaseArgument
4
- end
5
- end
@@ -1,7 +0,0 @@
1
- module Types
2
- module BaseInterface
3
- include GraphQL::Schema::Interface
4
-
5
- field_class Types::BaseField
6
- end
7
- end
@@ -1,5 +0,0 @@
1
- module Types
2
- class BaseObject < GraphQL::Schema::Object
3
- field_class Types::BaseField
4
- end
5
- end
@@ -1,4 +0,0 @@
1
- module Types
2
- class BaseScalar < GraphQL::Schema::Scalar
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module Types
2
- class BaseUnion < GraphQL::Schema::Union
3
- end
4
- end
@@ -1,12 +0,0 @@
1
- module Types
2
- class MutationType < Types::BaseObject
3
- workers =
4
- Dir["./app/graphql/mutations/workers/*.rb"].map do |file|
5
- file.gsub("./app/graphql/mutations/workers/", "").gsub(".rb", "")
6
- end
7
- workers.each do |worker|
8
- field worker.underscore.to_s.to_sym,
9
- mutation: Object.const_get("Mutations::Workers::#{worker.singularize.camelize}")
10
- end
11
- end
12
- end
@@ -1,6 +0,0 @@
1
- module Types
2
- class QueryType < Types::BaseObject
3
- add_field(GraphQL::Types::Relay::NodeField)
4
- add_field(GraphQL::Types::Relay::NodesField)
5
- end
6
- end
@@ -1,4 +0,0 @@
1
- class Article < ActiveRecord::Base
2
- belongs_to :user
3
- belongs_to :article_category
4
- end
@@ -1,3 +0,0 @@
1
- class ArticleCategory < ActiveRecord::Base
2
- has_many :article, dependent: :destroy
3
- end
@@ -1,19 +0,0 @@
1
- class User < ActiveRecord::Base
2
- include RoleModel
3
- has_many :article
4
-
5
- VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
6
- private_constant :VALID_EMAIL_REGEX
7
- validates :email, presence: true, uniqueness: true, format: { with: VALID_EMAIL_REGEX }
8
-
9
- roles :normal, :user, :admin, :master
10
-
11
- before_create :assign_initial_roles
12
-
13
- # Scope
14
- default_scope -> { order(created_at: :desc) }
15
-
16
- def assign_initial_roles
17
- roles << [:normal]
18
- end
19
- end
@@ -1,9 +0,0 @@
1
- module FireStore
2
- def self.log(title: "error", message: "type error!")
3
- Time.zone = "Asia/Tokyo"
4
- time = Time.zone.now.strftime("%F-%H-%M-%S")
5
- firestore = Google::Cloud::Firestore.new(project_id: "usmef-japan-trade")
6
- doc_ref = firestore.doc("Log/#{time}")
7
- doc_ref.set({ title: title, message: message, created_at: time })
8
- end
9
- end