Compare commits
6 Commits
16e7cf5109
...
29cc14c7e5
Author | SHA1 | Date |
---|---|---|
williamlardier | 29cc14c7e5 | |
williamlardier | 11cd9ed40e | |
williamlardier | b080ddd542 | |
williamlardier | f4a7c3a968 | |
williamlardier | ce3264dd63 | |
williamlardier | e5c2fa6cdb |
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es2021": true
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
"ignorePatterns": ["build/**/*.js", "build/**/*.d.ts"],
|
||||
"overrides": [
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": "latest",
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"rules": {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
name: release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: 'Tag to be released'
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
verify-release:
|
||||
name: Verify if tag is valid
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout CTST repository
|
||||
uses: 'actions/checkout@v3'
|
||||
with:
|
||||
ref: ${{ github.ref }}
|
||||
|
||||
- name: Fetch tags
|
||||
run: git fetch --tags
|
||||
|
||||
- name: 'Check if tag was already created'
|
||||
shell: bash
|
||||
run: >
|
||||
git show-ref --tags v${{ github.event.inputs.tag }} --quiet \
|
||||
&& exit 1 || exit 0
|
||||
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- verify-release
|
||||
steps:
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
name: Release ${{ github.event.inputs.tag }}
|
||||
tag_name: v${{ github.event.inputs.tag }}
|
||||
generate_release_notes: true
|
||||
target_commitish: ${{ github.sha }}
|
|
@ -0,0 +1,36 @@
|
|||
name: Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master/**'
|
||||
- 'feature/**'
|
||||
- 'documentation/**'
|
||||
- 'improvement/**'
|
||||
- 'bugfix/**'
|
||||
- 'w/**'
|
||||
- 'q/**'
|
||||
- 'hotfix/**'
|
||||
- 'task/**'
|
||||
- 'release/**'
|
||||
- 'main'
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Install deps
|
||||
run: sudo apt-get update -q
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '16'
|
||||
- name: Install Yarn
|
||||
run: npm install -g yarn
|
||||
- name: install dependencies
|
||||
run: yarn install --frozen-lockfile
|
||||
- name: run lint
|
||||
run: yarn run eslint
|
||||
- name: run build
|
||||
run: yarn build
|
|
@ -0,0 +1,68 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Typescript v1 declaration files
|
||||
typings/
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
|
||||
#reports
|
||||
reports/*.html
|
||||
reports/*.json
|
||||
|
||||
#build
|
||||
build
|
||||
|
||||
#local files
|
||||
*.loc
|
|
@ -0,0 +1,2 @@
|
|||
# Ignore artifacts:
|
||||
build
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"arrowParens": "avoid",
|
||||
"bracketSpacing": true,
|
||||
"endOfLine": "auto",
|
||||
"printWidth": 120,
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"tabWidth": 4,
|
||||
"trailingComma": "all",
|
||||
"useTabs": false
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
import httpAgent from "./lib/http-agent";
|
||||
import httpsAgent from "./lib/https-agent";
|
||||
|
||||
export const http = {
|
||||
Agent: httpAgent,
|
||||
};
|
||||
|
||||
export const https = {
|
||||
Agent: httpsAgent,
|
||||
};
|
|
@ -0,0 +1,6 @@
|
|||
export default interface clientConfigurationDefault {
|
||||
/**
|
||||
* Maximum Socket Number: true if TCP session reuse must be enabled
|
||||
*/
|
||||
maxSockets?: boolean;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
import * as http from 'http';
|
||||
import clientConfigurationDefault from './config/default';
|
||||
|
||||
/**
|
||||
* @class ClientHttp
|
||||
* Abstracts the native http.Agent class to enforce common
|
||||
* networking configuration across components.
|
||||
*/
|
||||
export default class ClientHttp extends http.Agent {
|
||||
/**
|
||||
* The maximum socket configuration defaults to 50.
|
||||
*/
|
||||
private static maxSocketsConfiguration = Number(process.env.MAX_SOCKETS) || 50;
|
||||
|
||||
/**
|
||||
* Constructor for the ClientHttp class
|
||||
*
|
||||
* @param opts - Custom HTTP Agent options
|
||||
* @param config - user-defined default configuration du apply
|
||||
*/
|
||||
constructor(
|
||||
opts?: http.AgentOptions,
|
||||
config: clientConfigurationDefault = {
|
||||
maxSockets: true,
|
||||
},
|
||||
) {
|
||||
// Enforce TCP session reuse configuration, unless explicitely specified.
|
||||
const defaultConfigurations: http.AgentOptions = {};
|
||||
if (config.maxSockets) {
|
||||
defaultConfigurations.keepAlive = true;
|
||||
defaultConfigurations.maxSockets = ClientHttp.maxSocketsConfiguration;
|
||||
defaultConfigurations.maxFreeSockets = ClientHttp.maxSocketsConfiguration;
|
||||
}
|
||||
super({
|
||||
...opts,
|
||||
...defaultConfigurations,
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
import * as https from 'https';
|
||||
import clientConfigurationDefault from './config/default';
|
||||
|
||||
/**
|
||||
* @class ClientHttps
|
||||
* Abstracts the native https.Agent class to enforce common
|
||||
* networking configuration across components.
|
||||
*/
|
||||
export default class ClientHttps extends https.Agent {
|
||||
/**
|
||||
* The maximum socket configuration defaults to 50.
|
||||
*/
|
||||
private static maxSocketsConfiguration = Number(process.env.MAX_SOCKETS) || 50;
|
||||
|
||||
/**
|
||||
* Constructor for the ClientHttps class
|
||||
*
|
||||
* @param opts - Custom HTTPs Agent options
|
||||
* @param config - user-defined default configuration du apply
|
||||
*/
|
||||
constructor(
|
||||
opts?: https.AgentOptions,
|
||||
config: clientConfigurationDefault = {
|
||||
maxSockets: true,
|
||||
},
|
||||
) {
|
||||
// Enforce TCP session reuse configuration, unless explicitely specified.
|
||||
const defaultConfigurations: https.AgentOptions = {};
|
||||
if (config.maxSockets) {
|
||||
defaultConfigurations.keepAlive = true;
|
||||
defaultConfigurations.maxSockets = ClientHttps.maxSocketsConfiguration;
|
||||
defaultConfigurations.maxFreeSockets = ClientHttps.maxSocketsConfiguration;
|
||||
}
|
||||
super({
|
||||
...opts,
|
||||
...defaultConfigurations,
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"name": "arsenal-networking",
|
||||
"version": "1.0.0",
|
||||
"description": "A utility library for networking",
|
||||
"main": "build/index.js",
|
||||
"repository": "git@github.com:scality/arsenal-networking.git",
|
||||
"author": "Scality Inc.",
|
||||
"license": "Apache-2.0",
|
||||
"scripts": {
|
||||
"build": "tsc --build tsconfig.json",
|
||||
"format": "prettier --write \"**/*.{ts,tsx,css,html}\" ",
|
||||
"prepare": "yarn build || true",
|
||||
"eslint": "eslint ./ --ext .js,.ts,.tsx",
|
||||
"eslint-fix": "eslint ./ --ext .js,.ts,.tsx --fix",
|
||||
"eslint-init": "eslint --init",
|
||||
"lint": "eslint ./ --ext .js,.ts,.tsx --format visualstudio --no-color --max-warnings 10 --report-unused-disable-directives"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/node": "^18.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^5.44.0",
|
||||
"@typescript-eslint/parser": "^5.44.0",
|
||||
"eslint": "^8.28.0",
|
||||
"eslint-config-airbnb-base": "^15.0.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-config-scality": "git+https://github.com/scality/Guidelines#8.2.0",
|
||||
"eslint-plugin-import": "^2.26.0",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"prettier": "^2.8.0",
|
||||
"typescript": "^4.9.3"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"module": "commonjs",
|
||||
"rootDir": "./",
|
||||
"resolveJsonModule": true,
|
||||
"allowJs": true,
|
||||
"checkJs": false,
|
||||
"outDir": "build",
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"declaration": true,
|
||||
"noImplicitAny": false,
|
||||
"noEmitOnError": false,
|
||||
"sourceMap": true,
|
||||
"declarationMap": true
|
||||
},
|
||||
"include": ["index.ts", "lib"],
|
||||
"exclude": ["node_modules/*"],
|
||||
"compileOnSave": true
|
||||
}
|
Loading…
Reference in New Issue