From 10a204a176f29cf708b2ebe16dbbef783d124731 Mon Sep 17 00:00:00 2001 From: Alexander Chabin Date: Sun, 3 Dec 2023 23:19:17 +0500 Subject: [PATCH] Move /api to /server --- .gitignore | 2 +- pnpm-lock.yaml | 124 +++++++++--------- {api => server}/.eslintrc.json | 0 {api => server}/controller/index.ts | 0 .../controller/masstrans/masstrans.ts | 0 {api => server}/index.ts | 0 .../ekaterinburg-rf.constants.ts | 0 .../model/ekaterinburg-rf/ekaterinburg-rf.ts | 0 .../ekaterinburg-rf/ekaterinburg-rf.types.ts | 0 {api => server}/model/index.ts | 0 {api => server}/package.json | 0 {api => server}/router/index.ts | 0 {api => server}/router/masstrans.ts | 0 {api => server}/service/index.ts | 0 .../service/masstrans/masstrans.ts | 0 {api => server}/tsconfig.json | 0 server/utils/allow-cross-domain.ts | 6 + .../utils/get-current-timestamp.ts | 0 {api => server}/utils/get-request-token.ts | 0 {api => server}/utils/is-value-in-object.ts | 0 20 files changed, 68 insertions(+), 64 deletions(-) rename {api => server}/.eslintrc.json (100%) rename {api => server}/controller/index.ts (100%) rename {api => server}/controller/masstrans/masstrans.ts (100%) rename {api => server}/index.ts (100%) rename {api => server}/model/ekaterinburg-rf/ekaterinburg-rf.constants.ts (100%) rename {api => server}/model/ekaterinburg-rf/ekaterinburg-rf.ts (100%) rename {api => server}/model/ekaterinburg-rf/ekaterinburg-rf.types.ts (100%) rename {api => server}/model/index.ts (100%) rename {api => server}/package.json (100%) rename {api => server}/router/index.ts (100%) rename {api => server}/router/masstrans.ts (100%) rename {api => server}/service/index.ts (100%) rename {api => server}/service/masstrans/masstrans.ts (100%) rename {api => server}/tsconfig.json (100%) create mode 100644 server/utils/allow-cross-domain.ts rename {api => server}/utils/get-current-timestamp.ts (100%) rename {api => server}/utils/get-request-token.ts (100%) rename {api => server}/utils/is-value-in-object.ts (100%) diff --git a/.gitignore b/.gitignore index bef2ad96..b2529888 100644 --- a/.gitignore +++ b/.gitignore @@ -42,4 +42,4 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts -api/build +server/build diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cc7661f6..da233b50 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -28,49 +28,6 @@ importers: specifier: ^2.8.8 version: 2.8.8 - api: - dependencies: - express: - specifier: ^4.18.2 - version: 4.18.2 - lodash: - specifier: ^4.17.21 - version: 4.17.21 - node-fetch: - specifier: ^2.7.0 - version: 2.7.0(encoding@0.1.13) - transport-common: - specifier: workspace:* - version: link:../common - ts-node: - specifier: ^10.9.1 - version: 10.9.1(@types/node@18.17.15)(typescript@4.9.5) - tslib: - specifier: ^2.6.2 - version: 2.6.2 - typescript: - specifier: ^4.9.5 - version: 4.9.5 - devDependencies: - '@types/express': - specifier: ^4.17.17 - version: 4.17.17 - '@types/js-sha1': - specifier: ^0.6.0 - version: 0.6.0 - '@types/lodash': - specifier: ^4.14.198 - version: 4.14.198 - '@types/node': - specifier: ^18.17.15 - version: 18.17.15 - '@types/node-fetch': - specifier: ^2.6.4 - version: 2.6.4 - nodemon: - specifier: ^2.0.22 - version: 2.0.22 - client: dependencies: '@reduxjs/toolkit': @@ -230,7 +187,7 @@ importers: version: link:../common transport-server: specifier: workspace:* - version: link:../api + version: link:../server devDependencies: '@types/jsdom': specifier: ^21.1.1 @@ -254,6 +211,49 @@ importers: specifier: ^4.8.4 version: 4.9.5 + server: + dependencies: + express: + specifier: ^4.18.2 + version: 4.18.2 + lodash: + specifier: ^4.17.21 + version: 4.17.21 + node-fetch: + specifier: ^2.7.0 + version: 2.7.0(encoding@0.1.13) + transport-common: + specifier: workspace:* + version: link:../common + ts-node: + specifier: ^10.9.1 + version: 10.9.1(@types/node@18.17.15)(typescript@4.9.5) + tslib: + specifier: ^2.6.2 + version: 2.6.2 + typescript: + specifier: ^4.9.5 + version: 4.9.5 + devDependencies: + '@types/express': + specifier: ^4.17.17 + version: 4.17.17 + '@types/js-sha1': + specifier: ^0.6.0 + version: 0.6.0 + '@types/lodash': + specifier: ^4.14.198 + version: 4.14.198 + '@types/node': + specifier: ^18.17.15 + version: 18.17.15 + '@types/node-fetch': + specifier: ^2.6.4 + version: 2.6.4 + nodemon: + specifier: ^2.0.22 + version: 2.0.22 + packages: /@aashutoshrathi/word-wrap@1.2.6: @@ -335,7 +335,7 @@ packages: '@babel/helper-validator-option': 7.21.0 browserslist: 4.21.5 lru-cache: 5.1.1 - semver: 6.3.0 + semver: 6.3.1 /@babel/helper-create-class-features-plugin@7.21.0(@babel/core@7.21.3): resolution: {integrity: sha512-Q8wNiMIdwsv5la5SPxNYzzkPnjgC0Sy0i7jLkVOCdllu/xcVNkr3TeZzbHBJrj+XXRqzX5uCyCoV9eu6xUG7KQ==} @@ -378,7 +378,7 @@ packages: debug: 4.3.4 lodash.debounce: 4.0.8 resolve: 1.22.1 - semver: 6.3.0 + semver: 6.3.1 transitivePeerDependencies: - supports-color dev: true @@ -2490,12 +2490,12 @@ packages: resolution: {integrity: sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==} engines: {node: '>=0.4.0'} hasBin: true - dev: true /acorn@8.8.2: resolution: {integrity: sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==} engines: {node: '>=0.4.0'} hasBin: true + dev: true /agent-base@6.0.2: resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==} @@ -2704,7 +2704,7 @@ packages: '@babel/compat-data': 7.21.0 '@babel/core': 7.21.3 '@babel/helper-define-polyfill-provider': 0.3.3(@babel/core@7.21.3) - semver: 6.3.0 + semver: 6.3.1 transitivePeerDependencies: - supports-color dev: true @@ -2804,7 +2804,7 @@ packages: resolution: {integrity: sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==} dependencies: function-bind: 1.1.1 - get-intrinsic: 1.2.0 + get-intrinsic: 1.2.1 /callsites@3.1.0: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} @@ -3281,7 +3281,7 @@ packages: es-set-tostringtag: 2.0.1 es-to-primitive: 1.2.1 function.prototype.name: 1.1.5 - get-intrinsic: 1.2.0 + get-intrinsic: 1.2.1 get-symbol-description: 1.0.0 globalthis: 1.0.3 gopd: 1.0.1 @@ -3393,7 +3393,7 @@ packages: resolution: {integrity: sha512-g3OMbtlwY3QewlqAiMLI47KywjWZoEytKr8pf6iTC8uJq5bIAH52Z9pnQ8pVL6whrCto53JZDuUIsifGeLorTg==} engines: {node: '>= 0.4'} dependencies: - get-intrinsic: 1.2.0 + get-intrinsic: 1.2.1 has: 1.0.3 has-tostringtag: 1.0.0 dev: true @@ -3472,7 +3472,7 @@ packages: eslint-plugin-import: 2.28.1(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@2.7.1)(eslint@8.49.0) object.assign: 4.1.4 object.entries: 1.1.6 - semver: 6.3.0 + semver: 6.3.1 dev: true /eslint-config-airbnb-typescript@17.1.0(@typescript-eslint/eslint-plugin@5.62.0)(@typescript-eslint/parser@5.62.0)(eslint-plugin-import@2.28.1)(eslint@8.49.0): @@ -4077,6 +4077,7 @@ packages: function-bind: 1.1.1 has: 1.0.3 has-symbols: 1.0.3 + dev: true /get-intrinsic@1.2.1: resolution: {integrity: sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw==} @@ -4085,7 +4086,6 @@ packages: has: 1.0.3 has-proto: 1.0.1 has-symbols: 1.0.3 - dev: true /get-stream@6.0.1: resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==} @@ -4097,7 +4097,7 @@ packages: engines: {node: '>= 0.4'} dependencies: call-bind: 1.0.2 - get-intrinsic: 1.2.0 + get-intrinsic: 1.2.1 dev: true /glob-parent@5.1.2: @@ -4173,7 +4173,7 @@ packages: /gopd@1.0.1: resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} dependencies: - get-intrinsic: 1.2.0 + get-intrinsic: 1.2.1 dev: true /graceful-fs@4.2.11: @@ -4200,13 +4200,12 @@ packages: /has-property-descriptors@1.0.0: resolution: {integrity: sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==} dependencies: - get-intrinsic: 1.2.0 + get-intrinsic: 1.2.1 dev: true /has-proto@1.0.1: resolution: {integrity: sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==} engines: {node: '>= 0.4'} - dev: true /has-symbols@1.0.3: resolution: {integrity: sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==} @@ -4363,7 +4362,7 @@ packages: resolution: {integrity: sha512-Y+R5hJrzs52QCG2laLn4udYVnxsfny9CpOhNhUvk/SSSVyF6T27FzRbF0sroPidSu3X8oEAkOn2K804mjpt6UQ==} engines: {node: '>= 0.4'} dependencies: - get-intrinsic: 1.2.0 + get-intrinsic: 1.2.1 has: 1.0.3 side-channel: 1.0.4 dev: true @@ -4385,7 +4384,7 @@ packages: resolution: {integrity: sha512-y+FyyR/w8vfIRq4eQcM1EYgSTnmHXPqaF+IgzgraytCFq5Xh8lllDVmAZolPJiZttZLeFSINPYMaEJ7/vWUa1w==} dependencies: call-bind: 1.0.2 - get-intrinsic: 1.2.0 + get-intrinsic: 1.2.1 is-typed-array: 1.1.10 dev: true @@ -5640,7 +5639,7 @@ packages: resolution: {integrity: sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==} dependencies: call-bind: 1.0.2 - get-intrinsic: 1.2.0 + get-intrinsic: 1.2.1 is-regex: 1.1.4 dev: true @@ -5672,7 +5671,6 @@ packages: /semver@6.3.1: resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} hasBin: true - dev: true /semver@7.0.0: resolution: {integrity: sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==} @@ -5749,7 +5747,7 @@ packages: resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==} dependencies: call-bind: 1.0.2 - get-intrinsic: 1.2.0 + get-intrinsic: 1.2.1 object-inspect: 1.12.3 /signal-exit@3.0.7: @@ -6067,7 +6065,7 @@ packages: '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.3 '@types/node': 18.17.15 - acorn: 8.8.2 + acorn: 8.10.0 acorn-walk: 8.2.0 arg: 4.1.3 create-require: 1.1.1 diff --git a/api/.eslintrc.json b/server/.eslintrc.json similarity index 100% rename from api/.eslintrc.json rename to server/.eslintrc.json diff --git a/api/controller/index.ts b/server/controller/index.ts similarity index 100% rename from api/controller/index.ts rename to server/controller/index.ts diff --git a/api/controller/masstrans/masstrans.ts b/server/controller/masstrans/masstrans.ts similarity index 100% rename from api/controller/masstrans/masstrans.ts rename to server/controller/masstrans/masstrans.ts diff --git a/api/index.ts b/server/index.ts similarity index 100% rename from api/index.ts rename to server/index.ts diff --git a/api/model/ekaterinburg-rf/ekaterinburg-rf.constants.ts b/server/model/ekaterinburg-rf/ekaterinburg-rf.constants.ts similarity index 100% rename from api/model/ekaterinburg-rf/ekaterinburg-rf.constants.ts rename to server/model/ekaterinburg-rf/ekaterinburg-rf.constants.ts diff --git a/api/model/ekaterinburg-rf/ekaterinburg-rf.ts b/server/model/ekaterinburg-rf/ekaterinburg-rf.ts similarity index 100% rename from api/model/ekaterinburg-rf/ekaterinburg-rf.ts rename to server/model/ekaterinburg-rf/ekaterinburg-rf.ts diff --git a/api/model/ekaterinburg-rf/ekaterinburg-rf.types.ts b/server/model/ekaterinburg-rf/ekaterinburg-rf.types.ts similarity index 100% rename from api/model/ekaterinburg-rf/ekaterinburg-rf.types.ts rename to server/model/ekaterinburg-rf/ekaterinburg-rf.types.ts diff --git a/api/model/index.ts b/server/model/index.ts similarity index 100% rename from api/model/index.ts rename to server/model/index.ts diff --git a/api/package.json b/server/package.json similarity index 100% rename from api/package.json rename to server/package.json diff --git a/api/router/index.ts b/server/router/index.ts similarity index 100% rename from api/router/index.ts rename to server/router/index.ts diff --git a/api/router/masstrans.ts b/server/router/masstrans.ts similarity index 100% rename from api/router/masstrans.ts rename to server/router/masstrans.ts diff --git a/api/service/index.ts b/server/service/index.ts similarity index 100% rename from api/service/index.ts rename to server/service/index.ts diff --git a/api/service/masstrans/masstrans.ts b/server/service/masstrans/masstrans.ts similarity index 100% rename from api/service/masstrans/masstrans.ts rename to server/service/masstrans/masstrans.ts diff --git a/api/tsconfig.json b/server/tsconfig.json similarity index 100% rename from api/tsconfig.json rename to server/tsconfig.json diff --git a/server/utils/allow-cross-domain.ts b/server/utils/allow-cross-domain.ts new file mode 100644 index 00000000..a0716e4e --- /dev/null +++ b/server/utils/allow-cross-domain.ts @@ -0,0 +1,6 @@ +import type { NextFunction, Request, Response } from "express"; + +export const allowCrossDomain = (req: Request, res: Response, next: NextFunction) => { + res.header(`Access-Control-Allow-Origin`, '*'); + next(); +}; diff --git a/api/utils/get-current-timestamp.ts b/server/utils/get-current-timestamp.ts similarity index 100% rename from api/utils/get-current-timestamp.ts rename to server/utils/get-current-timestamp.ts diff --git a/api/utils/get-request-token.ts b/server/utils/get-request-token.ts similarity index 100% rename from api/utils/get-request-token.ts rename to server/utils/get-request-token.ts diff --git a/api/utils/is-value-in-object.ts b/server/utils/is-value-in-object.ts similarity index 100% rename from api/utils/is-value-in-object.ts rename to server/utils/is-value-in-object.ts