-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement UpdatableAdapter on adapter
This updates the adapter so that we can use updatePolicy from the enforcer. I also set up local testing to use sqlite so we can run the tests without a mysql instance.
- Loading branch information
Showing
5 changed files
with
746 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,28 @@ | ||
import { DataSourceOptions } from 'typeorm'; | ||
|
||
export const connectionConfig: DataSourceOptions = { | ||
type: 'mysql', | ||
host: 'localhost', | ||
port: parseInt(process.env.MYSQL_PORT || '', 10) || 3306, | ||
username: process.env.MYSQL_USER || 'root', | ||
password: | ||
process.env.MYSQL_PASSWORD !== undefined | ||
? process.env.MYSQL_PASSWORD === '' | ||
? undefined | ||
: process.env.MYSQL_PASSWORD | ||
: 'password', | ||
database: process.env.MYSQL_DB || 'casbin', | ||
dropSchema: true, | ||
}; | ||
const SHOULD_USE_MYSQL = | ||
process.env.MYSQL_USER != null || | ||
process.env.MYSQL_PORT != null || | ||
process.env.MYSQL_PASSWORD != null || | ||
process.env.MYSQL_DB != null; | ||
|
||
export const connectionConfig: DataSourceOptions = SHOULD_USE_MYSQL | ||
? { | ||
type: 'mysql', | ||
host: 'localhost', | ||
port: parseInt(process.env.MYSQL_PORT || '', 10) || 3306, | ||
username: process.env.MYSQL_USER || 'root', | ||
password: | ||
process.env.MYSQL_PASSWORD !== undefined | ||
? process.env.MYSQL_PASSWORD === '' | ||
? undefined | ||
: process.env.MYSQL_PASSWORD | ||
: 'password', | ||
database: process.env.MYSQL_DB || 'casbin', | ||
dropSchema: true, | ||
} | ||
: { | ||
type: 'sqlite', | ||
database: ':memory:', | ||
dropSchema: true, | ||
}; |
Oops, something went wrong.