Skip to content

Commit dbdc442

Browse files
authored
Merge pull request #6 from BobbieBarker/master
feat(adapter-configuration): Modified adapter.ts to allow for configu…
2 parents 9978ba8 + 614f789 commit dbdc442

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/adapter.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,13 @@ export default class TypeORMAdapter implements Adapter {
3131
* @param option typeorm connection option
3232
*/
3333
public static async newAdapter(option: ConnectionOptions) {
34-
const officialOption = {
35-
entities: [CasbinRule],
34+
const defaults = {
3635
synchronize: true,
3736
name: 'node-casbin-official'
3837
};
39-
if (option.name) {
40-
officialOption.name = option.name;
41-
}
42-
43-
const a = new TypeORMAdapter(Object.assign(option, officialOption));
38+
const entities = { entities: [CasbinRule] };
39+
const configuration = Object.assign(defaults, option);
40+
const a = new TypeORMAdapter(Object.assign(configuration, entities));
4441
await a.open();
4542
return a;
4643
}

0 commit comments

Comments
 (0)