Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(storage-server): default configs #428

Merged
merged 2 commits into from
Nov 23, 2022
Merged
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
28 changes: 14 additions & 14 deletions packages/service/storage-server/demo.http
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
@apiUrl = http://localhost:80
@apiUrl = http://127.0.0.1:9000
@apiVersion = v0
@token = alwatr_110_313
@token = YOUR_SECRET_TOKEN

### Get a public storage over nginx serve
# GET {{apiUrl}}/{{apiVersion}}/public/comments/page1.json

### Get a document by storageName and docId
GET {{apiUrl}}/{{apiVersion}}/?storage=comments/page1&id=c1
authorization: Bearer {{token}}
Authorization: Bearer {{token}}

### Insert document
PATCH {{apiUrl}}/{{apiVersion}}/?storage=comments/page1
authorization: Bearer {{token}}
Authorization: Bearer {{token}}
Content-Type: application/json

{
Expand All @@ -23,7 +23,7 @@ Content-Type: application/json

###
PATCH {{apiUrl}}/{{apiVersion}}/?storage=comments/page1
authorization: Bearer {{token}}
Authorization: Bearer {{token}}
Content-Type: application/json

{
Expand All @@ -35,7 +35,7 @@ Content-Type: application/json

### Edit document
PATCH {{apiUrl}}/{{apiVersion}}/?storage=comments/page1
authorization: Bearer {{token}}
Authorization: Bearer {{token}}
Content-Type: application/json

{
Expand All @@ -47,19 +47,19 @@ Content-Type: application/json

### Check document exists by storageName and docId
GET {{apiUrl}}/{{apiVersion}}/has?storage=comments/page1&id=c1
authorization: Bearer {{token}}
Authorization: Bearer {{token}}

### Delete document
DELETE {{apiUrl}}/{{apiVersion}}/?storage=comments/page1&id=c1
authorization: Bearer {{token}}
Authorization: Bearer {{token}}

### Get keys
GET {{apiUrl}}/{{apiVersion}}/keys?storage=comments/page1
authorization: Bearer {{token}}
Authorization: Bearer {{token}}

### Get all data
GET {{apiUrl}}/{{apiVersion}}/all?storage=comments/page1
authorization: Bearer {{token}}
Authorization: Bearer {{token}}

### === Test other routes and errors ===

Expand All @@ -77,21 +77,21 @@ TRACE {{apiUrl}}/{{apiVersion}}

### Document not exists
GET {{apiUrl}}/{{apiVersion}}/has?storage=comments/page1&id=foo
authorization: Bearer {{token}}
Authorization: Bearer {{token}}


### Get a document by storageName without id
GET {{apiUrl}}/{{apiVersion}}/?storage=comments/page1
authorization: Bearer {{token}}
Authorization: Bearer {{token}}

### empty body
PATCH {{apiUrl}}/{{apiVersion}}/?storage=comments/page1
authorization: Bearer {{token}}
Authorization: Bearer {{token}}
Content-Type: application/json

### invalid json
PATCH {{apiUrl}}/{{apiVersion}}/?storage=comments/page1
authorization: Bearer {{token}}
Authorization: Bearer {{token}}
Content-Type: application/json

{
Expand Down
4 changes: 2 additions & 2 deletions packages/service/storage-server/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ export const logger = createLogger('service-storage');

export const config = {
host: process.env.HOST ?? '0.0.0.0',
port: process.env.PORT != null ? +process.env.PORT : 80,
port: process.env.PORT != null ? +process.env.PORT : 9000,
storagePath: process.env.STORAGE_PATH ?? 'db',
token: process.env.TOKEN ?? 'alwatr_110_313',
token: process.env.TOKEN ?? 'YOUR_SECRET_TOKEN',
};

logger.logProperty('config', {...config, token: '***'});