Skip to content

Commit

Permalink
docs: ensure the document/api collection is in sync with the current …
Browse files Browse the repository at this point in the history
…work (#334)
  • Loading branch information
kshitij-k-osmosys authored Sep 27, 2024
1 parent 9a28d3c commit 0dfda30
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 32 deletions.
4 changes: 3 additions & 1 deletion apps/api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ CLEANUP_IDLE_RESOURCES=false # Cleans up idle queues if inactive for the specifi
IDLE_TIMEOUT=30m # How long the queue should be idle before being considered for deletion, default 30m
CLEANUP_INTERVAL=7d # Frequency for running the cleanup, use formats from https://github.com/vercel/ms, default 7d
JWT_SECRET=your-strong-secret-key-here # A strong secret key for signing your JWTs. This should be a long, random string.
JWT_EXPIRES_IN=30d #Common formats are '60s', '10m', '1h', '1d', etc
JWT_EXPIRES_IN=30d # Common formats are '60s', '10m', '1h', '1d', etc
SALT_ROUNDS=10 # Number of salt rounds for bcrypt
API_KEY_SECRET=your-secret # Replace with a strong, unique secret for API authentication

# Node env
NODE_ENV= # Use "development" for graphql playground to work
Expand Down
90 changes: 87 additions & 3 deletions apps/api/OsmoX.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -4029,13 +4029,13 @@
"pm.test(\"Response is valid JSON\", function () {\r",
" pm.response.to.be.json;\r",
"});\r",
"pm.test(\"Response has valid 'data' and 'webhook' properties\", function () {\r",
"pm.test(\"Response has valid 'data' property\", function () {\r",
" var jsonData = pm.response.json();\r",
" pm.expect(jsonData).to.have.property(\"data\").to.be.an(\"object\");\r",
"});\r",
"pm.test(\"Response 'data' has valid 'webhook' property\", function () {\r",
" var jsonData = pm.response.json();\r",
" pm.expect(jsonData).to.have.property(\"data\").to.have.property(\"webhook\").to.be.an(\"object\");\r",
" pm.expect(jsonData).to.have.property(\"data\").to.have.property(\"webhook\").to.be.an(\"object\");\r",
"});\r",
""
],
Expand Down Expand Up @@ -4237,6 +4237,90 @@
"pm.test(\"Response is valid JSON\", function () {",
" pm.response.to.be.json;",
"});",
"pm.test(\"Response has valid 'data' property\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData).to.have.property(\"data\").to.be.an(\"object\");",
"});",
"pm.test(\"Response 'data' has valid 'generateApiKey' property\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData).to.have.property(\"data\").to.have.property(\"generateApiKey\")",
"});",
""
],
"type": "text/javascript",
"packages": {}
}
},
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{auth-token}}"
}
],
"body": {
"mode": "graphql",
"graphql": {
"query": "mutation GenerateApiKey($applicationId: Int!) {\n generateApiKey(applicationId: $applicationId)\n}",
"variables": "{\n \"applicationId\": 3\n}"
}
},
"url": {
"raw": "http://localhost:3000/graphql",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"graphql"
]
},
"description": "Allows successfully generating a new server key based on the options passed."
},
"response": []
},
{
"name": "Generate New Key - Error - unknown Application",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Response is valid JSON\", function () {",
" pm.response.to.be.json;",
"});",
"pm.test(\"Response has valid 'errors' and 'data' properties\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData).to.have.property(\"data\");",
" pm.expect(jsonData).to.have.property(\"errors\").to.be.an(\"array\");",
"});",
""
],
"type": "text/javascript",
"packages": {}
}
},
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript",
Expand All @@ -4260,7 +4344,7 @@
"mode": "graphql",
"graphql": {
"query": "mutation GenerateApiKey($applicationId: Int!) {\n generateApiKey(applicationId: $applicationId)\n}",
"variables": "{\n \"applicationId\": 1\n}"
"variables": "{\n \"applicationId\": 300\n}"
}
},
"url": {
Expand Down
30 changes: 4 additions & 26 deletions apps/api/docs/api-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ Note: Only users with `Admin` role get list of all keys. Returns `null` for user
mutation LoginUser {
login(loginUserInput: { username: "admin", password: "mysecurepassword" }) {
token
user
allKeys {
apiKeyId
apiKey
applicationId
status
}
__typename
}
}
Expand All @@ -42,9 +35,9 @@ mutation LoginUser {
**cURL**

```sh
curl --location 'http://localhost:3000/graphql' \
curl --location 'localhost:3000/graphql' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"mutation LoginUser {\n login(loginUserInput: { username: \"admin\", password: \"mysecurepassword\" }) {\n token\n user\n allKeys {\n apiKeyId\n apiKey\n applicationId\n status\n }\n __typename\n }\n}","variables":{}}'
--data '{"query":"mutation LoginUser {\n login(loginUserInput: { username: \"admin\", password: \"mysecurepassword\" }) {\n token\n __typename\n }\n}","variables":{}}'
```

**Sample response**
Expand All @@ -53,22 +46,7 @@ curl --location 'http://localhost:3000/graphql' \
{
"data": {
"login": {
"token": "mysecuretoken",
"user": "admin",
"allKeys": [
{
"apiKeyId": 1,
"apiKey": "test-api-key",
"applicationId": 1,
"status": 1
},
{
"apiKeyId": 2,
"apiKey": "test-api-key-2",
"applicationId": 2,
"status": 1
}
],
"token": "eymysecuretoken",
"__typename": "LoginResponse"
}
}
Expand Down Expand Up @@ -186,7 +164,7 @@ query {
sortBy: "createdOn"
sortOrder: DESC
search: "[email protected]"
filters: [{ field: "channelType", operator: "eq", value: "1" }]
filters: [{ field: "applicationId", operator: "eq", value: "1" }]
}
) {
notifications {
Expand Down
4 changes: 3 additions & 1 deletion apps/api/docs/development-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ sudo systemctl status mariadb
IDLE_TIMEOUT=30m # How long the queue should be idle before being considered for deletion, default 30m
CLEANUP_INTERVAL=7d # Frequency for running the cleanup, use formats from https://github.com/vercel/ms, default 7d
JWT_SECRET=your-strong-secret-key-here # A strong secret key for signing your JWTs. This should be a long, random string.
JWT_EXPIRES_IN=30d #Common formats are '60s', '10m', '1h', '1d', etc
JWT_EXPIRES_IN=30d # Common formats are '60s', '10m', '1h', '1d', etc
SALT_ROUNDS=10 # Number of salt rounds for bcrypt
API_KEY_SECRET=your-secret # Replace with a strong, unique secret for API authentication
# Node env
NODE_ENV=development
Expand Down
4 changes: 3 additions & 1 deletion apps/api/docs/production-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ Make sure Redis and MariaDB server are up and running.
IDLE_TIMEOUT=30m # How long the queue should be idle before being considered for deletion, default 30m
CLEANUP_INTERVAL=7d # Frequency for running the cleanup, use formats from https://github.com/vercel/ms, default 7d
JWT_SECRET=your-strong-secret-key-here # A strong secret key for signing your JWTs. This should be a long, random string.
JWT_EXPIRES_IN=30d #Common formats are '60s', '10m', '1h', '1d', etc
JWT_EXPIRES_IN=30d # Common formats are '60s', '10m', '1h', '1d', etc
SALT_ROUNDS=10 # Number of salt rounds for bcrypt
API_KEY_SECRET=your-secret # Replace with a strong, unique secret for API authentication
# Node env
NODE_ENV=production # Use "development" for graphql playground to work
Expand Down

0 comments on commit 0dfda30

Please sign in to comment.