Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "soul-cli",
"version": "0.8.2",
"version": "0.8.4",
"description": "A SQLite REST and Realtime server",
"main": "src/server.js",
"bin": {
Expand All @@ -11,7 +11,7 @@
"dev": "npm run swagger-autogen && cross-env NO_CLI=true nodemon src/server.js",
"cli": "nodemon src/server.js --database foobar.db",
"swagger-autogen": "cross-env NO_CLI=true node src/swagger/index.js",
"test": "cross-env CI=true NODE_ENV=test NO_CLI=true DB=test.db CORE_PORT=8001 jest --testTimeout=10000",
"test": "cross-env CI=true NODE_ENV=test NO_CLI=true DB=test.db CORE_PORT=8001 AUTH=true TOKEN_SECRET=test-secret INITIAL_USER_USERNAME=admin INITIAL_USER_PASSWORD=Admin123#Test jest --testTimeout=10000 --forceExit",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now it's ok but in the future we need to check why we need --forceExit and fix any related issues.

"prepare": "husky install",
"lint": "eslint . --fix --max-warnings=0",
"format": "prettier . --write"
Expand All @@ -28,7 +28,7 @@
"homepage": "https://github.com/thevahidal/soul#readme",
"dependencies": {
"bcrypt": "^5.1.1",
"better-sqlite3": "^8.1.0",
"better-sqlite3": "^12.4.4",
"body-parser": "^1.20.2",
"check-password-strength": "^2.0.7",
"cookie-parser": "^1.4.6",
Expand Down
9 changes: 8 additions & 1 deletion src/controllers/auth/tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,20 @@ const createDefaultTables = async () => {
// create _roles table
if (!roleTable) {
tableService.createTable(ROLES_TABLE, schema.roleSchema);
}

// create a default role in the _roles table
// create a default role in the _roles table if it doesn't exist
try {
const role = rowService.save({
tableName: ROLES_TABLE,
fields: { name: constantRoles.DEFAULT_ROLE },
});
roleId = role.lastInsertRowid;
} catch (e) {
if (e.code !== 'SQLITE_CONSTRAINT_UNIQUE') {
throw e;
}
// role already exists, ignore
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It the role already exists, shouldn't we get it from db?

// role already exists, ignore
roleId = rowService...

}

// create _roles_permissions table
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ if (config.auth) {
setInterval(
removeRevokedRefreshTokens,
authConstants.REVOKED_REFRESH_TOKENS_REMOVAL_TIME_RANGE,
);
).unref();

// If the user has passed custom CLI commands run the command and exit to avoid running the server
runCLICommands();
Expand Down
2 changes: 1 addition & 1 deletion src/swagger/swagger.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"swagger": "2.0",
"info": {
"version": "0.8.1",
"version": "0.8.4",
"title": "Soul API",
"description": "API Documentation for <b>Soul</b>, a SQLite REST and realtime server. "
},
Expand Down