generalpiston / typeorm-encrypted

Encrypted field for typeorm.
MIT License
74 stars 19 forks source link

Examples and configuration using ormconfig.json #10

Closed generalpiston closed 4 years ago

manuhortet commented 5 years ago

Tried adding "node_modules/typeorm-encrypted/src/subscribers/AutoEncryptSubscriber.ts" to subscribers in my ormconfig.json and didn't work. Any clue about how this must be done?

Error:

import { EventSubscriber, EntitySubscriberInterface, InsertEvent, UpdateEvent } from "typeorm";
       ^

SyntaxError: Unexpected token 
generalpiston commented 5 years ago

@manuhortet it seems like there's an issue with tsconfig.json. You'll likely have to make that file available using the files property: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html.

manuhortet commented 5 years ago

Added the path to files in tsconfig.json and it now finds the file (had to change my "scripts": { "start": } to avoid using ts-node src/index.ts, which will ignore tsconfig.json.

Anyway, now with:

"scripts": {
    "start": "tsc && node src/index.ts"
}

I'm getting:

node_modules/typeorm/common/DeepPartial.d.ts(5,27): error TS1005: ';' expected.
node_modules/typeorm/common/DeepPartial.d.ts(5,47): error TS1005: ';' expected.
node_modules/typeorm/common/DeepPartial.d.ts(5,50): error TS1109: Expression expected.
node_modules/typeorm/common/DeepPartial.d.ts(5,74): error TS1005: '(' expected.
node_modules/typeorm/common/DeepPartial.d.ts(5,81): error TS1005: ',' expected.
node_modules/typeorm/common/DeepPartial.d.ts(5,109): error TS1005: ',' expected.
node_modules/typeorm/common/DeepPartial.d.ts(5,112): error TS1109: Expression expected.
node_modules/typeorm/common/DeepPartial.d.ts(5,144): error TS1005: '(' expected.
node_modules/typeorm/common/DeepPartial.d.ts(5,163): error TS1005: '(' expected.
node_modules/typeorm/common/DeepPartial.d.ts(6,1): error TS1128: Declaration or statement expected.
node_modules/typeorm/query-builder/QueryPartialEntity.d.ts(11,27): error TS1005: ';' expected.
node_modules/typeorm/query-builder/QueryPartialEntity.d.ts(11,47): error TS1005: ';' expected.
node_modules/typeorm/query-builder/QueryPartialEntity.d.ts(11,50): error TS1109: Expression expected.
node_modules/typeorm/query-builder/QueryPartialEntity.d.ts(11,85): error TS1005: '(' expected.
node_modules/typeorm/query-builder/QueryPartialEntity.d.ts(11,92): error TS1005: ',' expected.
node_modules/typeorm/query-builder/QueryPartialEntity.d.ts(11,120): error TS1005: ',' expected.
node_modules/typeorm/query-builder/QueryPartialEntity.d.ts(11,123): error TS1109: Expression expected.
node_modules/typeorm/query-builder/QueryPartialEntity.d.ts(11,166): error TS1005: '(' expected.
node_modules/typeorm/query-builder/QueryPartialEntity.d.ts(11,197): error TS1005: '(' expected.
node_modules/typeorm/query-builder/QueryPartialEntity.d.ts(11,213): error TS1005: ')' expected.
node_modules/typeorm/query-builder/QueryPartialEntity.d.ts(12,1): error TS1128: Declaration or statement expected.
error Command failed with exit code 2.

I'm new with TS and pretty lost here. I guess this is not a problem with typeorm-encrypted and its use anymore, but something about how I'm compiling / running things here.

generalpiston commented 5 years ago

Hey man, no problem... it seems like you're using typescript incorrectly. I would try https://www.npmjs.com/package/ts-node. I usually use it this way: node -r ts-node/register src/index.ts.

If you need more help, feel free to find me on telegram: @generalpiston .

generalpiston commented 4 years ago

Less necessary with Transformers in #14 .