Git Product home page Git Product logo

logux-rack's Introduction

Logux

Logux contains multiple projects: core, Node.js server, Redux, and Vuex bindings, syntax sugar for Ruby and Django. This repository is the central hub to track big epics affecting several projects and provide support for end-users.

If you found a bug or need help in Logux best practices, this is the best place to create an issue.

logux-rack's People

Contributors

ai avatar anaumov avatar dmitrytsepelev avatar dreikanter avatar dsalahutdinov avatar dukaev avatar frostmark avatar gazay avatar moofkit avatar ojab avatar paderinandrey avatar wilddima avatar y9v avatar zumkorn avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

logux-rack's Issues

Dockerize integration tests execution

There is an error during integration testing, caused by DB records persisted after the previous test run:

npx @logux/backend-test http://localhost:3000/logux

Protocol version: 4
Secret:           parole
Logux server:     http://localhost:31337/
Back-end server:  http://localhost:3000/logux

✔  0 Supports token authentication
✔  1 Supports cookie authentication
✔  2 Processes an error during the authentication
✔  3 Detects wrong token
✔  4 Detects wrong cookie
✔  5 Sends server subprotocol
✔  6 Checks users subprotocol
✔  7 Checks subscription access
✔  8 Checks action access
✔  9 Processes an error during the action processing
✔ 10 Processes an error during the subscription
✖ 11 Processes subscriptions

  Server sent {"type":"users/name","payload":{"userId":"10","name":"B"}}, instead of {"type":"users/name","payload":{"userId":"10","name":"Name"}} action

Test:      file:///Users/dreikanter/amplifr/logux-rack/tests/backend-test/node_modules/@logux/backend-test/tests/actions.js:53:3
Re-run it: npx @logux/backend-test http://localhost:3000/logux 11

Need to purge users table after the tests execution (e.g. rails db:reset).

It would be nice to wrap the tests execution with a docker-compose configuration, to execute the whole thing with a single command:

`docker-compose run test

Instead of running the Rails server manually and then executing @logux/backend-test in a separate terminal.

Add back-end protocol 3 support

Version 3 of back-end protocol bring changes:

  1. password → secret
  2. ["error", meta.id, stack] must contain action ID.
  3. An error outside of action processing (where we do not know meta.id) the server should answer 500 HTTP code

Remove `rest-client` dependency

This gem is used in Logux::Client to perform JSON API call. It is not really necessary to maintain this dependency since the same feature can be implemented with stdlib's Net::HTTP.

spec.add_dependency 'rest-client', '>= 1.7.3', '< 3'

def post(params)
client.post(params.to_json, content_type: :json, accept: :json)
end
def client
@client ||= RestClient::Resource.new(logux_host, verify_ssl: false)
end

Undefined method `[]' for nil:NilClass. Server reachs an empty array

I'm using the example of todo for client, for server ruby_rack test example. When i send todo data from client, server getting this error;

index.js:26 Logux user ID was changed to 1
index.js:36 Logux state is connecting
index.js:36 Logux tab role is leader
index.js:26 Logux state is synchronized
index.js:26 Logux added tasks/create action
index.js:36 Logux state is sending
react_devtools_backend.js:4026 Error on Logux server:
 undefined method `[]' for nil:NilClass
/home/burak/Desktop/logux/logux-rack/test/app/app/logux/actions/tasks.rb:11:in `create'
/home/burak/Desktop/logux/logux-rack/lib/logux/action_caller.rb:27:in `public_send'
/home/burak/Desktop/logux/logux-rack/lib/logux/action_caller.rb:27:in `call_action'
/home/burak/Desktop/logux/logux-rack/lib/logux/action_caller.rb:18:in `block in call!'
/home/burak/Desktop/logux/logux-rack/lib/logux/action_watcher.rb:17:in `call'
/home/burak/Desktop/logux/logux-rack/lib/logux/rack.rb:110:in `watch_action'
/home/burak/Desktop/logux/logux-rack/lib/logux/action_caller.rb:18:in `call!'
/home/burak/Desktop/logux/logux-rack/lib/logux/process/action.rb:51:in `process_action!'
/home/burak/Desktop/logux/logux-rack/lib/logux/process/action.rb:17:in `call'
/home/burak/Desktop/logux/logux-rack/lib/logux/process/batch.rb:44:in `process_action'
/home/burak/Desktop/logux/logux-rack/lib/logux/process/batch.rb:27:in `process'
/home/burak/Desktop/logux/logux-rack/lib/logux/process/batch.rb:17:in `block in call'
/home/burak/Desktop/logux/logux-rack/lib/logux/process/batch.rb:16:in `map'
/home/burak/Desktop/logux/logux-rack/lib/logux/process/batch.rb:16:in `with_index'
/home/burak/Desktop/logux/logux-rack/lib/logux/process/batch.rb:16:in `call'
/home/burak/Desktop/logux/logux-rack/lib/logux/rack.rb:94:in `process_batch'
/home/burak/Desktop/logux/logux-rack/lib/logux/rack/app.rb:58:in `build_response'
/home/burak/Desktop/logux/logux-rack/lib/logux/rack/app.rb:21:in `block (2 levels) in process'
/home/burak/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/puma-5.6.5/lib/puma/request.rb:144:in `handle_request'
/home/burak/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/puma-5.6.5/lib/puma/server.rb:443:in `process_client'
/home/burak/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/puma-5.6.5/lib/puma/thread_pool.rb:147:in `block in spawn_thread'
overrideMethod @ react_devtools_backend.js:4026
(anonymous) @ index.js:280
emit @ index.js:6
debugMessage @ index.js:6
onMessage @ index.js:199
(anonymous) @ index.js:93
emit @ index.js:6
ws.onmessage @ index.js:35
index.js:36 Logux state is synchronized
index.js:26 Logux cleaned tasks/create action
index.js:26 Logux action tasks/create was undone because of error
index.js:182 Uncaught (in promise) LoguxUndoError: Server undid tasks/create because of error
    at Array.<anonymous> (index.js:182:41)
    at Object.emit (index.js:6:17)
    at actionEvents (index.js:8:11)
    at Array.<anonymous> (index.js:152:7)
    at Object.emit (index.js:6:17)
    at actionEvents (index.js:8:11)
    at Log.add (index.js:104:9)
(anonymous) @ index.js:182
emit @ index.js:6
actionEvents @ index.js:8
(anonymous) @ index.js:152
emit @ index.js:6
actionEvents @ index.js:8
add @ index.js:104

Change LOGUX_ROOT_PATH from /logux to /

Use root URL (/) for the Rack app root path. To allow mounting to an arbitrary explicit URL in a Rails app routing configuration.

At the moment this

# config/routes.rb
mount Logux::Engine, at: '/'

will cause Logux::App to handle /logux requests, which is not as transparent as it should be.

Note: This is a breaking change and will require major gem version version update.

Consider including this update to 1.0 release.

Bypass chunk to on_error hook

Current implementation provides error object and action id to the error handler (Logux.configuration.on_error).

def process(chunk)
case chunk[:type]
when :action
process_action(chunk: chunk.slice(:action, :meta, :headers))
when :auth
process_auth(chunk: chunk[:auth])
end
rescue StandardError => e
meta = chunk[:meta] ? chunk[:meta]['id'] : nil
handle_action_processing_errors(stream, e, meta)
end
def handle_action_processing_errors(logux_stream, exception, id)
Logux.configuration.on_error&.call(exception)
Logux.logger.error("#{exception}\n#{exception.backtrace.join("\n")}")
ensure
logux_stream.write({ id: id }.merge(Logux::ErrorRenderer.new(exception).message))
end

It makes sense to send more context, including action payload. Consider sending the chunk object contents besides the error to on_error proc.

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.