Git Product home page Git Product logo

elsoul / souls Goto Github PK

View Code? Open in Web Editor NEW
332.0 5.0 4.0 2.96 MB

🕺 SOULs 💃 Build Serverless Apps faster like Rails. Powered by Ruby GraphQL, Active Record, RSpec, RuboCop, and Google Cloud.

Home Page: https://souls.el-soul.com

License: Apache License 2.0

Ruby 99.28% Shell 0.04% Dockerfile 0.62% Procfile 0.06%
ruby graphql google-cloud serverless-framework serverless framework google-cloud-run pubsub rails ruby-on-rails

souls's Introduction

SOULs

Follow @ELSOUL_LABO2

Ruby Serverless Application Framework SOULs Document

What's SOULs?

Ruby Serverless Framework 'SOULs'.

The SOULs project was launched with the goal of reducing software development, operation and maintenance costs.

Build Serverless Apps faster like Rails. Powered by Ruby GraphQL, Active Record, RSpec, RuboCop, and Google Cloud.

  • Focus on business logic in serverless environment
  • Maximize development efficiency with CI / CD standard schema-driven Scaffold
  • Achieve global scale with lower management costs

SOULs Architecture

SOULs creates 3 types of App.

  1. API - GraphQL (Ruby) - Simple API - Cloud Run
  2. Worker - Google Pub/Sub Messaging Worker API (Ruby) - Cloud Run
  3. Functions - Google Cloud Functions

Dependency

Cloud Infrastructure

Installation

Add this line to your application's Gemfile:

gem 'souls'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install souls

And Create Your APP

$ souls new app_name

Development

After checking out the repo, run bin/setup to install dependencies. Then, run souls t to run the tests. You can also run souls c for an interactive prompt that will allow you to experiment.

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.

Test Coverage

Rspec Test Coverage

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/elsoul/souls. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the Apache-2.0 License.

Code of Conduct

Everyone interacting in the SOULs project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

souls's People

Contributors

jamesneve avatar kishithemechanic avatar poppin-fumi avatar s4na avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

souls's Issues

[Error] souls sync model

➜  api git:(frontend) souls sync model
🎉  Syncing Files...                   /Users/ktm/dev/trade-pos/config/souls.rb:5:in `block in <top (required)>'
/Users/ktm/.anyenv/envs/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/souls-0.48.2/lib/souls.rb:34:in `configure'
/Users/ktm/dev/trade-pos/config/souls.rb:1:in `<top (required)>'
<internal:/Users/ktm/.anyenv/envs/rbenv/versions/3.0.2/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
<internal:/Users/ktm/.anyenv/envs/rbenv/versions/3.0.2/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
/Users/ktm/.anyenv/envs/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/souls-0.48.2/lib/souls/cli/sync/model.rb:14:in `cp_and_dl_files'
/Users/ktm/.anyenv/envs/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/souls-0.48.2/lib/souls/cli/sync/model.rb:7:in `block in model'
/Users/ktm/.anyenv/envs/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/souls-0.48.2/lib/souls/cli/sync/model.rb:6:in `each'
/Users/ktm/.anyenv/envs/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/souls-0.48.2/lib/souls/cli/sync/model.rb:6:in `model'
/Users/ktm/.anyenv/envs/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/souls-0.48.2/exe/souls:152:in `public_send'
/Users/ktm/.anyenv/envs/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/souls-0.48.2/exe/souls:152:in `block in <top (required)>'
/Users/ktm/.anyenv/envs/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/whirly-0.3.0/lib/whirly.rb:171:in `start'
/Users/ktm/.anyenv/envs/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/souls-0.48.2/exe/souls:150:in `<top (required)>'
/Users/ktm/.anyenv/envs/rbenv/versions/3.0.2/bin/souls:23:in `load'
/Users/ktm/.anyenv/envs/rbenv/versions/3.0.2/bin/souls:23:in `<main>'
undefined method `github_repo=' for #<Souls::Configuration:0x00007ff62bad7e78 @app="trade-pos", @project_id="usmef-japan-trade", @region=nil, @endpoint=nil, @strain="mother", @fixed_gems=[""], @workers=nil>
➜  api git:(frontend) souls -v
0.48.2

need to add error handling with `souls db create` when docker psql doesn't exist

souls db create
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)

(See full trace by running task with --trace)
/home/fudo/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/souls-1.13.4/lib/souls/cli/db/index.rb:91:in `db_system': It looks like there was a problem with the DB. Make sure PSQL is running with 'souls docker psql' (Souls::PSQLException)
        from /home/fudo/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/souls-1.13.4/lib/souls/cli/db/index.rb:30:in `create'
        from /home/fudo/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
        from /home/fudo/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
        from /home/fudo/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
        from /home/fudo/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/thor-1.1.0/lib/thor/invocation.rb:116:in `invoke'
        from /home/fudo/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/thor-1.1.0/lib/thor.rb:243:in `block in subcommand'
        from /home/fudo/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
        from /home/fudo/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
        from /home/fudo/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
        from /home/fudo/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/thor-1.1.0/lib/thor/base.rb:485:in `start'
        from /home/fudo/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/souls-1.13.4/exe/souls:11:in `<top (required)>'
        from /home/fudo/.rbenv/versions/3.0.1/bin/souls:23:in `load'
        from /home/fudo/.rbenv/versions/3.0.1/bin/souls:23:in `<main>'

remove define_method from QueryType

module Types
  class QueryType < Souls::Types::BaseObject
    add_field(GraphQL::Types::Relay::NodeField)
    add_field(GraphQL::Types::Relay::NodesField)
    SoulsHelper.get_tables.each do |t|
      field t.singularize.underscore.to_s.to_sym, resolver: Object.const_get("Queries::#{t.singularize.camelize}")
      field "#{t.singularize.underscore}_search".to_sym,
            resolver: Object.const_get("Resolvers::#{t.singularize.camelize}Search")
      field t.pluralize.underscore.to_s.to_sym,
            Object.const_get("Types::#{t.singularize.camelize}Type").connection_type,
            null: true
      #remove this line
      define_method t do
        Object.const_get(t.singularize.camelize.to_s).all.order(id: :desc)
      end
      # end
    end
  end
end

new_record needs decoded id

update_article.rb

        new_record = { **args, id: data_id, user_id: user_id, article_category_id: article_category_id }

add `check_user_permissions` method to SOULs gem

def check_user_permissions(user, obj, method)
  raise(StandardError, "Invalid or Missing Token") unless user

  policy_class = obj.class.name + "Policy"
  policy_clazz = policy_class.constantize.new(user, obj)
  permission = policy_clazz.public_send(method)
  raise(Pundit::NotAuthorizedError, "permission error!") unless permission
end

Add `souls_fb_auth` in SoulsMutation

I updated souls-doc's firebase login method like below;

module Mutations
  module Managers::UserManager
    class SignInUser < BaseMutation
      field :status, String, null: false
      field :token, String, null: true
      field :user_role, String, null: true
      field :username, String, null: true
      argument :token, String, required: false

      def resolve(token:)
        payload = souls_fb_auth(token: token)
        begin
          user = ::User.find_by_uid(payload["sub"])
          user.update(icon_url: payload["picture"], username: payload["name"])
          token_base = JsonWebToken.encode(user_id: user.id)
          {
            status: "ログイン成功!",
            username: user.username,
            token: token_base
          }
        rescue StandardError
          user =
            ::User.new(
              uid: payload["sub"],
              email: payload["email"],
              icon_url: payload["picture"],
              username: payload["name"],
              user_role: 4
            )
          if user.save
            token = JsonWebToken.encode(user_id: user.id)
            {
              status: "ユーザー新規登録完了!",
              username: user.username,
              token: token,
              user_role: user.user_role
            }
          else
            { status: user.errors.full_messages }
          end
        end
      end
    end
  end
end

SOULs Doc

It would be super if that souls_fb_auth works behind and return Firebase payload.

current code

module Mutations
  class BaseMutation < GraphQL::Schema::RelayClassicMutation
    argument_class Types::BaseArgument
    field_class Types::BaseField
    input_object_class Types::BaseInputObject
    object_class Types::BaseObject

    def fb_auth(token:)
      FirebaseIdToken::Certificates.request!
      sleep(3) if ENV["RACK_ENV"] == "development"
      @payload = FirebaseIdToken::Signature.verify(token)
      raise(ArgumentError, "Invalid or Missing Token") if @payload.blank?

      @payload
    end
,
,

Test gem install as part of workflow

Thanks to #139 , we know that gem install can fail silently when we're not aware of it.

Let's add a test to the workflow so that gem install from the current branch is checked whenever we push.

Working with modules

I'm trying to move as much of my existing rails application to souls. I'm running into errors when dealing with modules/concerns.

I was getting an error with

module Legiscan
  require 'legiscan/error'
  require 'legiscan/request'
  require 'legiscan/push'

Was able to fix it by moving those class definitions in the same file

But now I'm getting an error with my concerns. I'm getting this error

NameError: uninitialized constant Voter

  include Voter

in my model

class User < ApplicationRecord
  include Voter
  include Follower
  include Verifiable
  include Devise::JWT::RevocationStrategies::JTIMatcher

How can I import modules into my models?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.