diff --git a/.eslintrc b/.eslintrc index 48848e5..e57cceb 100644 --- a/.eslintrc +++ b/.eslintrc @@ -73,6 +73,7 @@ "no-nested-ternary": 0, "no-unmodified-loop-condition": 0, "no-unused-vars": 1, + "no-useless-escape": 0, "object-curly-spacing": [2, "always"], "operator-linebreak": [2, "after"], "quotes": [2, "single"], @@ -80,6 +81,7 @@ "space-before-function-paren": 2, "strict": 0, "eol-last": ["error", "always"], + "@typescript-eslint/require-await": 0, "@typescript-eslint/restrict-plus-operands": 0, "@typescript-eslint/restrict-template-expressions": 0, "jsdoc/check-alignment": 1, diff --git a/package.json b/package.json index 3549372..2e69797 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "private": true, - "version": "0.0.1-dev", + "version": "0.0.1-repository", "name": "@highcharts/connectors-morningstar", "license": "UNLICENSED", "description": "Highcharts connectors for Morningstar Direct Web Services", @@ -42,11 +42,16 @@ "highcharts": ">=11.4.0" }, "scripts": { + "api": "npm run webpack && npm run api:server", + "api:server": "(sleep 1 ; open http://localhost:8005) & node bin/connectors-morningstar api", "build": "npm run webpack && npm run build:prepare && npm run build:copy && npm run build:pack && npm run build:cleanup", "build:cleanup": "rm -rf build/package/", - "build:copy": "cp -R bin code/* demos LICENSE.md README.md build/package/ && cp -R docs/connectors/ build/package/docs/ && cp package-build.json build/package/package.json", + "build:copy": "npm run copy:code && npm run copy:docs && npm run copy:json", "build:pack": "npm pack build/package/ --pack-destination build/", "build:prepare": "rm -rf build/ ; mkdir -p build/package/", + "copy:code": "cp -R bin code/* demos LICENSE.md README.md build/package/", + "copy:docs": "cp -R docs/connectors/ build/package/docs/", + "copy:json": "cp package-build.json build/package/package.json", "demos": "npm run webpack && npm run demos:server", "demos:server": "(sleep 1 ; open http://localhost:8080) & node bin/connectors-morningstar demos", "docs": "npm run webpack && npm run docs:server", @@ -55,8 +60,8 @@ "husky:pre-commit": "npx lint-staged && npm run webpack", "prepare": "rm -rf '.husky/_' ; husky", "scripts": "npm run scripts:bin && npm run scripts:code", - "scripts:bin": "rm -rf bin/ ; tsc -p src/CLI/ ; chmod +x bin/*.js", - "scripts:code": "rm -rf code/ ; tsc -p src/", + "scripts:bin": "rm -rf bin/ && tsc -p src/CLI/ && chmod +x bin/*.js && cp -R src/CLI/Static bin/ && ts-node tools/api", + "scripts:code": "rm -rf code/ && tsc -p src/", "reset": "rm -rf bin/ build/ code/ node_modules/ ; npm i", "test": "npm run webpack && npm run test:eslint && npm run test:tests", "test:eslint": "eslint .", @@ -64,7 +69,7 @@ "test:tests": "ts-node tools/tests", "watch": "tsc -p src/ -w", "webpack": "npm run scripts && webpack && npm run webpack:dts", - "webpack:dts": "npm run webpack:dts:cm && npm run webpack:dts:dbm && npm run webpack:dts:dgm && npm run webpack:dts:hcm", + "webpack:dts": "npm run webpack:dts:cm", "webpack:dts:cm": "cp src/webpack.d.ts code/connectors-morningstar.d.ts && cp src/webpack.d.ts code/connectors-morningstar.src.d.ts", "webpack:dts:dbm": "cp src/webpack.d.ts code/dashboards-morningstar.d.ts && cp src/webpack.d.ts code/dashboards-morningstar.src.d.ts", "webpack:dts:dgm": "cp src/webpack.d.ts code/datagrid-morningstar.d.ts && cp src/webpack.d.ts code/datagrid-morningstar.src.d.ts", diff --git a/src/.eslintrc b/src/.eslintrc index 36ce5c4..6dc304d 100644 --- a/src/.eslintrc +++ b/src/.eslintrc @@ -69,6 +69,7 @@ "valid-jsdoc": 0, "eol-last": ["error", "always"], "@typescript-eslint/array-type": 0, + "@typescript-eslint/require-await": 0, "@typescript-eslint/explicit-function-return-type": 0, // covered by TypeScript "@typescript-eslint/indent": [ "error", diff --git a/src/CLI/Library/APIServer.ts b/src/CLI/Library/APIServer.ts new file mode 100644 index 0000000..9e281e7 --- /dev/null +++ b/src/CLI/Library/APIServer.ts @@ -0,0 +1,560 @@ +/* * + * + * (c) 2009-2024 Highsoft AS + * + * License: www.highcharts.com/license + * + * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!! + * + * Authors: + * - Sophie Bremer + * + * */ + + +/* * + * + * Imports + * + * */ + + +import * as FS from 'node:fs/promises'; +import * as FSS from 'node:fs'; +import * as HTTP from 'node:http'; +import * as Marked from 'marked'; +import * as Path from 'node:path'; +import * as PPath from 'node:path/posix'; + +import APITemplate from './APITemplate'; +import Database from './Database'; +import Server, { MIME_TYPES } from './Server'; + + +/* * + * + * Declarations + * + * */ + + +export interface Context extends Record { + name: string; + node: Option; + side: Option; + platform: string; + productName: string; + toc: Record; + version?: string; + year?: number; +} + + +export interface ContextTOCItem extends Record { + displayName: string; +} + + +export interface Nav { + children?: Array