Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Ray Ch
    @iraycd
    Yeah, I thought there was something based on JS
    :smile:
    Bojan
    @bojand
    yea dont think so heh
    might be able to do something using benchmark js but tbh i havent had the best of luck with that lib when I had tried it before a couple of times, i wasn’t quite sure i was getting completely correct results compared to my own custom written benchmarking / timing. but maybe i was mistaken.
    and that was only really to benchmark actual code / functions
    Bojan
    @bojand
    Forgot about this lib but could probably be pretty useful to just roll your own test
    Ray Ch
    @iraycd
    :smile: This is great.
    Ray Ch
    @iraycd
    Thank you for ctx.res = new Error(“Boom!”)
    Ferrellio
    @_ferrellio_twitter
    Good morning. Is there any guidance, or recommended patterns on how to test services written using Mali?
    Bojan
    @bojand
    hello, depends on the context. strictly speaking normally in your setup you can just create your app and start it on OS assign 0 port, and then do your calls to the service in the tests. on teardown close the service. i am ignoring other dependenices like db’s or other services.
    this is more like functional / integration testing.
    Ferrellio
    @_ferrellio_twitter
    Got it, thanks for the guidance.
    Bojan
    @bojand
    ideally your handler implementation would just be a function that returns / emits whatever is the payload(s), so then you can just unit test them individually w/o relying on specifics of the transport
    Ferrellio
    @_ferrellio_twitter
    Yeah, that's what I've done so far. Just testing the handlers within unit testing, and services, repositories, etc.
    It's still nice to get the end to end assurance. :)
    Ferrellio
    @_ferrellio_twitter
    Hi again - what is the preferred way to catch if app.start cannot bind to the provided port (such as is the case when it is already in use.)?
    Bojan
    @bojand
    hmm that’s a good a good question… the core server doesn’t seem to throw or anything.. just logs it
    i’ll have to look into it some more when I have some more time
    Ferrellio
    @_ferrellio_twitter
    Thanks, created as malijs/mali#39
    Greg Keys
    @gregkeys
    Can malijs be used with grpc-web?
    Bojan
    @bojand
    probably possible, but you would need to add gRPC-Web compatibility to the server using grpcwebproxy, and then use grpc-web-client from the browser to talk to the backend via the proxy.
    https://github.com/improbable-eng/grpc-web/tree/master/go/grpcwebproxy
    not something I’ve personally experimented with. I’ll have to try and find some time to do an example or a demo
    Greg Keys
    @gregkeys

    That would be really helpful, Im trying to find a very simple demo in order to do a presentation on why we should switch from crossbar.io (websockets) to gRPC, so far its not as simple as it seems at firlst look. Mali looks really clean and simple, but it appears to be focused primarily towards the backend of things.

    our ultimate goal is to use web components (front end micro services) which talk to our backend server micro services using gRPC

    Bojan
    @bojand
    Yea in general grpc story is not very good for client side (from browser) interaction right now out of the box. It usually involves some kind of proxy at the moment. There is an official project here too: https://github.com/grpc/grpc-web that's in beta now and requires a proxy as well. But in future they are planning to improve things. Mobile and server to server is more the main usage now, but I imagine web based will improve.
    Stephen Dahl
    @stephen-dahl
    is there a way to unit test mali?
    Bojan
    @bojand
    Yes. Depends what you mean by unit test exactly and what you want to test specifically. Some of it may be more of an independant functional or integration tests. But regardless your service implementation should just be functional components that you can independenantly test.
    Ferrellio
    @_ferrellio_twitter
    :point_up: That's what we've been doing. Unit testing the handler methods, stubbing out the context. @stephen-dahl
    Mina Luke
    @menocomp
    I had this warning when using new Mali(PROTO_PATH, 'UserService')
    grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
    Mina Luke
    @menocomp
    ah my mistake. I was using old version of Mali. It is running now correctly with no warnings in the latest version.
    Bojan
    @bojand
    :thumbsup:
    Mina Luke
    @menocomp
    I am trying to create a date from/to timestamp transformation for my rpc services. Is there a Mali middleware that do that for me?
    Bojan
    @bojand
    hi, can you elaborate some more on what exactly do you mean?
    Mina Luke
    @menocomp
    @bojand I am defining all date fields in proto files as google.proto.timestamp which worked correctly by using (seconds/nanos) however I have to write a JS function to convert every single date field in the response object to be timestamp.
    Also, in the calling service, I have to reverse all those timestamps to their original JS dates.
    I am curious if there is a middleware or something that can achieve this automatically for me.
    Bojan
    @bojand
    Hmm the only thing that I can think of that may help is https://github.com/malijs/param
    That's on the incoming request
    For response you could just have a regular middleware
    Or try something like this if you add a method to the response https://github.com/malijs/transform
    Peter Whitesell
    @peterwhitesell_twitter
    I want to use Mali in a typescript project and am having trouble setting the response in a handler for a unary . Following the docs and examples, I try to set ctx.res = { foo: 'bar' }, but I get the typescript error "Type '{ foo: string; }' is not assignable to type 'GrpcResponse'". Has anyone here written a Mali server with TypeScript and has any advice on this?
    Bojan
    @bojand
    Hello, was away on vacation. I see the issue on GH, and i’ll look into this… Don’t really use TS. Hope to have it resolved soon-ish.
    Peter Whitesell
    @peterwhitesell_twitter
    @bojand thank you for looking into this :thumbsup:
    Stivenson
    @stivenson
    hi all, a cordial greeting ..
    Mali.js is awesome i have been learn it currently ... :)
    Please, I have a small question:
    I'm trying to check of tests' coverage with mocha, specifically with the command nyc mocha but the results are not correct. Any idea to check the coverage of my mali.js' tests?
    My tests perform calls to the grpc methods.
    Bojan
    @bojand

    Hello, if you just run npm test you should get a coverage report:

    -------------|----------|----------|----------|----------|-------------------|
    File         |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
    -------------|----------|----------|----------|----------|-------------------|
    All files    |    98.93 |    94.12 |    98.48 |    99.18 |                   |
     app.js      |    99.41 |    95.45 |      100 |     99.4 |               323 |
     context.js  |      100 |      100 |      100 |      100 |                   |
     lo.js       |      100 |      100 |      100 |      100 |                   |
     request.js  |      100 |      100 |      100 |      100 |                   |
     response.js |      100 |      100 |      100 |      100 |                   |
     run.js      |    96.36 |    93.75 |    94.74 |    98.11 |                89 |
     utils.js    |    98.55 |    87.27 |      100 |    98.55 |                57 |
    -------------|----------|----------|----------|----------|—————————|

    Coverage is also available online: https://coveralls.io/github/malijs/mali

    Stivenson
    @stivenson
    @bojand oh thanks. I'm going to try adding babel to the coverage, because i'm using ES6 classes in node v10.
    The link is cool...
    Bojan
    @bojand
    hmm not sure i understand… there is no need for babel
    node 10 supports classes
    mali itself does not use babel or any transpiler. it’s plain javascript. what you see is what’s run.
    Stivenson
    @stivenson

    yes, @bojand yo're right, but of moment my coverage is impossible

    auth.js | 0 | 0 | 0 | 0 | 1,3,5,7,8,13 |
    core.js | 0 | 0 | 0 | 0 |... 78,82,86,91,92 |
    giftcard.js | 0 | 0 | 0 | 0 |... 41,42,43,48,53 |

    What might be ? :( i see all fine..

    only an unit-test to a file have the real coverage (it's a test that no use any proto)

    i think so: The coverage is not able to follow the execution of the functions when they are called through proto.