diff --git a/backend/package.json b/backend/package.json index 4620db4ad..73c0f7513 100644 --- a/backend/package.json +++ b/backend/package.json @@ -27,6 +27,7 @@ "jest": "^27.2.4", "jsonwebtoken": "^8.5.1", "libsodium-wrappers": "^0.7.9", + "module-alias": "^2.2.2", "mysql2": "^2.3.0", "reflect-metadata": "^0.1.13", "ts-jest": "^27.0.5", @@ -50,5 +51,8 @@ "prettier": "^2.3.1", "ts-node": "^10.0.0", "typescript": "^4.3.4" + }, + "_moduleAliases": { + "@entity" : "../database/build/entity" } } diff --git a/backend/src/index.ts b/backend/src/index.ts index 916fe0550..9dd75dce5 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -1,6 +1,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import 'reflect-metadata' +import 'module-alias/register' import express from 'express' import { ApolloServer } from 'apollo-server-express' diff --git a/backend/tsconfig.json b/backend/tsconfig.json index 7e36dfe5d..15eb704ba 100644 --- a/backend/tsconfig.json +++ b/backend/tsconfig.json @@ -45,7 +45,7 @@ /* Module Resolution Options */ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ "paths": { /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ "@entity/*": ["../database/entity/*"] }, @@ -70,5 +70,12 @@ /* Advanced Options */ "skipLibCheck": true, /* Skip type checking of declaration files. */ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ - } + }, + "references": [ + { + "path": "../database/tsconfig.json", + // add 'prepend' if you want to include the referenced project in your output file + // "prepend": true, + } + ] } diff --git a/backend/yarn.lock b/backend/yarn.lock index 11401ccf0..f884afe18 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -4116,6 +4116,11 @@ mkdirp@^1.0.4: resolved "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz" integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== +module-alias@^2.2.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/module-alias/-/module-alias-2.2.2.tgz#151cdcecc24e25739ff0aa6e51e1c5716974c0e0" + integrity sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q== + ms@2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz" diff --git a/database.d.ts b/database.d.ts new file mode 100644 index 000000000..3cda5e882 --- /dev/null +++ b/database.d.ts @@ -0,0 +1,165 @@ +/// +declare module "entity/0001-init_db/Balance" { + import { BaseEntity } from 'typeorm'; + export class Balance extends BaseEntity { + id: number; + userId: number; + modified: Date; + recordDate: Date; + amount: number; + } +} +declare module "entity/Balance" { + export { Balance } from "entity/0001-init_db/Balance"; +} +declare module "entity/0001-init_db/Migration" { + import { BaseEntity } from 'typeorm'; + export class Migration extends BaseEntity { + version: number; + fileName: string; + date: Date; + } +} +declare module "entity/Migration" { + export { Migration } from "entity/0001-init_db/Migration"; +} +declare module "entity/0001-init_db/TransactionCreation" { + import { BaseEntity, Timestamp } from 'typeorm'; + import { Transaction } from "entity/0001-init_db/Transaction"; + export class TransactionCreation extends BaseEntity { + id: number; + transactionId: number; + userId: number; + amount: number; + targetDate: Timestamp; + transaction: Transaction; + } +} +declare module "entity/0001-init_db/TransactionSendCoin" { + import { BaseEntity } from 'typeorm'; + import { Transaction } from "entity/0001-init_db/Transaction"; + export class TransactionSendCoin extends BaseEntity { + id: number; + transactionId: number; + senderPublic: Buffer; + userId: number; + recipiantPublic: Buffer; + recipiantUserId: number; + amount: number; + transaction: Transaction; + } +} +declare module "entity/0001-init_db/Transaction" { + import { BaseEntity } from 'typeorm'; + import { TransactionCreation } from "entity/0001-init_db/TransactionCreation"; + import { TransactionSendCoin } from "entity/0001-init_db/TransactionSendCoin"; + export class Transaction extends BaseEntity { + id: number; + transactionTypeId: number; + txHash: Buffer; + memo: string; + received: Date; + blockchainTypeId: number; + transactionSendCoin: TransactionSendCoin; + transactionCreation: TransactionCreation; + } +} +declare module "entity/Transaction" { + export { Transaction } from "entity/0001-init_db/Transaction"; +} +declare module "entity/TransactionCreation" { + export { TransactionCreation } from "entity/0001-init_db/TransactionCreation"; +} +declare module "entity/TransactionSendCoin" { + export { TransactionSendCoin } from "entity/0001-init_db/TransactionSendCoin"; +} +declare module "entity/0002-add_settings/UserSetting" { + import { BaseEntity } from 'typeorm'; + import { User } from "entity/0002-add_settings/User"; + export class UserSetting extends BaseEntity { + id: number; + userId: number; + user: User; + key: string; + value: string; + } +} +declare module "entity/0002-add_settings/User" { + import { BaseEntity } from 'typeorm'; + import { UserSetting } from "entity/0002-add_settings/UserSetting"; + export class User extends BaseEntity { + id: number; + pubkey: Buffer; + email: string; + firstName: string; + lastName: string; + username: string; + disabled: boolean; + settings: UserSetting[]; + } +} +declare module "entity/User" { + export { User } from "entity/0002-add_settings/User"; +} +declare module "entity/UserSetting" { + export { UserSetting } from "entity/0002-add_settings/UserSetting"; +} +declare module "entity/0001-init_db/UserTransaction" { + import { BaseEntity } from 'typeorm'; + export class UserTransaction extends BaseEntity { + id: number; + userId: number; + transactionId: number; + transactionTypeId: number; + balance: number; + balanceDate: Date; + } +} +declare module "entity/UserTransaction" { + export { UserTransaction } from "entity/0001-init_db/UserTransaction"; +} +declare module "entity/0001-init_db/User" { + import { BaseEntity } from 'typeorm'; + export class User extends BaseEntity { + id: number; + pubkey: Buffer; + email: string; + firstName: string; + lastName: string; + username: string; + disabled: boolean; + } +} +declare module "migrations/0001-init_db" { + export function upgrade(queryFn: (query: string, values?: any[]) => Promise>): Promise; + export function downgrade(queryFn: (query: string, values?: any[]) => Promise>): Promise; +} +declare module "migrations/0002-add_settings" { + export function upgrade(queryFn: (query: string, values?: any[]) => Promise>): Promise; + export function downgrade(queryFn: (query: string, values?: any[]) => Promise>): Promise; +} +declare module "src/config/index" { + const CONFIG: { + MIGRATIONS_TABLE: string; + MIGRATIONS_DIRECTORY: string; + DB_HOST: string; + DB_PORT: number; + DB_USER: string; + DB_PASSWORD: string; + DB_DATABASE: string; + }; + export default CONFIG; +} +declare module "src/prepare" { + const _default: () => Promise; + export default _default; +} +declare module "src/typeorm/connection" { + import { Connection } from 'typeorm'; + const connection: () => Promise; + export default connection; +} +declare module "src/index" { + import 'reflect-metadata'; +} +//# sourceMappingURL=database.d.ts.map \ No newline at end of file diff --git a/database.d.ts.map b/database.d.ts.map new file mode 100644 index 000000000..b5b67871a --- /dev/null +++ b/database.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["database/entity/0001-init_db/Balance.ts","database/entity/Balance.ts","database/entity/0001-init_db/Migration.ts","database/entity/Migration.ts","database/entity/0001-init_db/TransactionCreation.ts","database/entity/0001-init_db/TransactionSendCoin.ts","database/entity/0001-init_db/Transaction.ts","database/entity/Transaction.ts","database/entity/TransactionCreation.ts","database/entity/TransactionSendCoin.ts","database/entity/0002-add_settings/UserSetting.ts","database/entity/0002-add_settings/User.ts","database/entity/User.ts","database/entity/UserSetting.ts","database/entity/0001-init_db/UserTransaction.ts","database/entity/UserTransaction.ts","database/entity/0001-init_db/User.ts","database/migrations/0001-init_db.ts","database/migrations/0002-add_settings.ts","database/src/config/index.ts","database/src/prepare.ts","database/src/typeorm/connection.ts","database/src/index.ts"],"names":[],"mappings":";;IAAA,OAAO,EAAE,UAAU,EAA0C,MAAM,SAAS,CAAA;IAG5E,MAAM,OAAO,OAAQ,SAAQ,UAAU;QAErC,EAAE,EAAE,MAAM,CAAA;QAGV,MAAM,EAAE,MAAM,CAAA;QAGd,QAAQ,EAAE,IAAI,CAAA;QAGd,UAAU,EAAE,IAAI,CAAA;QAGhB,MAAM,EAAE,MAAM,CAAA;KACf;;;IClBD,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AU,EAAE,MAAM,SAAS,CAAA;IAItD,MAAM,UAAU,QAAa,QAAQ,UAAU,GAAG,IAAI,CAiBrD,CAAA;IAED,eAAe,UAAU,CAAA;;;ICvBzB,OAAO,kBAAkB,CAAA"} \ No newline at end of file diff --git a/database.tsbuildinfo b/database.tsbuildinfo new file mode 100644 index 000000000..e6bed655d --- /dev/null +++ b/database.tsbuildinfo @@ -0,0 +1 @@ +{"bundle":{"commonSourceDirectory":"./database","sourceFiles":["./database/entity/0001-init_db/Balance.ts","./database/entity/Balance.ts","./database/entity/0001-init_db/Migration.ts","./database/entity/Migration.ts","./database/entity/0001-init_db/TransactionCreation.ts","./database/entity/0001-init_db/TransactionSendCoin.ts","./database/entity/0001-init_db/Transaction.ts","./database/entity/Transaction.ts","./database/entity/TransactionCreation.ts","./database/entity/TransactionSendCoin.ts","./database/entity/0002-add_settings/UserSetting.ts","./database/entity/0002-add_settings/User.ts","./database/entity/User.ts","./database/entity/UserSetting.ts","./database/entity/0001-init_db/UserTransaction.ts","./database/entity/UserTransaction.ts","./database/entity/0001-init_db/User.ts","./database/migrations/0001-init_db.ts","./database/migrations/0002-add_settings.ts","./database/src/config/index.ts","./database/src/prepare.ts","./database/src/typeorm/connection.ts","./database/src/index.ts"],"js":{"sections":[{"pos":0,"end":762,"kind":"emitHelpers","data":"typescript:extends"},{"pos":763,"end":1334,"kind":"emitHelpers","data":"typescript:decorate"},{"pos":1335,"end":1511,"kind":"emitHelpers","data":"typescript:metadata"},{"pos":1512,"end":2192,"kind":"emitHelpers","data":"typescript:awaiter"},{"pos":2193,"end":3983,"kind":"emitHelpers","data":"typescript:generator"},{"pos":3984,"end":4366,"kind":"emitHelpers","data":"typescript:assign"},{"pos":4367,"end":65553,"kind":"text"}],"sources":{"helpers":["typescript:extends","typescript:decorate","typescript:metadata","typescript:awaiter","typescript:generator","typescript:assign"]}},"dts":{"sections":[{"pos":0,"end":30,"kind":"type","data":"node"},{"pos":31,"end":5388,"kind":"text"}]}},"version":"4.3.4"} \ No newline at end of file diff --git a/database/tsconfig.json b/database/tsconfig.json index 250ec5201..102d9112f 100644 --- a/database/tsconfig.json +++ b/database/tsconfig.json @@ -4,19 +4,19 @@ /* Basic Options */ // "incremental": true, /* Enable incremental compilation */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */ + "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation. */ // "allowJs": true, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */ - // "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ + "declaration": true, /* Generates corresponding '.d.ts' file. */ + "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outFile": "./build/outfile.js", /* Concatenate and emit output to single file. */ "outDir": "./build", /* Redirect output structure to the directory. */ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "composite": true, /* Enable project compilation */ + "composite": true, /* Enable project compilation */ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ // "removeComments": true, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ @@ -44,10 +44,10 @@ // "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */ /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ - "rootDirs": [".", "../database"], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "rootDirs": [".", "../database"], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ @@ -68,5 +68,6 @@ /* Advanced Options */ "skipLibCheck": true, /* Skip type checking of declaration files. */ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ - } + }, + "references": [] /* Any project that is referenced must itself have a `references` array (which may be empty). */ }