diff --git a/uniquely/com-api/demo-data.http b/uniquely/com-api/demo-data.http index a813949a2..3ad0a2025 100644 --- a/uniquely/com-api/demo-data.http +++ b/uniquely/com-api/demo-data.http @@ -56,7 +56,6 @@ PATCH {{apiUrl}}/price-list/?name=tile-market-ir Authorization: Bearer {{adminToken}} Content-Type: application/json - { "data": [ { @@ -99,7 +98,6 @@ PATCH {{apiUrl}}/price-list/?name=tile-agency-ir Authorization: Bearer {{adminToken}} Content-Type: application/json - { "data": [ { diff --git a/uniquely/com-api/demo.http b/uniquely/com-api/demo.http index 48ca624e4..8009a103c 100644 --- a/uniquely/com-api/demo.http +++ b/uniquely/com-api/demo.http @@ -39,7 +39,6 @@ PATCH {{apiUrl}}/price-list/?name=tile-agency-ir Authorization: Bearer {{adminToken}} Content-Type: application/json - { "data": [ { @@ -84,5 +83,5 @@ client-id: 2b6861f4-a8d7-4065-a5a5-3caa54b71a20 } ### Get all orders list of special user -get {{apiUrl}}/order/?userId=abc123 +get {{apiUrl}}/order-list/?userId=abc123 Authorization: Bearer {{userToken}} diff --git a/uniquely/com-api/src/index.ts b/uniquely/com-api/src/index.ts index b6d91575c..ae4284ac0 100644 --- a/uniquely/com-api/src/index.ts +++ b/uniquely/com-api/src/index.ts @@ -1,7 +1,7 @@ import {logger} from './lib/config.js'; import './route/home.js'; -import './route/get-order.js'; +import './route/get-order-list.js'; import './route/get-product-list.js'; import './route/get-price-list.js'; import './route/put-order.js'; diff --git a/uniquely/com-api/src/lib/storage.ts b/uniquely/com-api/src/lib/storage.ts index 841a0e0d7..86be2e6df 100644 --- a/uniquely/com-api/src/lib/storage.ts +++ b/uniquely/com-api/src/lib/storage.ts @@ -2,4 +2,4 @@ import {AlwatrStorageClient} from '@alwatr/storage-client'; import {config} from './config.js'; -export const storageClient = new AlwatrStorageClient(config.storage); +export const storageClient = new AlwatrStorageClient(config.storageClient); diff --git a/uniquely/com-api/src/route/get-order.ts b/uniquely/com-api/src/route/get-order-list.ts similarity index 57% rename from uniquely/com-api/src/route/get-order.ts rename to uniquely/com-api/src/route/get-order-list.ts index a724dbe73..2c02cf133 100644 --- a/uniquely/com-api/src/route/get-order.ts +++ b/uniquely/com-api/src/route/get-order-list.ts @@ -4,15 +4,12 @@ import {storageClient} from '../lib/storage.js'; import type {Order} from '@alwatr/type/customer-order-management.js'; -// Get all orders of special customer -nanoServer.route('GET', '/order/', async (connection) => { +/** + * Get all orders of special user. + */ +nanoServer.route('GET', '/order-list/', async (connection) => { logger.logMethod('get-order'); - - const params = connection.requireQueryParams<{userId: string}>({userId: 'string'}); - // connection.requireToken((token: string) => { - // return tokenGenerator.verify(params.userId, token) === 'valid'; - // }); connection.requireToken(config.nanoServer.accessToken); - - return await storageClient.getStorage(params.userId); + const params = connection.requireQueryParams<{userId: string}>({userId: 'string'}); + return await storageClient.getStorage(config.orderStoragePrefix + params.userId); }); diff --git a/uniquely/com-api/src/route/get-price-list.ts b/uniquely/com-api/src/route/get-price-list.ts index 6514a73b6..cbc9f3fe6 100644 --- a/uniquely/com-api/src/route/get-price-list.ts +++ b/uniquely/com-api/src/route/get-price-list.ts @@ -8,5 +8,5 @@ nanoServer.route('GET', '/price-list/', async (connection) => { logger.logMethod('get-price-list'); connection.requireToken(config.nanoServer.accessToken); const params = connection.requireQueryParams<{name: string}>({name: 'string'}); - return await storageClient.getStorage(config.storage.priceStorageName + '-' + params.name); + return await storageClient.getStorage(config.priceStoragePrefix + params.name); }); diff --git a/uniquely/com-api/src/route/get-product-list.ts b/uniquely/com-api/src/route/get-product-list.ts index 65de576c4..aa8d83e7b 100644 --- a/uniquely/com-api/src/route/get-product-list.ts +++ b/uniquely/com-api/src/route/get-product-list.ts @@ -8,5 +8,5 @@ nanoServer.route('GET', '/product-list/', async (connection) => { logger.logMethod('get-product-list'); connection.requireToken(config.nanoServer.accessToken); const params = connection.requireQueryParams<{name: string}>({name: 'string'}); - return await storageClient.getStorage(config.storage.productStorageName + '-' + params.name); + return await storageClient.getStorage(config.productStoragePrefix + params.name); }); diff --git a/uniquely/com-api/src/route/patch-price-list.ts b/uniquely/com-api/src/route/patch-price-list.ts index 45b0a2924..69d20ab51 100644 --- a/uniquely/com-api/src/route/patch-price-list.ts +++ b/uniquely/com-api/src/route/patch-price-list.ts @@ -11,7 +11,7 @@ nanoServer.route('PATCH', '/price-list/', async (connection) => { const bodyJson = await connection.requireJsonBody<{data: Array}>(); for (const price of bodyJson.data) { - await storageClient.set(price, config.storage.priceStorageName + '-' + params.name); + await storageClient.set(price, config.priceStoragePrefix + params.name); } return { diff --git a/uniquely/com-api/src/route/patch-product-list.ts b/uniquely/com-api/src/route/patch-product-list.ts index 603f38556..397865b06 100644 --- a/uniquely/com-api/src/route/patch-product-list.ts +++ b/uniquely/com-api/src/route/patch-product-list.ts @@ -11,7 +11,7 @@ nanoServer.route('PATCH', '/product-list/', async (connection) => { const bodyJson = await connection.requireJsonBody<{data: Array}>(); for (const price of bodyJson.data) { - await storageClient.set(price, config.storage.productStorageName + '-' + params.name); + await storageClient.set(price, config.productStoragePrefix + params.name); } return { diff --git a/uniquely/com-api/src/route/put-order.ts b/uniquely/com-api/src/route/put-order.ts index ca0bc06a1..2c52c94ab 100644 --- a/uniquely/com-api/src/route/put-order.ts +++ b/uniquely/com-api/src/route/put-order.ts @@ -8,11 +8,8 @@ import type {Order} from '@alwatr/type/customer-order-management.js'; nanoServer.route('PUT', '/order/', async (connection) => { logger.logMethod('put-order'); - const params = connection.requireQueryParams<{userId: string}>({userId: 'string'}); - // connection.requireToken((token: string) => { - // return tokenGenerator.verify(params.userId, token) === 'valid'; - // }); connection.requireToken(config.nanoServer.accessToken); + const params = connection.requireQueryParams<{userId: string}>({userId: 'string'}); const remoteAddress = connection.getRemoteAddress(); const clientId = connection.requireClientId();