faustinoaq changed the topic of #amber to: Welcome to Amber Framework community! | https://amberframework.org | Developer happiness, productivity and bare metal performance | GH: https://github.com/amberframework | Docs: https://docs.amberframework.org | Gitter: https://gitter.im/amberframework/amber | IRC Logger: https://irclog.whitequark.org/amber | Amber::Server.start
<FromGitter> <drujensen> @eliasjpr time to spin up an amber box and do the same. ;-)
wontruefree has quit [Ping timeout: 245 seconds]
_whitelogger has joined #amber
feepbot has quit [Ping timeout: 240 seconds]
feepbot has joined #amber
<FromGitter> <eliasjpr> Definitely we have to put amber to the test
<FromGitter> <grig191> Guys please help!
<FromGitter> <grig191> Currently im running amber as json API and separate vue frontend, but I have troubles with CORS
<FromGitter> <grig191> Previously, CORS pipe was disabled by me, but since browsers make OPTIONS requests, I enabled it
<FromGitter> <grig191> But now there is another problem: in dev environment, vue is at localhost:8081 and amber is at localhost:3000, so it is different domains
<FromGitter> <grig191> in result i have this: ⏎ `No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8081' is therefore not allowed access.`
<FromGitter> <grig191> How can I allow specific origin domains?
<FromGitter> <damianham> I think you are going about it arse over tit
<FromGitter> <damianham> load the app by visiting a home page at localhost:3000 and embed vue or any other frontend DOM rendering framework into the home page
<FromGitter> <damianham> look at the preact redux recipe at https://github.com/amberframework/recipes/tree/master/react as an example
<FromGitter> <grig191> Thx, in production vue will be hosted in `public/`, but I need another solution in dev environment
<FromGitter> <grig191> I guess I figured it out
<FromGitter> <grig191> But it is very strange:
<FromGitter> <grig191> CORS pipe allows only `["POST", "PUT", "PATCH", "DELETE"]`
<FromGitter> <grig191> BUT, Chrome is making GET request with preflight check!
<FromGitter> <grig191> wdyt about it?
<FromGitter> <eliasjpr> you can change the CORS pipe allow methods on intialization
<FromGitter> <damianham> yes it makes an OPTIONS preflight check IIRC - looks like we need to add OPTIONS to that list
<FromGitter> <c910335> Use `plug Amber::Pipe::CORS.new(methods: %w(GET POST PUT PATCH DELETE))` in your `config/routes.cr`
<FromGitter> <eliasjpr> @c910335 thanks!
<FromGitter> <eliasjpr> @damianham Options is checked by default. It is what allows CORS to know if the request is a preflight request https://github.com/amberframework/amber/blob/master/src/amber/pipes/cors.cr#L75
<FromGitter> <eliasjpr> @grig191 you can see the initialization options here https://github.com/amberframework/amber/blob/master/src/amber/pipes/cors.cr#L28
<FromGitter> <eliasjpr> You can configure CORS pipe as needed.
<FromGitter> <grig191> @eliasjpr yes, i already figured it out
<FromGitter> <damianham> ah yes OK - I thought I my recollection of it was a bit sketchy
<FromGitter> <grig191> but surprise was is preflight on GET
<FromGitter> <grig191> because usually GET is not CORS
<FromGitter> <eliasjpr> Agreed @grig191
<FromGitter> <eliasjpr> @/all would like to get some inputs about implementing nested params in Amber
<FromGitter> <eliasjpr> Someone already posted an issue in regards to this here https://github.com/amberframework/amber/issues/943
<FromGitter> <eliasjpr> We are considering enhancing this functionality and more detail will help to shed some light for an approach. Some of the things you can please elaborate on. ⏎ ⏎ 1) Examples of nested params in request ⏎ 2) Expected parsed output for nested params ⏎ 3) How you plan to use nested params ... [https://gitter.im/amberframework/amber?at=5b992a02a2343433d13a957a]
<FromGitter> <grig191> Nested params is great feature!
<FromGitter> <eliasjpr> yes it is a high requested feature and in order to implement it we would have to settle into some conventions
<FromGitter> <eliasjpr> I would like to suggest to use a format of `user.address.city=New York&user.address.address=West 28 St`
<FromGitter> <eliasjpr> I think the `.` notation is simple and clean
<FromGitter> <damianham> it would be a POST surely?
<FromGitter> <eliasjpr> when parsed the params would become a hash ⏎ ⏎ ```{ :user => { :address => { :city => “New York”, :address => “West 28 St" } } }``` [https://gitter.im/amberframework/amber?at=5b992bd1a04db554a715e5da]
<FromGitter> <eliasjpr> > it would be a POST surely? ⏎ ⏎ This can be in url or form post
<FromGitter> <damianham> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5b992e4e1e2b442a25001d3c]
<FromGitter> <eliasjpr> String keys got it
<FromGitter> <damianham> key thing there is that nested array has either id for existing associated records or "" for new
<FromGitter> <damianham> if an existing record is missing in the posted params array then delete it
<FromGitter> <damianham> I think that is a better option than "post_attributes"=>{"0"=>{"title"=>"jshdgj","body"=>"ahsgaj","_destroy"=>""}}
wontruefree has joined #amber
<robacarp> automagic deleting of records because they aren't present shouldn't be a default
<robacarp> an option, sure, but that seems like it should live in the ORM
<FromGitter> <valamorgon> I've just upgraded my crystal to 26 and upgraded my amber to latest using shards update
<FromGitter> <valamorgon> when I make amber w I got this
<FromGitter> <valamorgon> Unhandled exception: Couldn't parse (Array(String) | Bool | String) at line 11, column 5 (YAML::ParseException) ⏎ from /usr/lib/crystal/yaml/nodes/nodes.cr:30:9 in 'raise' ⏎ from /usr/lib/crystal/yaml/from_yaml.cr:203:3 in 'new' ⏎ from /usr/lib/crystal/yaml/from_yaml.cr:113:28 in 'new' ⏎ from lib/amber/src/amber/environment/settings.cr:49:5 in 'initialize' ...
<FromGitter> <valamorgon> any idea?
<FromGitter> <eliasjpr> Not sure if this helps but might be worth the try, can you clear the `~/.crystal` cache directory.
<robacarp> no, the problem is in your config/development.yml
<robacarp> in mine, it was under logging
<FromGitter> <valamorgon> now I deleted crystal cache directory like @eliasjpr suggest, still same error
<FromGitter> <eliasjpr> 👍
<FromGitter> <robacarp> I did this to fix mine, a similar change might help:
<FromGitter> <valamorgon> @robacarp I don't understand, you delete skip line?
<robacarp> yep
<robacarp> if you paste your config/environments/development.yml, I can tell you what needs to be deleted
<FromGitter> <eliasjpr> should we fix that?
<robacarp> ideally it _shouldn't_ explode on an empty array item, yeah.
<robacarp> it should also allow the yaml definition to be flexible and opt-in rather than a strict schema
<FromGitter> <valamorgon> if I delete it I have this error
<FromGitter> <valamorgon> Missing yaml attribute: skip at line 5, column 3 (YAML::ParseException) ⏎ Failed to raise an exception: END_OF_STACK
<robacarp> @valamorgon, can you post your development.yml?
<FromGitter> <valamorgon> secret_key_base: dadada ⏎ port: 3000 ⏎ name: server ⏎ logging: ⏎ severity: debug ... [https://gitter.im/amberframework/amber?at=5b996aaaa56b215c972b096f]
<FromGitter> <valamorgon> It didnt look good when I post it like that
<FromGitter> <robacarp> you can wrap the whole message in ```
<FromGitter> <robacarp> 3 backticks
<FromGitter> <valamorgon> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5b996ae41ee2ca6502089a47]
<FromGitter> <valamorgon> @robacarp thanks for the info
<FromGitter> <robacarp> np
<FromGitter> <robacarp> you should be able to delete both the `skip` and the `-` line below it
<FromGitter> <robacarp> line 11 and 12 (I think, no numbers here)
<FromGitter> <valamorgon> ``````
<FromGitter> <valamorgon> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5b996b250cfe7f30f1854ccd]
<FromGitter> <valamorgon> I delete it like this
<FromGitter> <robacarp> yeah. does that still break?
<FromGitter> <eliasjpr> why that skip line breaks?
<FromGitter> <valamorgon> now I have this error:
<FromGitter> <valamorgon> Missing yaml attribute: skip at line 5, column 3 (YAML::ParseException) ⏎ Failed to raise an exception: END_OF_STACK
<FromGitter> <robacarp> hm, what version of amber are you on?
<FromGitter> <valamorgon> 1) 9.0
<FromGitter> <robacarp> hm, same here
<FromGitter> <valamorgon> btw are you guys running 26.1?
<FromGitter> <valamorgon> I m running 26
<FromGitter> <valamorgon> it is the latest version from pacman
<FromGitter> <robacarp> I am running 26.1, yeah
<FromGitter> <robacarp> that might be causing it, but I'm not sure
<FromGitter> <robacarp> I upgraded amber to 0.9 at the same time as crystal to 0.26.1 (skipping 0.26)
<FromGitter> <valamorgon> okay just to make sure I will manually upgrade
<FromGitter> <valamorgon> I ve just upgraded to 26.1 also
<FromGitter> <valamorgon> then delete cache
<FromGitter> <valamorgon> then shards update
<FromGitter> <valamorgon> still have this
<FromGitter> <valamorgon> Missing yaml attribute: skip at line 5, column 3 (YAML::ParseException) ⏎ Failed to raise an exception: END_OF_STACK
<FromGitter> <eliasjpr> can you add the skip back
<FromGitter> <eliasjpr> without `-`
<FromGitter> <valamorgon> if I add skip without - I got this
<FromGitter> <valamorgon> Expected sequence, not YAML::Nodes::Scalar at line 10, column 8 (YAML::ParseException) ⏎ Failed to raise an exception: END_OF_STACK
<FromGitter> <eliasjpr> one sec
<FromGitter> <eliasjpr> im going to try it
<FromGitter> <eliasjpr> @valamorgon this app used to run in the previous version of amber?
<FromGitter> <valamorgon> yes
<FromGitter> <valamorgon> I was in crystal 25.1 and amber 8
<FromGitter> <valamorgon> I install the same app on two device one of them arch linux other xubuntu
<FromGitter> <valamorgon> both of them was working
<FromGitter> <valamorgon> now trying to upgrade arch
<FromGitter> <eliasjpr> I just generated an app using amber 0.9.0 and crystal 0.26.1 ⏎ can you copy and paste this yaml and use your values. ⏎ ⏎ This example is from a generated app ⏎ ... [https://gitter.im/amberframework/amber?at=5b99707afcba1254faa7c972]
<FromGitter> <eliasjpr> Can it be the YAML library used in one of the linux system?
<FromGitter> <eliasjpr> I know that for crystal you have to install a yaml lib
<FromGitter> <eliasjpr> for ubuntu `sudo apt install libyaml-dev`
<FromGitter> <valamorgon> okay I will try all your suggestions and keep here updated
<FromGitter> <eliasjpr> thanks for being patient I know this can be frustrating
<FromGitter> <eliasjpr> if you find a solution feel free to document it in Amber docs
<FromGitter> <valamorgon> oh god, thank you for being patient, you guys are the best community
<FromGitter> <eliasjpr> :) ♥️
<feepbot> Awwwwwwwwwwwww!
<FromGitter> <eliasjpr> ha!
wontruefree has quit [Quit: bye]
wontruefree has joined #amber