Skip to content

Commit

Permalink
Merge pull request #4 from ty-ras/issue/2-add-code
Browse files Browse the repository at this point in the history
Issue/2 add code
  • Loading branch information
stazz authored Sep 8, 2023
2 parents 5c93bd8 + 11b71e2 commit e8d6a80
Show file tree
Hide file tree
Showing 20 changed files with 4,197 additions and 0 deletions.
16 changes: 16 additions & 0 deletions code/.c8rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"all": true,
"include": [
"src/**/*.ts"
],
"exclude": [
"src/**/__test__/**/*.*",
"**/*.d.ts",
"**/*.types.ts",
"src/index.ts"
],
"reporter": [
"text",
"json"
]
}
61 changes: 61 additions & 0 deletions code/.eslintrc.library.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// ESLint config for formatting the <project name>/src/**/*.ts files.
module.exports = {
root: true,
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:type-only-import/recommended",
"plugin:jsdoc/recommended-typescript-error",
"plugin:prettier/recommended",
"plugin:sonarjs/recommended"
],
plugins: [
"type-only-import",
"jsdoc",
"prettier"
],
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.json",
sourceType: "module",
ecmaVersion: "latest",
tsconfigRootDir: __dirname,
},
rules: {
"prettier/prettier": "error",
//"function-paren-newline": ["error", "always"],
"@typescript-eslint/explicit-module-boundary-types": "off", // IDE will show the return types
"@typescript-eslint/restrict-template-expressions": "off", // We are OK with whatever type within template expressions
"@typescript-eslint/unbound-method": "off", // We never use 'this' within functions anyways.
"@typescript-eslint/no-empty-function": "off", // Empty functions are ok sometimes.
"no-useless-return": "error",
"no-console": "error",
"sonarjs/no-nested-template-literals": "off", // Nested template literals are OK really
"jsdoc/require-file-overview": "error",
"jsdoc/require-jsdoc": [
"error",
{
"publicOnly": true,
"require": {
"ArrowFunctionExpression": true,
"ClassDeclaration": true,
"ClassExpression": true,
"FunctionDeclaration": true,
"FunctionExpression": true,
"MethodDefinition": true
},
"exemptEmptyConstructors": true,
"exemptEmptyFunctions": false,
"enableFixer": false,
"contexts": [
"TSInterfaceDeclaration",
"TSTypeAliasDeclaration",
"TSMethodSignature",
"TSPropertySignature"
]
}
]
}
};
17 changes: 17 additions & 0 deletions code/.eslintrc.out-ts.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ESLint config for formatting the resulting .d.ts files (<project name>/dist-ts/**/*.d.ts) that end up in NPM package for typing information.
const { extends: extendsArray, plugins, rules } = require("./.eslintrc.cjs");
module.exports = {
root: true,
extends: extendsArray.filter((ext) => ext.startsWith("plugin:jsdoc/") || ext.startsWith("plugin:prettier/")),
plugins: plugins.filter((plugin) => plugin === "jsdoc" || plugin === "prettier"),
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.out.json",
sourceType: "module",
ecmaVersion: "latest",
tsconfigRootDir: __dirname,
},
rules: Object.fromEntries(Object.entries(rules).filter(([ruleKey]) => ruleKey.startsWith("jsdoc/") || ruleKey.startsWith("prettier/"))),
// So we won't get errors on comments disable e.g. @typescript-eslint/xyz rules.
noInlineConfig: true,
};
19 changes: 19 additions & 0 deletions code/.eslintrc.out.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// ESLint config for formatting the resulting .[m]js files (<project name>/dist-(cjs|mjs)/**/*.[m]js) that end up in NPM package.
module.exports = {
root: true,
extends: [
"plugin:path-import-extension/recommended",
"plugin:prettier/recommended",
],
plugins: [
"path-import-extension",
"prettier"
],
parser: "@babel/eslint-parser",
parserOptions: {
requireConfigFile: false
},
rules: {
"prettier/prettier": "error",
}
};
7 changes: 7 additions & 0 deletions code/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
build
dist*
coverage
*/.eslintrc*.cjs
*/tsconfig*.json
yarn-error.log
6 changes: 6 additions & 0 deletions code/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"printWidth": 80,
"trailingComma": "all",
"tabWidth": 2,
"useTabs": false
}
18 changes: 18 additions & 0 deletions code/ava.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default {
cache: false, // We run Ava in non-coverage mode with 'ro' modifier for Docker volume
extensions: {
ts: "module"
},
nodeArguments: [
"--loader=ts-node/esm",
"--experimental-specifier-resolution=node",
"--trace-warnings"
],
files: [
"**/__test__/*.spec.ts"
],
timeout: "10m",
verbose: true,
// The default is number of corse, which in CI I guess is 1
concurrency: 5
}
5 changes: 5 additions & 0 deletions code/client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Typesafe REST API Specification - Typesafe Client With Axios

[![Coverage](https://codecov.io/gh/ty-ras/client-axios/branch/main/graph/badge.svg?flag=client)](https://codecov.io/gh/ty-ras/client-axios)

This folder contains library which exposes a method to create callback implementing `CallHTTPEndpoint` from [`@ty-ras/data-frontent`](https://github.com/ty-ras/data) using [Axios library](https://github.com/axios/axios).
85 changes: 85 additions & 0 deletions code/client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"name": "@ty-ras/client-axios",
"version": "2.0.0",
"author": {
"name": "Stanislav Muhametsin",
"email": "[email protected]",
"url": "https://github.com/stazz"
},
"description": "TyRAS library implementing type-based HTTP endpoint invocation using Axios.",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/ty-ras/client-axios"
},
"files": [
"./src",
"./dist-ts",
"./dist-esm",
"./dist-cjs",
"README.md",
"LICENSE.txt"
],
"type": "module",
"main": "./dist-cjs/index.js",
"module": "./dist-esm/index.js",
"types": "./dist-ts/index.d.ts",
"exports": {
".": {
"types": "./dist-ts/index.d.ts",
"import": "./dist-esm/index.js",
"require": "./dist-cjs/index.js"
}
},
"dependencies": {
"@ty-ras/data-frontend": "^2.0.1"
},
"peerDependencies": {
"axios": "^1.5.0"
},
"devDependencies": {
"@ava/get-port": "2.0.0",
"@babel/core": "7.22.11",
"@babel/eslint-parser": "7.22.11",
"@typescript-eslint/eslint-plugin": "6.5.0",
"@typescript-eslint/parser": "6.5.0",
"@types/node": "18.16.3",
"ava": "5.3.1",
"axios": "1.5.0",
"c8": "8.0.1",
"eslint": "8.48.0",
"eslint-plugin-jsdoc": "46.5.0",
"eslint-plugin-path-import-extension": "0.9.0",
"eslint-plugin-type-only-import": "0.9.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-prettier": "5.0.0",
"eslint-plugin-sonarjs": "0.21.0",
"madge": "6.1.0",
"prettier": "3.0.2",
"ts-node": "10.9.1",
"typescript": "5.1.6"
},
"scripts": {
"build:run": "yarn run lint && yarn run tsc",
"build:ci": "yarn run clear-build-artifacts && yarn run compile-d-ts-files && yarn run tsc --outDir ./dist-esm && yarn run tsc --module CommonJS --outDir ./dist-cjs && yarn run remove-empty-js-files && yarn run generate-stub-package-json-for-cjs && yarn run format-output-files",
"clear-build-artifacts": "rm -rf dist dist-ts dist-cjs dist-esm build",
"compile-d-ts-files": "yarn run tsc --removeComments false --emitDeclarationOnly --declaration --declarationDir ./dist-ts && yarn run tsc:plain --project tsconfig.out.json",
"format-output-files": "yarn run format-output-files-ts && yarn run format-output-files-js",
"format-output-files-ts": "eslint --no-eslintrc --config '.eslintrc.out-ts.cjs' --fix --fix-type layout './dist-ts/**/*.ts'",
"format-output-files-js": "eslint --no-eslintrc --config '.eslintrc.out.cjs' --fix 'dist-cjs/**/*js' 'dist-esm/**/*js'",
"generate-stub-package-json-for-cjs": "../../scripts/generate-stub-package-json.cjs",
"lint": "yarn run lint:eslint && yarn run lint:circular",
"lint:circular": "madge --circular --no-color --no-spinner --extensions ts --warning ./src",
"lint:eslint": "eslint ./src --ext .ts,.tsx",
"remove-empty-js-files": "../../scripts/remove-empty-js-files.cjs",
"tsc": "tsc --project tsconfig.build.json",
"tsc:plain": "tsc",
"test:coverage": "c8 --temp-directory /tmp ava",
"test:run": "c8 --temp-directory /tmp --reporter text ava"
},
"resolutions": {
"dependency-tree": "10.0.9",
"precinct": "11.0.5",
"typescript": "5.1.6"
}
}
Loading

0 comments on commit e8d6a80

Please sign in to comment.