Skip to content

Commit

Permalink
Make HttpRequestOptions accept 'headers' parameter when Axios request.
Browse files Browse the repository at this point in the history
  • Loading branch information
sjiang-cb committed Nov 14, 2024
1 parent a55c551 commit 14f0cda
Show file tree
Hide file tree
Showing 11 changed files with 5,228 additions and 6,116 deletions.
32 changes: 16 additions & 16 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
pre-process:
name: Pre process
runs-on: ubuntu-latest
outputs:
outputs:
were-only-docs-updated: ${{ steps.were-only-docs-updated-action.outputs.were-only-docs-updated }}
steps:
- name: Checkout code
Expand All @@ -38,7 +38,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 2.
fetch-depth: 2.
- name: Get commit range
id: get-commit-range-action
uses: ./.github/actions/get-commit-range-action
Expand Down Expand Up @@ -86,50 +86,50 @@ jobs:
security-events: write
strategy:
matrix:
node-version: [10.x]
node-version: [14.x]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Create cache folder
run: |
mkdir -p /home/runner/.npm
continue-on-error: true
continue-on-error: true
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache: 'npm'
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: javascript
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2

codacy-analysis-cli:
name: Codacy Analysis CLI
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@main
- name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@master
uses: codacy/codacy-analysis-cli-action@master

Check warning

Code scanning / Semgrep (reported by Codacy)

An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Warning

An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release.
with:
output: results.sarif
format: sarif
# Adjust severity of non-security issues
gh-code-scanning-compat: true
# Force 0 exit code to allow SARIF file generation
# This will handover control about PR rejection to the GitHub side
max-allowed-issues: 2147483647
# Upload the SARIF file generated in the previous step
max-allowed-issues: 2147483647
# Upload the SARIF file generated in the previous step
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@main
with:
sarif_file: results.sarif

smoke-test:
name: Smoke Test
runs-on: ubuntu-latest
Expand All @@ -141,19 +141,19 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up JDK 8
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '8'
java-version: '17'
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Smoke Test
run: |
TZ='Asia/Shanghai'; export TZ
TZ='Asia/Shanghai'; export TZ
mkdir -p g11n-js-client
shopt -s extglob
mv !(g11n-js-client) g11n-js-client/
Expand Down
11,230 changes: 5,160 additions & 6,070 deletions package-lock.json

Large diffs are not rendered by default.

21 changes: 14 additions & 7 deletions package.client.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@singleton-i18n/js-core-sdk",
"version": "0.5.7",
"version": "0.5.8",
"publishConfig": {
"registry": ""
},
Expand Down Expand Up @@ -42,18 +42,25 @@
"@types/node": "^10.11.7",
"awesome-typescript-loader": "^5.2.1",
"axios": "^0.21.1",
"jest": "^24.5.0",
"ts-jest": "^24.0.0",
"jest": "^29.7.0",
"ts-jest": "^29.2.5",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"tslint-loader": "^3.5.4",
"typescript": "^4.4.4",
"typescript-loader": "^1.1.3",
"typings": "^2.1.1",
"webpack": "^4.20.2",
"webpack-cli": "^3.3.0"
"webpack": "^5.96.1",
"webpack-cli": "^5.1.4"
},
"changelogHistory": [
{
"date": "11/15/24",
"version": "0.5.8",
"notes": [
{
"description": "Make HttpRequestOptions accept 'headers' parameter when Axios request."
}
]
},
{
"date": "06/05/23",
"version": "0.5.7",
Expand Down
21 changes: 14 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@singleton-i18n/js-core-sdk-server",
"version": "0.5.7",
"version": "0.5.8",
"publishConfig": {
"registry": ""
},
Expand Down Expand Up @@ -42,18 +42,25 @@
"@types/node": "^10.11.7",
"awesome-typescript-loader": "^5.2.1",
"axios": "^0.21.1",
"jest": "^24.5.0",
"ts-jest": "^24.0.0",
"jest": "^29.7.0",
"ts-jest": "^29.2.5",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"tslint-loader": "^3.5.4",
"typescript": "^4.4.4",
"typescript-loader": "^1.1.3",
"typings": "^2.1.1",
"webpack": "^4.20.2",
"webpack-cli": "^3.3.0"
"webpack": "^5.96.1",
"webpack-cli": "^5.1.4"
},
"changelogHistory": [
{
"date": "11/15/24",
"version": "0.5.8",
"notes": [
{
"description": "Make HttpRequestOptions accept 'headers' parameter when Axios request."
}
]
},
{
"date": "06/05/23",
"version": "0.5.7",
Expand Down
8 changes: 4 additions & 4 deletions samples/client/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"load-translation": "load-translation --directory `pwd`/src/sources --product CoreSDKClient --component ui --host http://localhost:8091 --version 1.0 --languages zh,en"
},
"dependencies": {
"@singleton-i18n/js-core-sdk": "file:../../../singleton-i18n-js-core-sdk-0.5.7.tgz",
"@singleton-i18n/js-core-sdk": "file:../../../singleton-i18n-js-core-sdk-0.5.8.tgz",

Check notice

Code scanning / Tslint (reported by Codacy)

" should be ' Note

" should be '
"argparse": "^1.0.10",
"axios": "^0.21.1",
"typescript": "^4.4.4"
Expand All @@ -21,8 +21,8 @@
"copy-webpack-plugin": "^5.0.4",
"express": "^4.17.1",
"express-rate-limit": "^6.7.0",
"jest": "^24.9.0",
"webpack": "^4.39.1",
"webpack-cli": "^3.3.6"
"jest": "^29.7.0",

Check notice

Code scanning / Tslint (reported by Codacy)

" should be ' Note

" should be '
"webpack": "^5.96.1",

Check notice

Code scanning / Tslint (reported by Codacy)

" should be ' Note

" should be '
"webpack-cli": "^5.1.4"

Check notice

Code scanning / Tslint (reported by Codacy)

" should be ' Note

" should be '
}
}
4 changes: 4 additions & 0 deletions samples/client/js/src/i18n.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export function localize(config) {
// Uncommend if you don't want to load your translation from singleton but from your sources
//i18nAssets: 'src/translations/',
isPseudo: shouldUsePseudoTranslations(),
// It offers the feature to self-custom header for target product
httpOptions: {
headers: {'vrni-header': 'vrni_custom'}
}
}
);
loadAndShowTranslations(i18nClient, config);
Expand Down
2 changes: 1 addition & 1 deletion samples/server/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"collect-source-bundle": "collect-source-bundle --source-dir `pwd`/i18n --product NodeSample --component NodeJS --host http://localhost:8091 --version 1.0"
},
"dependencies": {
"@singleton-i18n/js-core-sdk-server": "file:../../../singleton-i18n-js-core-sdk-server-0.5.7.tgz",
"@singleton-i18n/js-core-sdk-server": "file:../../../singleton-i18n-js-core-sdk-server-0.5.8.tgz",

Check notice

Code scanning / Tslint (reported by Codacy)

" should be ' Note

" should be '
"argparse": "^1.0.10",
"axios": "^0.21.1",
"express": "4.15.3",
Expand Down
4 changes: 2 additions & 2 deletions src/formatters/plural/plural.formatter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2023 VMware, Inc.
* Copyright 2019-2024 VMware, Inc.
* SPDX-License-Identifier: EPL-2.0
*/
import { PLURALFUNCS } from './plurals.func';
Expand All @@ -8,7 +8,7 @@ export class Plural {
constructor() { }
private resolveLocale(locale: string): string {
let lang: string = locale;
do {
do {
if (PLURALFUNCS[lang]) {
return lang;
} else if (PLURALFUNCS[lang.toLocaleLowerCase()]) {
Expand Down
7 changes: 6 additions & 1 deletion src/loader.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 VMware, Inc.
* Copyright 2019-2024 VMware, Inc.
* SPDX-License-Identifier: EPL-2.0
*/
import axios from 'axios';
Expand All @@ -8,6 +8,11 @@ import { basedLogger, Logger } from './logger';
export interface HttpRequestOptions {
timeout?: number;
withCredentials?: boolean;
headers?: HttpHeaders;
}

export interface HttpHeaders {
[key: string]: string;
}

export abstract class Loader {
Expand Down
4 changes: 2 additions & 2 deletions src/services/core.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 VMware, Inc.
* Copyright 2019-2024 VMware, Inc.
* SPDX-License-Identifier: EPL-2.0
*/
import { Loader, HttpRequestOptions } from '../loader';
Expand Down Expand Up @@ -62,7 +62,7 @@ export class CoreService {
* on which some products might rely to handle .then() method
1. language = 'en-US'
2. language = 'en', region = 'US'
3. language = 'en'
3. language = 'en'
*/
return Promise.resolve({});
}
Expand Down
11 changes: 5 additions & 6 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2023 VMware, Inc.
* Copyright 2019-2024 VMware, Inc.
* SPDX-License-Identifier: EPL-2.0
*/
const helpers = require('./config/helpers');
Expand Down Expand Up @@ -44,21 +44,21 @@ module: {
const nodeConfig = {
mode: 'production',
target: 'node',

resolve: {
extensions: ['.ts', '.js']
},

entry: helpers.root('index.ts'),

output: {
path: helpers.root('bundles'),
publicPath: '/',
filename: 'singleton.core.umd.server.js',
library: 'singletoncore',
libraryTarget: 'umd'
},

module: {
rules: [{
enforce: 'pre',
Expand All @@ -77,4 +77,3 @@ const nodeConfig = {
};

module.exports = [ webConfig, nodeConfig ];

0 comments on commit 14f0cda

Please sign in to comment.