28 Commits

Author SHA1 Message Date
dffad844ad Rename scope @rondo to @rondo.dev 2019-08-25 11:33:06 +07:00
19565563cc Add Contextual<Service, Context> type
As seen in TeamService2.ts, the Contextual type will add Context as the
last argument to any method of the interface, as long as the method has
0-4 arguments.

Interfaces with more than 4 arguments cannot use this type, but they
could be converted to interfaces which use 1 argument
(object/dictionary) only.

Some long-term thinking: Maybe only methods with a single argument
should be supported, similar to the way gRPC does it.
2019-08-07 22:37:48 +07:00
cc2f5f58e2 Add ability to specify jsonrpc context as extra argument
In this case the interface does not define context, but the implementing
service may use it as an optional argument:

  interface IService {
    add(a: number, b: number): number
  }

  class Service implements IService {
    add(a: number, b: number, ctx?: IContext): number {
      return a + b + ctx!.userId
    }
  }
2019-08-06 20:10:38 +07:00
86e90d28bb Make express jsonrpc use a builder pattern 2019-08-05 21:07:46 +07:00
f3f6166aab Send 405 when GET request is not allowed 2019-08-05 21:07:46 +07:00
e2f6c5f798 Encode JSON-RPC GET request params as JSON 2019-08-05 21:07:46 +07:00
81225b77a8 Implement GET method for idempotent methods 2019-08-05 21:07:46 +07:00
7edbe354a9 Remove TODO from jsonrpc 2019-08-05 21:07:46 +07:00
15d54639ab Move ILogger to @rondo/common 2019-08-04 13:15:33 +07:00
aeb208162f Refactor express#handleError 2019-08-04 13:02:01 +07:00
e6a98bb450 Add ability to call idempotent methods via GET request 2019-08-04 10:19:42 +07:00
c273c1b914 Extract jsonrpc functionality into a separate file 2019-08-04 10:08:06 +07:00
1cb41e4b4a Move types to types.ts, rename some types 2019-08-02 08:27:53 +07:00
9aba9000b7 Rename createReduxClient to createActions 2019-08-01 20:01:30 +07:00
daf32de431 Add test for missing method 2019-08-01 19:55:30 +07:00
2b0ccfb984 Update createReducer API for jsonrpc 2019-08-01 19:40:26 +07:00
4faedc23ce WIP: Add ability to define reducer handlers 2019-08-01 19:03:10 +07:00
82ec4c321a Add & test createReducer 2019-08-01 16:35:40 +07:00
dca9691d7d Add ability to easily create redux middleware for async actions 2019-08-01 15:51:59 +07:00
fa27dda530 Add ability to infer jsonrpc redux action types 2019-08-01 13:57:51 +07:00
166981fe3b Move jsonrpc back to single package 2019-08-01 12:26:23 +07:00
f500d7f66c Split jsonrpc into smaller packages 2019-08-01 09:17:38 +07:00
dde96b41d3 Add packages/scripts 2019-07-31 09:53:45 +08:00
3787315905 Add jsonrpc local, remote and supertest clients 2019-07-31 08:44:50 +08:00
cfc6933e78 jsonrpc: Add ability to specify context via high-order functions 2019-07-31 01:10:27 +08:00
401e5b481a Set status to 204 for notifications 2019-07-31 00:53:57 +08:00
e16edd5655 Add 100% test coverage for jsonrpc server 2019-07-31 00:19:46 +08:00
faf76ec76a Add jsonrpc middleware 2019-07-24 23:59:02 +08:00