251 Commits

Author SHA1 Message Date
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
b617069784 Add packages/services/src/services/TeamService2.ts
A few notes:

1) The context higher-order function will be tedious to define - a lot
   more typing than just an extra function argument.
2) As some methods do not require the context function, forgetting to
   call it might introduce bugs (await fn will not error out), but
   compile checks of the return value type might detect this

Possible solution is to go the GRPC way and allow only a single method
type as a parameter so all server-side method types would look like:

  async fn(param: IParam, context: Context) {}

and all client-side method types would look like:

  async fn(param: IParam) {}

However, This would deviate from the JSON-RPC standard which allows
multiple arguments to be passed in an array.

Alternatively, context could be passed as a first argument and then
filtered out:

  type Arguments<T> = T extends (context: Ctx, ...args: infer A) => infer R
    ? A
    : never

In this case, the type of Ctx would need to be known in advance. Will
have to think about this some more.
2019-08-06 19:26:11 +07:00
a057ca97d5 Automatically print help 2019-08-06 18:29:58 +07:00
10ca503e59 Add script to create new package from template 2019-08-06 15:40:16 +07:00
87d515d89b Add help for positional arguments 2019-08-06 11:37:44 +07:00
a1ac8880d4 Add ability to generate help text 2019-08-06 11:14:00 +07:00
8c399c1903 Add help function 2019-08-06 11:02:02 +07:00
b50dfb1455 Add support for positional args in @rondo/argparse 2019-08-05 22:56:40 +07:00
7ea1c34428 Use @rondo/argparse for build script 2019-08-05 22:25:49 +07:00
cea9bc0dd1 Add more tests for argparse 2019-08-05 22:07:37 +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
9a156fea16 Add ability to process short flags (untested) 2019-08-05 20:26:39 +07:00
47859ffa34 Add packages/argparse 2019-08-05 18:11: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
745834848f Add createMigration task 2019-08-02 22:39:04 +07:00
3690908918 Add exec script command 2019-08-02 20:46:23 +07:00
41c5022f32 Add rondo test command 2019-08-02 20:30:44 +07:00
4c3570a9ce Do not extend/modify existing entities
Typeorm loads all @Entities and decorator-defined relations into a
global variable, and thus makes it impossible to override already
defined variables.

Will have to think about how to disable this behaviour in case the user
of this library does not want to use predefined variables, but for now
we will use the predefined defaults.
2019-08-02 20:17:10 +07:00
a6649def72 Add packages/server/src/database/DB.ts 2019-08-02 17:05:36 +07:00
d2a9d6faf6 Add log message when killing subprocess 2019-08-02 09:21:38 +07:00
9d35984033 Add frontend build scripts 2019-08-02 09:11:52 +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
33c401dbcb Make packages/scripts work 2019-08-01 13:21:11 +07:00
166981fe3b Move jsonrpc back to single package 2019-08-01 12:26:23 +07:00
9adbc584b3 Add generic action creators for jsonrpc 2019-08-01 09:18:29 +07:00
f500d7f66c Split jsonrpc into smaller packages 2019-08-01 09:17:38 +07:00
e79008cf0f Add test @rondo/scripts package for CLI 2019-07-31 10:50:29 +08: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
7dd9497514 Use ttsc instead of tsc 2019-07-31 07:19:22 +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
fdfe356ded Fix types of event handlers in TaskExecutor 2019-07-30 22:55:18 +08:00
faf76ec76a Add jsonrpc middleware 2019-07-24 23:59:02 +08:00
b5e0c408c2 Add initial impl of TaskExecutor 2019-07-19 23:33:19 +08:00