91 Commits

Author SHA1 Message Date
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
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
15d54639ab Move ILogger to @rondo/common 2019-08-04 13:15:33 +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
7dd9497514 Use ttsc instead of tsc 2019-07-31 07:19:22 +08:00
a672aab11d Add ability to run app minified 2019-04-15 21:45:03 +12:00
5f662a1ac1 Make server work with browserify --node 2019-04-15 14:28:56 +12:00
dcc2fb4dc8 Log error messages during app Bootstrap.ts 2019-04-15 13:09:32 +12:00
9d282b278d Build ESM client-side modules to enable tree shaking
TypeScript compiler needs to be configured to output ES6 module by
setting --module es6 or the equivalent tsconfig.json compilerOptions
parameter.

Since tsc --build does not accept compiler options flags, we need to
duplicate some of the configuration:

- specify separate output folder for ES6 module files (new
  tsconfig.esm.json file)
- add "module" field for ES6 module (esm) output files to package.json

Hence, a script `scripts/sync-esm-config.js` was added to automate this
process.
2019-04-11 11:40:07 +08:00
e509c32f79 Add ability to load votes by id
Use createDate and updateDate as strings
2019-04-08 13:33:58 +08:00
e727687ec8 Refactor CommentActions, add skeleton for Reducer 2019-04-07 00:23:01 +08:00
bbf18ed27a Add ability to specify middleware in AsyncRouter 2019-04-06 21:32:20 +08:00
89af2f0845 Add StringUtils 2019-04-06 13:58:20 +08:00
264f5aba60 Add T prefix for all type defs 2019-04-02 16:22:38 +08:00
0630260628 Add space-within-parens rule 2019-04-02 15:09:47 +08:00
adfa7a069a Add common tslint.json configuration 2019-04-02 14:46:40 +08:00
ed047be2e3 Add valueOrError.ts 2019-03-27 16:23:47 +08:00
e76f762d23 Fix TeamService deleting all team realtions by userId 2019-03-25 13:30:21 +08:00
c83fa2d6d4 packages/client: Style TeamManager, fix error on delete 2019-03-25 13:28:09 +08:00
3f96a128a0 packages/server: Return API errors as JSON 2019-03-25 13:27:36 +08:00
c1d7077061 packages/server: Return validation errors as JSON 2019-03-25 13:19:20 +08:00
77838e8e0c packages/comments-server: Migrate to mysql/mariadb
Currently mysql2 prints a warning every time a connection is
established. This should be fixed with soon:

https://github.com/typeorm/typeorm/pull/3753
2019-03-23 21:21:50 +08:00
93b048bc10 Add correlationId to SqlLogger 2019-03-23 21:16:20 +08:00
dca5374911 Use $typeorm in buildfile 2019-03-23 17:14:08 +08:00
a628082a73 Add packages/client/src/team 2019-03-20 15:01:15 +05:00
9aff78b7a9 Add ability to search users by email
This might be a security concern, even though the user will have to
provide an email to retrieve user information.

This functionality is needed by Team management functionality because
expecting users to add a user by id is hard.

TODO: explore other options. Maybe add public profiles and request the
user to go to the profile to invite a user to team?
2019-03-20 13:23:47 +05:00
7a0d44abe4 Return ITeam[] from /my/teams 2019-03-20 11:15:49 +05:00
46e56b7ad4 Add routes for managing users in teams 2019-03-19 17:51:16 +05:00
dfca6cf073 Remove 302 after logout 2019-03-19 10:59:45 +05:00
209378424c Increase default duration in SessionMiddleware 2019-03-19 10:50:51 +05:00
6ae5817529 Generate req.correlationId 2019-03-19 10:20:32 +05:00
c813407c95 Add LoginMenu.tsx 2019-03-18 20:18:52 +05:00
30a8c56119 Fix test for User firstName & lastName
Also fix CSRF token. This was probably broken since csurf middleware was
modified to use cookie instead of session storage to provide support for
single page app (SPA).
2019-03-18 15:53:05 +05:00
6fb69e40df Build tsc project before generating migration
This is especially important for comments-server, because ts-node will
use compiled js files from @rondo/server - that's just how node's module
resolution works and I do not think there's anything that we can do to
change that
2019-03-18 14:27:32 +05:00
49fc73a1c2 comments/server: Add migration for User 2019-03-18 14:00:29 +05:00
bc979c51c7 packages/server: Fix ormconfig.js 2019-03-18 13:57:41 +05:00
428630072c Fix (hopefully) CSRF for SPA 2019-03-17 15:04:15 +05:00
0c7af3538c Move LoginRoutes from /app to /api 2019-03-17 14:24:09 +05:00
491012a815 Update TypeScript to 3.3.3333
TODO: Remove cast this.router to any
2019-03-17 13:43:47 +05:00
360dc83ded Setup simple SSR, untested 2019-03-14 12:38:34 +05:00
949b008208 Update jest to 24 and set maxConcurrency 2019-03-14 12:08:37 +05:00
6ea422f340 Fix running jest from root directory 2019-03-13 22:19:51 +05:00
2fb77382c9 Log config files read 2019-03-13 22:18:58 +05:00
6d926894db Fix broken tests in new project 2019-03-13 11:53:42 +05:00
36c61646ed Fix UserService.test.ts 2019-03-13 11:33:02 +05:00
155c98d000 Extract comments functionality to packages/comments-server 2019-03-13 11:24:08 +05:00
2fc22f05b7 Add comments-server 2019-03-12 22:42:14 +05:00
0a7442a932 Replace node-config with packages/server/config 2019-03-12 17:09:21 +05:00
a5ef6bd981 Add ConfigReader.ts 2019-03-12 17:04:42 +05:00