soul-cli 0.6.1 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.all-contributorsrc +73 -0
- package/.editorconfig +26 -0
- package/.env.sample +9 -0
- package/.eslintignore +2 -0
- package/.eslintrc.js +24 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/.github/workflows/npm-publish.yml +23 -0
- package/.husky/pre-commit +5 -0
- package/CONTRIBUTING.md +92 -0
- package/LICENSE +21 -0
- package/README.md +188 -1
- package/docs/api/root-examples.md +41 -0
- package/docs/api/rows-examples.md +225 -0
- package/docs/api/tables-examples.md +217 -0
- package/docs/api-examples.md +62 -0
- package/docs/auth-db-diagram.png +0 -0
- package/docs/auth.md +135 -0
- package/docs/extensions-examples.md +167 -0
- package/docs/logo.png +0 -0
- package/docs/soul-studio.png +0 -0
- package/docs/ws/rows-examples.md +122 -0
- package/docs/ws-examples.md +42 -0
- package/package.json +17 -2
- package/src/cli.js +59 -1
- package/src/commands.js +22 -0
- package/src/config/index.js +48 -3
- package/src/constants/api.js +26 -0
- package/src/constants/auth.js +5 -0
- package/src/constants/index.js +13 -0
- package/src/constants/messages.js +41 -0
- package/src/constants/roles.js +3 -0
- package/src/constants/tables.js +47 -0
- package/src/controllers/auth/common.js +16 -0
- package/src/controllers/auth/index.js +5 -0
- package/src/controllers/auth/tables.js +96 -0
- package/src/controllers/auth/token.js +243 -0
- package/src/controllers/auth/user.js +394 -0
- package/src/controllers/auth.test.js +372 -0
- package/src/controllers/rows.js +48 -55
- package/src/controllers/rows.test.js +146 -40
- package/src/controllers/tables.test.js +58 -28
- package/src/db/schema.js +118 -0
- package/src/index.js +33 -4
- package/src/middlewares/api.js +79 -0
- package/src/middlewares/auth.js +85 -0
- package/src/middlewares/broadcast.js +1 -1
- package/src/middlewares/validation.js +3 -2
- package/src/routes/auth.js +29 -0
- package/src/routes/rows.js +17 -5
- package/src/routes/tables.js +26 -4
- package/src/schemas/auth.js +67 -0
- package/src/schemas/index.js +6 -1
- package/src/schemas/rows.js +20 -0
- package/src/schemas/tables.js +18 -2
- package/src/server.js +3 -2
- package/src/services/authService.js +78 -0
- package/src/services/index.js +2 -1
- package/src/services/rowService.js +36 -7
- package/src/services/tableService.js +127 -1
- package/src/swagger/index.js +67 -0
- package/src/swagger/swagger.json +292 -60
- package/src/tests/index.js +4 -5
- package/src/tests/testData.js +23 -10
- package/src/utils/index.js +78 -0
- /package/{src/services/.gitkeep → docs/extensions/api-examples.js} +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"files": [
|
|
3
|
+
"README.md"
|
|
4
|
+
],
|
|
5
|
+
"imageSize": 100,
|
|
6
|
+
"commit": false,
|
|
7
|
+
"commitType": "docs",
|
|
8
|
+
"commitConvention": "angular",
|
|
9
|
+
"contributors": [
|
|
10
|
+
{
|
|
11
|
+
"login": "thevahidal",
|
|
12
|
+
"name": "Vahid Al",
|
|
13
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/20302825?v=4",
|
|
14
|
+
"profile": "http://linktr.ee/thevahidal",
|
|
15
|
+
"contributions": [
|
|
16
|
+
"code",
|
|
17
|
+
"review"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"login": "AbegaM",
|
|
22
|
+
"name": "Abenezer Melkamu",
|
|
23
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/70259638?v=4",
|
|
24
|
+
"profile": "https://github.com/AbegaM",
|
|
25
|
+
"contributions": [
|
|
26
|
+
"code"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"login": "IanMayo",
|
|
31
|
+
"name": "Ian Mayo",
|
|
32
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/1108513?v=4",
|
|
33
|
+
"profile": "https://github.com/IanMayo",
|
|
34
|
+
"contributions": [
|
|
35
|
+
"code",
|
|
36
|
+
"review"
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"login": "HanzCEO",
|
|
41
|
+
"name": "Hanz",
|
|
42
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/40712686?v=4",
|
|
43
|
+
"profile": "https://godot.id",
|
|
44
|
+
"contributions": [
|
|
45
|
+
"code"
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"login": "KoenDG",
|
|
50
|
+
"name": "Koen De Groote",
|
|
51
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/1440619?v=4",
|
|
52
|
+
"profile": "https://github.com/KoenDG",
|
|
53
|
+
"contributions": [
|
|
54
|
+
"code"
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"login": "TahaKhanAbdalli",
|
|
59
|
+
"name": "Muhammad Taha Khan",
|
|
60
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/50602678?v=4",
|
|
61
|
+
"profile": "https://github.com/TahaKhanAbdalli",
|
|
62
|
+
"contributions": [
|
|
63
|
+
"code"
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"contributorsPerLine": 7,
|
|
68
|
+
"skipCi": true,
|
|
69
|
+
"repoType": "github",
|
|
70
|
+
"repoHost": "https://github.com",
|
|
71
|
+
"projectName": "soul",
|
|
72
|
+
"projectOwner": "thevahidal"
|
|
73
|
+
}
|
package/.editorconfig
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# EditorConfig is awesome: https://github.com/editorconfig/editorconfig
|
|
2
|
+
|
|
3
|
+
# Top-most EditorConfig file
|
|
4
|
+
root = true
|
|
5
|
+
|
|
6
|
+
[*.{js,jsx,ts,tsx}]
|
|
7
|
+
quote_type = single
|
|
8
|
+
|
|
9
|
+
[*]
|
|
10
|
+
# Set default charset to utf-8
|
|
11
|
+
charset = utf-8
|
|
12
|
+
# Set default indentation to spaces
|
|
13
|
+
indent_style = space
|
|
14
|
+
# Linux-style newlines with a newline ending every file
|
|
15
|
+
end_of_line = lf
|
|
16
|
+
insert_final_newline = true
|
|
17
|
+
# Remove whitespace characters preceding newline characters
|
|
18
|
+
trim_trailing_whitespace = true
|
|
19
|
+
|
|
20
|
+
# Two space indentation for JavaScript files
|
|
21
|
+
[*.{js,json}]
|
|
22
|
+
indent_size = 2
|
|
23
|
+
|
|
24
|
+
# Disable trimming trailing whitespaces so that double space newlines work
|
|
25
|
+
[*.md]
|
|
26
|
+
trim_trailing_whitespace = false
|
package/.env.sample
CHANGED
|
@@ -3,6 +3,7 @@ CORE_PORT=8000
|
|
|
3
3
|
NODE_ENV=development
|
|
4
4
|
|
|
5
5
|
CORS_ORIGIN_WHITELIST=http://localhost:3000,http://127.0.0.1:3000
|
|
6
|
+
AUTH=false
|
|
6
7
|
|
|
7
8
|
RATE_LIMIT_ENABLED=false
|
|
8
9
|
RATE_LIMIT_WINDOW_MS=1000
|
|
@@ -10,4 +11,12 @@ RATE_LIMIT_MAX_REQUESTS=10
|
|
|
10
11
|
|
|
11
12
|
DB=foobar.db
|
|
12
13
|
|
|
14
|
+
|
|
15
|
+
ACCESS_TOKEN_EXPIRATION_TIME=10H
|
|
16
|
+
REFRESH_TOKEN_EXPIRATION_TIME=2D
|
|
17
|
+
|
|
18
|
+
INITIAL_USER_USERNAME
|
|
19
|
+
INITIAL_USER_PASSWORD
|
|
20
|
+
TOKEN_SECRET
|
|
21
|
+
|
|
13
22
|
START_WITH_STUDIO=false
|
package/.eslintignore
ADDED
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
env: {
|
|
3
|
+
node: true,
|
|
4
|
+
commonjs: true,
|
|
5
|
+
es2021: true,
|
|
6
|
+
jest: true,
|
|
7
|
+
},
|
|
8
|
+
extends: ["eslint:recommended", "prettier"],
|
|
9
|
+
overrides: [
|
|
10
|
+
{
|
|
11
|
+
env: {
|
|
12
|
+
node: true,
|
|
13
|
+
},
|
|
14
|
+
files: [".eslintrc.{js,cjs}"],
|
|
15
|
+
parserOptions: {
|
|
16
|
+
sourceType: "script",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
parserOptions: {
|
|
21
|
+
ecmaVersion: "latest",
|
|
22
|
+
},
|
|
23
|
+
rules: {},
|
|
24
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Create a report to help us improve
|
|
4
|
+
title: ''
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Describe the bug**
|
|
11
|
+
A clear and concise description of what the bug is.
|
|
12
|
+
|
|
13
|
+
**To Reproduce**
|
|
14
|
+
Steps to reproduce the behavior:
|
|
15
|
+
1. Go to '...'
|
|
16
|
+
2. Click on '....'
|
|
17
|
+
3. Scroll down to '....'
|
|
18
|
+
4. See error
|
|
19
|
+
|
|
20
|
+
**Expected behavior**
|
|
21
|
+
A clear and concise description of what you expected to happen.
|
|
22
|
+
|
|
23
|
+
**Screenshots**
|
|
24
|
+
If applicable, add screenshots to help explain your problem.
|
|
25
|
+
|
|
26
|
+
**Desktop (please complete the following information):**
|
|
27
|
+
- OS: [e.g. iOS]
|
|
28
|
+
- Browser [e.g. chrome, safari]
|
|
29
|
+
- Version [e.g. 22]
|
|
30
|
+
|
|
31
|
+
**Smartphone (please complete the following information):**
|
|
32
|
+
- Device: [e.g. iPhone6]
|
|
33
|
+
- OS: [e.g. iOS8.1]
|
|
34
|
+
- Browser [e.g. stock browser, safari]
|
|
35
|
+
- Version [e.g. 22]
|
|
36
|
+
|
|
37
|
+
**Additional context**
|
|
38
|
+
Add any other context about the problem here.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest an idea for this project
|
|
4
|
+
title: ''
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Is your feature request related to a problem? Please describe.**
|
|
11
|
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
12
|
+
|
|
13
|
+
**Describe the solution you'd like**
|
|
14
|
+
A clear and concise description of what you want to happen.
|
|
15
|
+
|
|
16
|
+
**Describe alternatives you've considered**
|
|
17
|
+
A clear and concise description of any alternative solutions or features you've considered.
|
|
18
|
+
|
|
19
|
+
**Additional context**
|
|
20
|
+
Add any other context or screenshots about the feature request here.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
|
|
3
|
+
|
|
4
|
+
name: Node.js Package
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
release:
|
|
8
|
+
types: [created]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
publish-npm:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v3
|
|
15
|
+
- uses: actions/setup-node@v3
|
|
16
|
+
with:
|
|
17
|
+
node-version: 16
|
|
18
|
+
registry-url: https://registry.npmjs.org/
|
|
19
|
+
|
|
20
|
+
- run: npm ci
|
|
21
|
+
- run: npm publish
|
|
22
|
+
env:
|
|
23
|
+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
When contributing to this repository, please first discuss the change you wish to make via issue,
|
|
4
|
+
email, or any other method with the owners of this repository before making a change.
|
|
5
|
+
|
|
6
|
+
Please note we have a code of conduct, please follow it in all your interactions with the project.
|
|
7
|
+
|
|
8
|
+
## Pull Request Process
|
|
9
|
+
|
|
10
|
+
1. Ensure any install or build dependencies are removed before the end of the layer when doing a
|
|
11
|
+
build.
|
|
12
|
+
2. Update the README.md with details of changes to the interface, this includes new environment
|
|
13
|
+
variables, exposed ports, useful file locations and container parameters.
|
|
14
|
+
3. Increase the version numbers in any examples files and the README.md to the new version that this
|
|
15
|
+
Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
|
|
16
|
+
4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
|
|
17
|
+
do not have permission to do that, you may request the second reviewer to merge it for you.
|
|
18
|
+
|
|
19
|
+
## Code of Conduct
|
|
20
|
+
|
|
21
|
+
### Our Pledge
|
|
22
|
+
|
|
23
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
24
|
+
contributors and maintainers pledge to making participation in our project and
|
|
25
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
26
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
27
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
28
|
+
orientation.
|
|
29
|
+
|
|
30
|
+
### Our Standards
|
|
31
|
+
|
|
32
|
+
Examples of behavior that contributes to creating a positive environment
|
|
33
|
+
include:
|
|
34
|
+
|
|
35
|
+
* Using welcoming and inclusive language
|
|
36
|
+
* Being respectful of differing viewpoints and experiences
|
|
37
|
+
* Gracefully accepting constructive criticism
|
|
38
|
+
* Focusing on what is best for the community
|
|
39
|
+
* Showing empathy towards other community members
|
|
40
|
+
|
|
41
|
+
Examples of unacceptable behavior by participants include:
|
|
42
|
+
|
|
43
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
44
|
+
advances
|
|
45
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
46
|
+
* Public or private harassment
|
|
47
|
+
* Publishing others' private information, such as a physical or electronic
|
|
48
|
+
address, without explicit permission
|
|
49
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
50
|
+
professional setting
|
|
51
|
+
|
|
52
|
+
### Our Responsibilities
|
|
53
|
+
|
|
54
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
55
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
56
|
+
response to any instances of unacceptable behavior.
|
|
57
|
+
|
|
58
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
59
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
60
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
61
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
62
|
+
threatening, offensive, or harmful.
|
|
63
|
+
|
|
64
|
+
### Scope
|
|
65
|
+
|
|
66
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
67
|
+
when an individual is representing the project or its community. Examples of
|
|
68
|
+
representing a project or community include using an official project e-mail
|
|
69
|
+
address, posting via an official social media account, or acting as an appointed
|
|
70
|
+
representative at an online or offline event. Representation of a project may be
|
|
71
|
+
further defined and clarified by project maintainers.
|
|
72
|
+
|
|
73
|
+
### Enforcement
|
|
74
|
+
|
|
75
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
76
|
+
reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
|
|
77
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
78
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
79
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
80
|
+
Further details of specific enforcement policies may be posted separately.
|
|
81
|
+
|
|
82
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
83
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
84
|
+
members of the project's leadership.
|
|
85
|
+
|
|
86
|
+
### Attribution
|
|
87
|
+
|
|
88
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
89
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
90
|
+
|
|
91
|
+
[homepage]: http://contributor-covenant.org
|
|
92
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Vahid Al
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1 +1,188 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src='docs/logo.png' height='150px' style="">
|
|
3
|
+
<p align="center">
|
|
4
|
+
A SQLite REST and Realtime server
|
|
5
|
+
</p>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
[](https://justforfunnoreally.dev)
|
|
9
|
+
[](#contributors)
|
|
10
|
+
[](https://trackgit.com)
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
Install Soul CLI with npm
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install -g soul-cli
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### 1. Running Soul
|
|
23
|
+
|
|
24
|
+
Soul is command line tool, after installing it,
|
|
25
|
+
Run `soul -d sqlite.db -p 8000` and it'll start a REST API on [http://localhost:8000](http://localhost:8000) and a Websocket server on [ws://localhost:8000](ws://localhost:8000).
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
Usage: soul [options]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
Options:
|
|
32
|
+
--version Show version number [boolean]
|
|
33
|
+
-d, --database SQLite database file or :memory: [string] [required]
|
|
34
|
+
-p, --port Port to listen on [number]
|
|
35
|
+
-r, --rate-limit-enabled Enable rate limiting [boolean]
|
|
36
|
+
-c, --cors CORS whitelist origins [string]
|
|
37
|
+
-a, --auth Enable authentication and authorization [boolean]
|
|
38
|
+
|
|
39
|
+
-iuu, --initialuserusername Initial user username [string]
|
|
40
|
+
-iup, --initialuserpassword Initial user password [string]
|
|
41
|
+
|
|
42
|
+
-ts, --tokensecret Token Secret [string]
|
|
43
|
+
-atet, --accesstokenexpirationtime Access Token Expiration Time (Default: 5H) [string]
|
|
44
|
+
-rtet, --refreshtokenexpirationtime Refresh Token Expiration Time (Default: 1D) [string]
|
|
45
|
+
-S, --studio Start Soul Studio in parallel
|
|
46
|
+
--help Show help
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Then to test Soul is working run the following command
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
curl http://localhost:8000/api/tables
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
It should return a list of the tables inside `sqlite.db` database.
|
|
57
|
+
|
|
58
|
+
### 2. Running Soul in Auth mode
|
|
59
|
+
|
|
60
|
+
To run Soul in auth mode, allowing login and signup features with authorization capabilities in your database tables, follow these steps:
|
|
61
|
+
|
|
62
|
+
Run the Soul command with the necessary parameters:
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
soul --d foobar.db -a -ts <your_jwt_secret_value> -atet=4H -rtet=3D -iuu=john -iup=<your_password>
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Note: When configuring your JWT Secret, it is recommended to use a long string value for enhanced security. It is advisable to use a secret that is at least 10 characters in length.
|
|
71
|
+
|
|
72
|
+
In this example:
|
|
73
|
+
|
|
74
|
+
The `-a` flag instructs Soul to run in auth mode.
|
|
75
|
+
The `-ts` flag allows you to pass a JWT secret value for the `access and refresh tokens` generation and verification. Replace <your_jwt_secret_value> with your desired secret value.
|
|
76
|
+
The `-atet` flag sets the JWT expiration time for the access token. In this case, it is set to four hours (4H), meaning the token will expire after 4 hours.
|
|
77
|
+
The `-rtet` flag sets the JWT expiration time for the refresh token. In this case, it is set to three days (3D), meaning the token will expire after 3 days.
|
|
78
|
+
The `-iuu` flag is used to pass a username for the initial user
|
|
79
|
+
The `-iup` flag is used to pass a password for the initial user
|
|
80
|
+
|
|
81
|
+
Here are some example values for the `-atet` and `rtet` flags
|
|
82
|
+
|
|
83
|
+
- 60M: Represents a duration of 60 minutes.
|
|
84
|
+
- 5H: Represents a duration of 5 hours.
|
|
85
|
+
- 1D: Represents a duration of 1 day.
|
|
86
|
+
|
|
87
|
+
NOTE: It is crucial to securely store a copy of the `-ts`(`Token Secret`) value used in Soul. Once you pass this values, make sure to keep a backup because you will need it every time you restart Soul. Losing this secret values can result in a situation where all of your users are blocked from accessing Soul.
|
|
88
|
+
|
|
89
|
+
### 3. Updating Super Users
|
|
90
|
+
|
|
91
|
+
To modify a superuser information in a database, you can utilize the `updatesuperuser` command. This command allows you to change a superuser's `password` or upgrade/downgrade a normal user to a `superuser`. Below is an example of how to use it:
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
soul --d foobar.db updatesuperuser --id=1 password=<new_password_for_the_user> // Update the password for the superuser with ID 1
|
|
95
|
+
|
|
96
|
+
soul --d foobar.db updatesuperuser --id=1 --is_superuser=true // Upgrade the user with ID 1 to a superuser
|
|
97
|
+
|
|
98
|
+
soul --d foobar.db updatesuperuser --id=1 --is_superuser=false // Revoke the superuser role from the superuser with ID 1
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Documentation
|
|
102
|
+
|
|
103
|
+
API documentation is available while the project is running at [http://localhost:8000/api/docs](http://localhost:8000/api/docs)
|
|
104
|
+
|
|
105
|
+
There's also a list of all endpoints examples at [docs/api-examples.md](docs/api-examples.md)
|
|
106
|
+
|
|
107
|
+
For websocket examples, check [docs/ws-examples.md](docs/ws-examples.md)
|
|
108
|
+
|
|
109
|
+
For detailed information on how authentication works in Soul, please refer to the [docs/auth.md](docs/auth.md)
|
|
110
|
+
|
|
111
|
+
## Extending Soul
|
|
112
|
+
|
|
113
|
+
Soul is able to be extended (e.g. Adding custom APIs) via extensions, you can find a list of extensions at [docs/extensions-examples.md](docs/extensions-examples.md)
|
|
114
|
+
|
|
115
|
+
## Soul-mates
|
|
116
|
+
|
|
117
|
+
A collection of projects that revolve around the Soul ecosystem.
|
|
118
|
+
|
|
119
|
+
- [Soul Studio](https://github.com/thevahidal/soul-studio) provides a GUI to work with your database.
|
|
120
|
+
|
|
121
|
+
Right now Soul Studio is in early stages of development and not useful to work with.
|
|
122
|
+
|
|
123
|
+
<p align="center">
|
|
124
|
+
<img src='docs/soul-studio.png' style="">
|
|
125
|
+
</p>
|
|
126
|
+
|
|
127
|
+
- [RCO-Soul](https://github.com/DeepBlueCLtd/RCO-Soul) The purpose of this project is to demonstrate how to run a React admin client using Soul as a REST API service.
|
|
128
|
+
|
|
129
|
+
## Development
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
git clone https://github.com/thevahidal/soul # Clone project
|
|
133
|
+
|
|
134
|
+
cp .env.sample .env # Duplicate sample environment variables
|
|
135
|
+
nano .env # Update the environment variables
|
|
136
|
+
|
|
137
|
+
npm install # Install dependencies
|
|
138
|
+
npm run dev # Start the dev server
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Testing
|
|
142
|
+
|
|
143
|
+
Set the `AUTH` variable to `true` in your `.env` file and use the command below to run the tests
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
npm run test
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Community
|
|
150
|
+
|
|
151
|
+
[Join](https://bit.ly/soul-discord) the discussion in our Discord server and help making Soul together.
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
[MIT](https://choosealicense.com/licenses/mit/)
|
|
156
|
+
|
|
157
|
+
## Contributing
|
|
158
|
+
|
|
159
|
+
Contributions are always welcome!
|
|
160
|
+
|
|
161
|
+
See `CONTRIBUTING.md` for ways to get started and please adhere to `CODE OF CONDUCT`.
|
|
162
|
+
|
|
163
|
+
## Contributors ✨
|
|
164
|
+
|
|
165
|
+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
166
|
+
|
|
167
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
168
|
+
<!-- prettier-ignore-start -->
|
|
169
|
+
<!-- markdownlint-disable -->
|
|
170
|
+
<table>
|
|
171
|
+
<tbody>
|
|
172
|
+
<tr>
|
|
173
|
+
<td align="center" valign="top" width="14.28%"><a href="http://linktr.ee/thevahidal"><img src="https://avatars.githubusercontent.com/u/20302825?v=4?s=100" width="100px;" alt="Vahid Al"/><br /><sub><b>Vahid Al</b></sub></a><br /><a href="https://github.com/thevahidal/soul/commits?author=thevahidal" title="Code">💻</a> <a href="https://github.com/thevahidal/soul/pulls?q=is%3Apr+reviewed-by%3Athevahidal" title="Reviewed Pull Requests">👀</a></td>
|
|
174
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/AbegaM"><img src="https://avatars.githubusercontent.com/u/70259638?v=4?s=100" width="100px;" alt="Abenezer Melkamu"/><br /><sub><b>Abenezer Melkamu</b></sub></a><br /><a href="https://github.com/thevahidal/soul/commits?author=AbegaM" title="Code">💻</a></td>
|
|
175
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/IanMayo"><img src="https://avatars.githubusercontent.com/u/1108513?v=4?s=100" width="100px;" alt="Ian Mayo"/><br /><sub><b>Ian Mayo</b></sub></a><br /><a href="https://github.com/thevahidal/soul/commits?author=IanMayo" title="Code">💻</a> <a href="https://github.com/thevahidal/soul/pulls?q=is%3Apr+reviewed-by%3AIanMayo" title="Reviewed Pull Requests">👀</a></td>
|
|
176
|
+
<td align="center" valign="top" width="14.28%"><a href="https://godot.id"><img src="https://avatars.githubusercontent.com/u/40712686?v=4?s=100" width="100px;" alt="Hanz"/><br /><sub><b>Hanz</b></sub></a><br /><a href="https://github.com/thevahidal/soul/commits?author=HanzCEO" title="Code">💻</a></td>
|
|
177
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/KoenDG"><img src="https://avatars.githubusercontent.com/u/1440619?v=4?s=100" width="100px;" alt="Koen De Groote"/><br /><sub><b>Koen De Groote</b></sub></a><br /><a href="https://github.com/thevahidal/soul/commits?author=KoenDG" title="Code">💻</a></td>
|
|
178
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/TahaKhanAbdalli"><img src="https://avatars.githubusercontent.com/u/50602678?v=4?s=100" width="100px;" alt="Muhammad Taha Khan"/><br /><sub><b>Muhammad Taha Khan</b></sub></a><br /><a href="https://github.com/thevahidal/soul/commits?author=TahaKhanAbdalli" title="Code">💻</a></td>
|
|
179
|
+
</tr>
|
|
180
|
+
</tbody>
|
|
181
|
+
</table>
|
|
182
|
+
|
|
183
|
+
<!-- markdownlint-restore -->
|
|
184
|
+
<!-- prettier-ignore-end -->
|
|
185
|
+
|
|
186
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
187
|
+
|
|
188
|
+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
## Root
|
|
2
|
+
|
|
3
|
+
### 1. Transaction
|
|
4
|
+
|
|
5
|
+
To start a transaction call `/transaction` endpoint with `POST` method.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
curl --request POST \
|
|
9
|
+
--url http://localhost:8000/api/transaction \
|
|
10
|
+
--header 'Content-Type: application/json' \
|
|
11
|
+
--data '{
|
|
12
|
+
"transaction": [
|
|
13
|
+
{
|
|
14
|
+
"statement": "INSERT INTO Artist (ArtistId, Name) VALUES (:id, :name)",
|
|
15
|
+
"values": { "id": 100000, "name": "Glen Hansard" }
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"query": "SELECT * FROM Artist ORDER BY ArtistId DESC LIMIT 1"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}'
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Response
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"data": [
|
|
29
|
+
{
|
|
30
|
+
"changes": 1,
|
|
31
|
+
"lastInsertRowid": 100000
|
|
32
|
+
},
|
|
33
|
+
[
|
|
34
|
+
{
|
|
35
|
+
"ArtistId": 100000,
|
|
36
|
+
"Name": "Glen Hansard"
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
```
|