|
|
@@ -1,4 +1,4 @@
|
|
|
-import { LanguageCode, Permission } from '@vendure/common/lib/generated-types';
|
|
|
+import { CurrencyCode, LanguageCode, Permission } from '@vendure/common/lib/generated-types';
|
|
|
import { ID, JsonCompatible } from '@vendure/common/lib/shared-types';
|
|
|
import { isObject } from '@vendure/common/lib/shared-utils';
|
|
|
import { Request } from 'express';
|
|
|
@@ -43,6 +43,7 @@ export type SerializedRequestContext = {
|
|
|
*/
|
|
|
export class RequestContext {
|
|
|
private readonly _languageCode: LanguageCode;
|
|
|
+ private readonly _currencyCode: CurrencyCode;
|
|
|
private readonly _channel: Channel;
|
|
|
private readonly _session?: CachedSession;
|
|
|
private readonly _isAuthorized: boolean;
|
|
|
@@ -60,16 +61,18 @@ export class RequestContext {
|
|
|
channel: Channel;
|
|
|
session?: CachedSession;
|
|
|
languageCode?: LanguageCode;
|
|
|
+ currencyCode?: CurrencyCode;
|
|
|
isAuthorized: boolean;
|
|
|
authorizedAsOwnerOnly: boolean;
|
|
|
translationFn?: TFunction;
|
|
|
}) {
|
|
|
- const { req, apiType, channel, session, languageCode, translationFn } = options;
|
|
|
+ const { req, apiType, channel, session, languageCode, currencyCode, translationFn } = options;
|
|
|
this._req = req;
|
|
|
this._apiType = apiType;
|
|
|
this._channel = channel;
|
|
|
this._session = session;
|
|
|
this._languageCode = languageCode || (channel && channel.defaultLanguageCode);
|
|
|
+ this._currencyCode = currencyCode || (channel && channel.defaultCurrencyCode);
|
|
|
this._isAuthorized = options.isAuthorized;
|
|
|
this._authorizedAsOwnerOnly = options.authorizedAsOwnerOnly;
|
|
|
this._translationFn = translationFn || (((key: string) => key) as any);
|
|
|
@@ -185,6 +188,10 @@ export class RequestContext {
|
|
|
return this._languageCode;
|
|
|
}
|
|
|
|
|
|
+ get currencyCode(): CurrencyCode {
|
|
|
+ return this._currencyCode;
|
|
|
+ }
|
|
|
+
|
|
|
get session(): CachedSession | undefined {
|
|
|
return this._session;
|
|
|
}
|