Comments (9)
TypeORMAdapter.newAdapter
return is Promise
, you forget use await
.
from typeorm-adapter.
Can you provide a runnable example?
from typeorm-adapter.
Can you provide a runnable example?
Sorry, picture upload failed.
This is some code in config.default.ts
:
config.middleware = ['user','authz'];
config.authz = {
enable: true,
newEnforcer: async() => {
const dbConnect = TypeORMAdapter.newAdapter({
"type": "mysql",
"host": "localhost",
"port": 3306,
"username": "root",
"password": "123456",
"database": "casbin"
});
const enforcer = await Enforcer.newEnforcer('authz_model.conf', dbConnect);
return enforcer
}
}
router.ts
:
router.get('/test', controller.home.test);
controller/home.ts
:
public test() {
const { ctx } = this;
ctx.body = "this is a test";
};
from typeorm-adapter.
Use node-casbin v2.0, you can try this
import casbin from 'casbin';
const enforcer = await casbin.newEnforcer('authz_model.conf', dbConnect);
return enforcer
from typeorm-adapter.
@nodece
use “ import casbin from 'casbin'; ” has error:
Module '"E:/workSpace/typeorm_test/node_modules/casbin/lib/index"' has no default export.
from typeorm-adapter.
ts use import * as casbin from 'casbin';
from typeorm-adapter.
@nodece
done as you said,still has this.adapter.loadPolicy is not a function
......
from typeorm-adapter.
@nodece
done as you said,still has “this.adapter.loadPolicy is not a function”......
I use const dbConnect = await SequelizeAdapter.newAdapter('mysql://root:123456@localhost:3306/');
is ok;but const dbConnect = TypeORMAdapter.newAdapter(......)
can't
from typeorm-adapter.
TypeORMAdapter.newAdapter
return isPromise
, you forget useawait
.
oh my god!!!
I am so sorry.
thank you very much!!
from typeorm-adapter.
Related Issues (20)
- batch operation support HOT 2
- Error: filtered policies are not supported by this adapter HOT 2
- Any existing function to retrieve filtered policies HOT 5
- [feat] pass connection object to newAdapter HOT 2
- AlreadyHasActiveConnectionError issue in nestjs HOT 2
- use database replace .csv get error:nodejs.AlreadyHasActiveConnectionError HOT 4
- casbin_rule does not exist HOT 7
- Publish v1.3.0 to npm HOT 8
- Migrate from Travis CI to Github Actions HOT 3
- removePolicy not working HOT 1
- Limited to 6 policy arguments HOT 3
- v1.5 Performance regression HOT 3
- use ExistentConnection HOT 4
- [bug] removeFilteredPolicy is not working properly HOT 1
- The automated release is failing 🚨 HOT 2
- TypeORM adapter fails with ACL model HOT 1
- Custom database table name HOT 4
- Issue: ObjectID no longer be used in typeorm, please update to ObjectId HOT 3
- RESOLVE unable to resolve dependency tree HOT 2
- The lib directory is missing in version 1.6.0 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typeorm-adapter.