Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Paul Smith
    @paulcsmith
    Will take a look now!
    Michael Lang
    @mwlang
    @jwoertink Now that you mention it, I may need to look into my postgres server / client settings as this is a new development machine and on Linux instead of macOS. It may be postgres itself doing the prompting for password even though the psql cli doesn't prompt.
    Håkan Nylén
    @confact
    I don't need to do anything anymore. @stephendolan is doing everything for me
    Stephen Dolan
    @stephendolan
    Hmmm... where does send_json come from (referenced here: https://luckyframework.org/guides/testing/testing-actions#json-actions)?
    Crystal's having some trouble: undefined method 'send_json' for top-level
    Håkan Nylén
    @confact
    @stephendolan i think that is a spec helper method
    So need to require spec helper
    Stephen Dolan
    @stephendolan
    Ah right, it's in Lucky::RequestExpectations
    Cool, that helped me track it down, thanks @confact !
    We were missing that inclusion from the website codebase spec/spec_helper.cr file
    Håkan Nylén
    @confact
    Easy to miss :)
    Paul Smith
    @paulcsmith
    Ah yeah that makes sense. Website is an older codebase and I probably missed that update or thought "why would this ever have an API?" :P
    Stephen Dolan
    @stephendolan
    Haha yeah, there have a been a few small things to add, but it's pretty amazing how simple it was to add an API
    Really feels like a first-class citizen to the framework, and not an afterthought
    Paul Smith
    @paulcsmith
    Woo hoo! Glad it was pretty easy. Still some parts that could be better, and test helpers need a bit more work, but it's getting there :)
    Stephen Dolan
    @stephendolan
    One piece I am struggling with is how to set an ENV variable from within a test to ensure that it affects the test output appropriately

    I've got this spec:

      it "returns a 503 (Service Unavailable) when HTML conversions are disabled" do
        ENV["DISABLE_HTML_CONVERSION_API"] = "Shut it down!"
    
        response = AppClient.exec(Api::HtmlConversions::Create.with(input: "<div>Test</div>"))
    
        puts response
    
        response.status_code.should eq(503)
      end

    And this before action, where it complains that the ENV key is missing:

      private def halt_if_html_conversion_disabled
        puts ENV["DISABLE_HTML_CONVERSION_API"]
        if ENV["DISABLE_HTML_CONVERSION_API"]?
          head :service_unavailable
        else
          continue
        end
      end
    (the puts statements are just temporary :smile:)
    Stephen Dolan
    @stephendolan
    Ahh, the spec is just connecting to the current dev server, which establishes the ENV when it spins up... hmm...
    Paul Smith
    @paulcsmith
    Oh right. This makes sense because the server is actually running in its own process. Id say to skip that test for now and just do the happy oath test
    I think we won’t need it anyway unless some hackers decide to randomly target Lucky :P
    Or there are so many lucky users converting html at once that it crashes things. Which I think would be pretty awesome :D
    Stephen Dolan
    @stephendolan
    Haha agreed, that would be a good problem to have :)
    PR should be RTM, in that case! I did test locally with the env flag, and even added a helpful message to the VSCode plugin when it gets a 503!
    Paul Smith
    @paulcsmith
    Wonderful!! Looking now
    Stephen Dolan
    @stephendolan
    Nevermind... into CI/CD land I go! The dev server needs to be running for the GitHub action to work
    Michael Lang
    @mwlang

    @jwoertink After some investigating, it seems Avram connects on host rather than local for Posgres. So the solution to get password-less DB connections working was to add this to my pg_hba.conf

    local   all             mwlang                                  peer
    host    all             mwlang          127.0.0.1/32            peer

    which was kind of unexpected that both are needed because I would expect localhost as the hostname to resolve to the local entry always.

    3 replies
    At any rate, once I solved the password issue, I hit upon the next hurdle and that is createdb is running and is looking for template0 even though the test database already exists.
    Unhandled exception: It looks like Postgres is not running.
    
    Message from Postgres:
    
      createdb: error: could not connect to database template1: could not connect to server: Connection refused
            Is the server running on host "localhost" (127.0.0.1) and accepting
            TCP/IP connections on port 5432?
    N Atta Kusi Adusei
    @akadusei
    Hi everyone, I just released Shield v0.1.0. Shield is a comprehensive security solution for Lucky framework: https://github.com/grottopress/shield
    Michael Lang
    @mwlang
    actually, strike that. with both local and host entries in the HBA file, not even psql is able to connect...still diagnosing.
    Michael Lang
    @mwlang
    @akadusei to use this shield, do we need to delete the auth pages that Lucky installs when we first set up our project or is this to augment all that?
    N Atta Kusi Adusei
    @akadusei
    @mwlang Lucky's generated auth pages are designed to be used with Authentic, I believe. If that's the case, you would need to remove them, to use Shield. You can skip auth when generating a new project with the --no-auth flag, thus: lucky init.custom my_app --no-auth
    Michael Lang
    @mwlang
    That is worth documenting in your README or other docs so it's very clear.
    N Atta Kusi Adusei
    @akadusei
    @mwlang I agree. Will work on that. Thanks.
    Michael Lang
    @mwlang
    with some more experimenting, apparently order of entries matter, so moving my specific user up in the HBA file to just under the first one for postgres resulted in successfully being able to connect w/o password.
    host    all             mwlang          127.0.0.1/32            trust
    also, using trust instead of peer as I was previously
    Paul Smith
    @paulcsmith
    @mwlang wow that sounds pretty complex. Once you get it all working would you mind opening an issue on the website repo? I think it’d be good to note that this is a potential solution for Linux users
    Sorry it’s being such a pain to get working!
    Michael Lang
    @mwlang
    LOL This one's not Lucky's fault. And honestly, I haven't had to modify a postgres HBA file in almost 8 years
    Jeremy Woertink
    @jwoertink
    nice! @akadusei Thanks for sharing!
    N Atta Kusi Adusei
    @akadusei
    @jwoertink You welcome :-)
    Ghost
    @ghost~56ba344de610378809c0a277
    @akadusei Is it easy to migrate a project based on authentic to shield?
    N Atta Kusi Adusei
    @akadusei
    @snadon I can't tell from experience. (:facepalm: I should have thought about this). What I intend to do the coming week, is build a basic Lucky app based on Authentic, and try to migrate to Shield. I'll update the documentation to reflect what I learn.
    Stephen Dolan
    @stephendolan
    Have any of y'all successfully created a wrapper Component for a link in Lucky? I've been trying with something like what's below, but it's trying to match the union type to a signature in Lucky::LinkHelpers rather than each individual type and throwing a compile error :(
    class UI::CardActionHeader < BaseComponent
      needs title : String
      needs link_text : String
      needs link_target : Lucky::Action.class | Lucky::RouteHelper | String
    
      def render
        div class: "-ml-4 -mt-2 flex items-center justify-between flex-wrap sm:flex-no-wrap" do
          div class: "ml-4 mt-2" do
            h3 class: "text-lg leading-6 font-medium text-gray-900" do
              text title
            end
          end
          div class: "ml-4 mt-2 flex-shrink-0" do
            span class: "inline-flex rounded-md shadow-sm" do
              link link_text, to: link_target, class: "a lot of classes"
            end
          end
        end
      end
    end
    Ends up throwing this:
    web          |  15 | link link_text, to: link_target, class: "a lot of classes"
    web          |       ^---
    web          | Error: no overload matches 'UI::CardActionHeader#link' with types String, to: (Lucky::Action.class | Lucky::RouteHelper | String), class: String
    web          |
    web          | Overloads are:
    web          |  - Lucky::LinkHelpers#link(text, to : Lucky::RouteHelper, attrs : Array(Symbol) = [] of Symbol, **html_options)
    web          |  - Lucky::LinkHelpers#link(text, to : Lucky::Action.class, attrs : Array(Symbol) = [] of Symbol, **html_options)
    web          |  - Lucky::LinkHelpers#link(to : Lucky::RouteHelper, attrs : Array(Symbol) = [] of Symbol, **html_options, &block)
    web          |  - Lucky::LinkHelpers#link(to : Lucky::Action.class, attrs : Array(Symbol) = [] of Symbol, **html_options, &block)
    web          |  - Lucky::LinkHelpers#link(to : Lucky::RouteHelper, attrs : Array(Symbol) = [] of Symbol, **html_options)
    web          |  - Lucky::LinkHelpers#link(to : Lucky::Action.class, attrs : Array(Symbol) = [] of Symbol, **html_options)
    web          |  - Lucky::LinkHelpers#link(text, to : String, attrs : Array(Symbol) = [] of Symbol, **html_options)
    web          |  - Lucky::LinkHelpers#link(to : String, attrs : Array(Symbol) = [] of Symbol, **html_options, &block)
    Matthew McGarvey
    @matthewmcgarvey
    I've been shown Laravel's Telescope tool and it makes me all the more excited for Breeze :tada: :tada: :tada: :tada:
    Håkan Nylén
    @confact
    @stephendolan if you find a solution to that please tell me. Got the same issue when I want to loop through links for navigation :D
    Stephen Dolan
    @stephendolan
    I did figure it out! Not to do exactly that, but another way to accomplish the same thing. Going to be posting a LuckyCast on it in the next week or so!
    Paul Smith
    @paulcsmith
    @stephendolan @confact This is what I was going to recommend (not tested yet) https://gist.github.com/paulcsmith/180bf202509b926c914e92bd137700de
    Similar pattern to Shared::Field. This allows you to pass any option you want and use other methods like a or button instead of link. But I haven't test yet so not sure. Might be worth exploring. Looking forward to seeing what you came up with @stephendolan!