Skip to content

Commit

Permalink
add api-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Mineev authored and paskal committed Jul 22, 2022
1 parent 2178321 commit 2e8644c
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 15 deletions.
2 changes: 2 additions & 0 deletions frontend/packages/api/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
coverage
32 changes: 32 additions & 0 deletions frontend/packages/api/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = {
overrides: [
{
files: ['**/*.ts'],
env: {
browser: true,
es2021: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json'],
},
plugins: ['@typescript-eslint'],
},
{
files: ['**/*.{js,cjx}'],
parser: 'espree',
extends: ['eslint:recommended', 'prettier'],
env: {
node: true,
},
},
],
}
1 change: 0 additions & 1 deletion frontend/packages/api/dist/index.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion frontend/packages/api/dist/index.js

This file was deleted.

9 changes: 4 additions & 5 deletions frontend/packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,17 @@
"author": "Paul Mineev",
"license": "MIT",
"scripts": {
"dev": "tsc -w -p tsconfig.dev.json",
"build": "tsc",
"prebuild": "rm -rf dist",
"dev": "tsc -w --incremental",
"build": "rm -rf dist && tsc",
"prepublish": "./prepublish.sh",
"postpublish": "./postpublish.sh",
"test": "jest",
"coverage": "jest --coverage",
"lint": "eslint src --ext=.ts,.js",
"lint": "eslint --ext=.ts,.js,.cjs ./",
"type-check": "tsc --noEmit",
"format": "prettier --write '**/*.{ts,js,json}'",
"lint-staged:format": "prettier --write",
"lint-staged:lint": "eslint --fix"
"lint-staged:lint": "eslint --ext=.ts,.js,.cjs --fix"
},
"devDependencies": {
"@swc/core": "^1.2.215",
Expand Down
2 changes: 1 addition & 1 deletion frontend/packages/api/src/lib/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const createFetcher = (site: string, baseUrl: string): Client => {
// An HTTP header cannot be empty.
// Although some webservers allow this (nginx, Apache), others answer 400 Bad Request (lighttpd).
const xsrfToken = getCookie(XSRF_COOKIE)
if (xsrfToken !== undefined) {
if (typeof xsrfToken === 'string') {
headers.set(XSRF_HEADER, xsrfToken)
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/packages/api/test/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function mockEndpoint(
url: string,
params: {
method?: 'get' | 'put' | 'post' | 'delete'
body?: string | Record<string, unknown> | unknown[]
body?: number | string | null | Record<string, unknown> | unknown[]
status?: number
headers?: Record<string, string | string[]>
} = {}
Expand Down
14 changes: 8 additions & 6 deletions frontend/packages/api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* Visit https://aka.ms/tsconfig to read more about this file */

/* Projects */
"incremental": true /* Save .tsbuildinfo files to allow for incremental compilation of projects. */,
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
Expand Down Expand Up @@ -43,8 +43,8 @@
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */

/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "allowJs": true /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */,
// "checkJs": true /* Enable error reporting in type-checked JavaScript files. */,
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */

/* Emit */
Expand All @@ -53,7 +53,7 @@
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
// "outDir": "./", /* Specify an output folder for all emitted files. */
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
Expand All @@ -69,7 +69,7 @@
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
"declarationDir": "./dist/types" /* Specify the output directory for generated declaration files. */,
// "declarationDir": "./" /* Specify the output directory for generated declaration files. */,
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */

/* Interop Constraints */
Expand Down Expand Up @@ -103,5 +103,7 @@
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
},
"include": ["src/**/*.ts"],
"exclude": ["tests/**", "coverage/**", "dist/**", "**/*.spec.ts"]
}

0 comments on commit 2e8644c

Please sign in to comment.