OPS-235: Proxy + PHP currency (#94)

This commit is contained in:
Rinat Arsaev 2022-12-12 17:31:27 +06:00 committed by GitHub
parent b8ae56c301
commit 3cc96f0daf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 76 additions and 23 deletions

3
.gitignore vendored
View File

@ -48,5 +48,6 @@ Thumbs.db
# Angular
.angular
# Configs
# Env and configs
.env*
src/*Config*.json

View File

@ -2,17 +2,5 @@
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/build_utils" vcs="Git" />
<mapping directory="$PROJECT_DIR$/schemes/claim-management/v0" vcs="Git" />
<mapping directory="$PROJECT_DIR$/schemes/dark-api/v0" vcs="Git" />
<mapping directory="$PROJECT_DIR$/schemes/messages/v0" vcs="Git" />
<mapping directory="$PROJECT_DIR$/schemes/organizations/v0" vcs="Git" />
<mapping directory="$PROJECT_DIR$/schemes/questionary-aggr-proxy/v0" vcs="Git" />
<mapping directory="$PROJECT_DIR$/schemes/questionary/v0" vcs="Git" />
<mapping directory="$PROJECT_DIR$/schemes/sender/v0" vcs="Git" />
<mapping directory="$PROJECT_DIR$/schemes/swag-analytics/v1" vcs="Git" />
<mapping directory="$PROJECT_DIR$/schemes/swag-wallets/v0" vcs="Git" />
<mapping directory="$PROJECT_DIR$/schemes/swag/v2" vcs="Git" />
<mapping directory="$PROJECT_DIR$/schemes/url-shortener/v0" vcs="Git" />
</component>
</project>

1
_.env Normal file
View File

@ -0,0 +1 @@
PROXY_TARGET="https://sample.vality.dev"

30
package-lock.json generated
View File

@ -86,6 +86,7 @@
"@typescript-eslint/eslint-plugin": "5.31.0",
"@typescript-eslint/parser": "5.31.0",
"concurrently": "7.0.0",
"dotenv": "^16.0.3",
"eslint": "8.20.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.26.0",
@ -7755,12 +7756,12 @@
}
},
"node_modules/dotenv": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz",
"integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==",
"version": "16.0.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
"integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==",
"dev": true,
"engines": {
"node": ">=10"
"node": ">=12"
}
},
"node_modules/ecc-jsbn": {
@ -13035,6 +13036,15 @@
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
"node_modules/nx/node_modules/dotenv": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz",
"integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==",
"dev": true,
"engines": {
"node": ">=10"
}
},
"node_modules/nx/node_modules/glob": {
"version": "7.1.4",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz",
@ -23266,9 +23276,9 @@
}
},
"dotenv": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz",
"integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==",
"version": "16.0.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
"integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==",
"dev": true
},
"ecc-jsbn": {
@ -26901,6 +26911,12 @@
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
"dotenv": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz",
"integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==",
"dev": true
},
"glob": {
"version": "7.1.4",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz",

View File

@ -4,8 +4,8 @@
"private": true,
"scripts": {
"postinstall": "ngcc",
"start": "ng serve --port 8000",
"stage": "ng serve --port 8001 --configuration=stage",
"start": "ng serve --proxy-config proxy.conf.js --port 8000",
"stage": "ng serve --proxy-config proxy.conf.js --port 8001 --configuration=stage",
"fix": "npm run lint-fix && npm run prettier-fix",
"build": "ng build --extra-webpack-config webpack.extra.js && npm run transloco:optimize",
"test": "ng test",
@ -104,6 +104,7 @@
"@typescript-eslint/eslint-plugin": "5.31.0",
"@typescript-eslint/parser": "5.31.0",
"concurrently": "7.0.0",
"dotenv": "^16.0.3",
"eslint": "8.20.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.26.0",

32
proxy.conf.js Normal file
View File

@ -0,0 +1,32 @@
const url = require('url');
require('dotenv').config({ path: ['.env', process.env.NODE_ENV].filter(Boolean).join('.') });
const { PROXY_TARGET } = process.env;
const REQUIRED_ENV = [PROXY_TARGET];
if (REQUIRED_ENV.findIndex((e) => !e) !== -1) {
throw new Error('[proxy.conf.js] Set required environment variables!');
}
/**
* http://localhost/__subdomain to https://subdomain.target.com
*/
function createSubdomainByPathProxy(target, subdomainPathPrefix = '__') {
const SUBDOMAIN_PARAM_REGEXP = `^/${subdomainPathPrefix}(?<param>[a-zA-Z0-9-]+)`;
const { host, port, protocol } = url.parse(target);
return {
context: `/${subdomainPathPrefix}*/**`,
target: 'localhost',
router: function (req) {
const param = req.url.match(new RegExp(SUBDOMAIN_PARAM_REGEXP)).groups.param;
return `${protocol}//${param}.${host}${port ? `:${port}` : ''}`;
},
pathRewrite: { [SUBDOMAIN_PARAM_REGEXP]: '' },
secure: false,
logLevel: 'debug',
changeOrigin: true,
};
}
module.exports = [createSubdomainByPathProxy(PROXY_TARGET)];

View File

@ -14,7 +14,21 @@ export class CurrencyAutocompleteFieldComponent extends WrappedFormControlSuperc
@Input() label: string;
@Input() @coerceBoolean required = false;
options: Option<string>[] = ['RUB', 'USD', 'EUR', 'UAH', 'KZT', 'BYN', 'JPY', 'INR', 'AZN', 'BRL', 'BDT', 'TRY']
options: Option<string>[] = [
'RUB',
'USD',
'EUR',
'UAH',
'KZT',
'BYN',
'JPY',
'INR',
'AZN',
'BRL',
'BDT',
'TRY',
'PHP',
]
.sort()
.map((currency) => ({ label: currency, value: currency }));