(作業中) RoutingControllersのCurrentUserをテンプレートでレンダリングできるようにしたい


`@CurrentUser`デコレータの実装を確認する

https://github.com/typestack/routing-controllers/blob/4a56d176db77bc081dfcd3d8550e8433b5bc476e/src/ActionParameterHandler.ts

```ts:ActionParameterHandler.ts
    protected handleValue(value: any, action: Action, param: ParamMetadata): Promise<any>|any {
:
        // if its current-user decorator then get its value
        if (param.type === "current-user") {
            if (!this.driver.currentUserChecker)
                throw new CurrentUserCheckerNotDefinedError();

            value = this.driver.currentUserChecker(action);
        }
        if (param.required) {
            const isValueEmpty = value === null || value === undefined || value === "";
            const isValueEmptyObject = value instanceof Object && Object.keys(value).length === 0;
:
            } else if (param.type === "current-user") { // current user has a special check as well

                if (isPromiseLike(value)) {
                    return value.then(currentUser => {
                        if (!currentUser)
                            return Promise.reject(new AuthorizationRequiredError(action));

                        return currentUser;
                    });

                } else {
                    if (!value)
                        return Promise.reject(new AuthorizationRequiredError(action));
                }

            }
:
        }

        return value;
```

```ts:ActionParameterHandler.ts
    handle(action: Action, param: ParamMetadata): Promise<any>|any {

        if (param.type === "request")
            return action.request;

        if (param.type === "response")
            return action.response;

        if (param.type === "context")
            return action.context;

        // get parameter value from request and normalize it
        const value = this.normalizeParamValue(this.driver.getParamFromRequest(action, param), param);
        if (isPromiseLike(value))
            return value.then(value => this.handleValue(value, action, param));

        return this.handleValue(value, action, param);
    }
```

```ts:RoutingController.ts
    protected executeAction(actionMetadata: ActionMetadata, action: Action, interceptorFns: Function[]) {

        // compute all parameters
        const paramsPromises = actionMetadata.params
            .sort((param1, param2) => param1.index - param2.index)
            .map(param => this.parameterHandler.handle(action, param));

        // after all parameters are computed
        return Promise.all(paramsPromises).then(params => {

            // execute action and handle result
            const allParams = actionMetadata.appendParams ? actionMetadata.appendParams(action).concat(params) : params;
            const result = actionMetadata.methodOverride ? actionMetadata.methodOverride(actionMetadata, action, allParams) : actionMetadata.callMethod(allParams);
            return this.handleCallMethodResult(result, actionMetadata, action, interceptorFns);

        }).catch(error => {

            // otherwise simply handle error without action execution
            return this.driver.handleError(error, actionMetadata, action);
        });
    }
```

この`allParams`がどこかに引き渡されてたらいい
ただ上記の`executeAction`を見る限り`actionMetadata.methodOverride`か`actionMetadata.callMethod`にしか渡されていない


```ts
const result = actionMetadata.methodOverride 
? actionMetadata.methodOverride(actionMetadata, action, allParams)
 : actionMetadata.callMethod(allParams);
```

方針をかえる

```ts:ActionParameterHandler.ts
    protected handleValue(value: any, action: Action, param: ParamMetadata): Promise<any>|any {
:
this.driver.currentUserChecker(action);
```

ということは

`currentUserChecker`から呼び出されるフック内で`request`に書き込むという方針はいかがであろうか？

---

作業中