trailblazer / trailblazer-endpoint

Generic HTTP endpoints to deal with different results from your operations.
22 stars 18 forks source link

Gem migration and docs incomplete #8

Open nomasprime opened 6 years ago

nomasprime commented 6 years ago

The endpoint code has been moved from Trailblazer to here but it looks like process wasn't completed because the only way I can seem to use the gem is bundling directly from Github.

Docs also need updating.

apotonick commented 6 years ago

Hi Rick, we're in the process of finalizing the API, and then you will get new docs!

nomasprime commented 6 years ago

Thanks @apotonick, very much appreciated and liking Trailblazer 👍

In the meantime I have this controller:

class ArticlesController < ApplicationController
  include Trailblazer::Endpoint::Controller

  def show
    endpoint Article::Operation::Show.(:id => params[:id]) do |m|
      m.success do |result|
        render :html => cell(
          Article::Cell::Show,
          result["model"],
          :layout => App::Cell::Layout
        )
      end
    end
  end
end

I'm getting uninitialized constant Trailblazer::Endpoint::Controller::Handlers.

Any ideas?

Not sure if I'm the bug so thought I'd mention here and raise separately if need be.

apotonick commented 6 years ago

Uhm, it looks like you're using a very old version, I can give you a working version later tonight.

nomasprime commented 6 years ago

@apotonick no probs. I'll pop it on Gitter in meantime, client's breathing down my neck 🙄

apotonick commented 6 years ago

Not sure this will help, since that gem hasn't been released, yet, and underwent many changes and redesigns.

nomasprime commented 6 years ago

@apotonick cool, I'll put in a workaround for now until you get a chance.

apotonick commented 6 years ago

Yeah, just run the op manually in the controller and add some ifs, I can later help you migrate it to the stable API.

nomasprime commented 6 years ago
class ArticlesController < ApplicationController
  def show
    result = Article::Operation::Show.(:id => params[:id])

    if result.success?
      render :html => cell(
        Article::Cell::Show,
        result["model"],
        :layout => App::Cell::Layout
      )
    elsif result["model"].nil?
      render(
        :html => cell(
          App::Cell::Error,
          nil,
          :layout => App::Cell::Layout
        ),
        :status => 404
      )
    end
  end
end

I'm a TB noob, can you tell 😄

apotonick commented 6 years ago

So there's one thing you could take advantage of already, that's render from trailblazer-rails: http://trailblazer.to/gems/trailblazer/2.0/rails.html#render

Other than that, what you do here is basically what your endpoint will abstract in a few hrs. :stuck_out_tongue_winking_eye:

agis-theodoropoulos commented 6 years ago

Hello!

Is there an ETA for the gem's release?

apotonick commented 6 years ago

Good timing, there's an endpoint team meeting scheduled for next week, we will then publish a roadmap. I'd say somewhere in March?

agis-theodoropoulos commented 6 years ago

Excellent! I'm looking forward to it.