-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(com-api): admin user-list-inc-order route (#1189)
- Loading branch information
Showing
7 changed files
with
392 additions
and
360 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import {logger} from './lib/config.js'; | ||
import './root-user.js'; | ||
import './route/admin/user-list-inc-order.js'; | ||
import './route/home.js'; | ||
import './route/patch-price-list.js'; | ||
import './route/patch-product-list.js'; | ||
import './route/patch-user.js'; | ||
import './route/put-order.js'; | ||
import './route/user-list.js'; | ||
|
||
logger.logOther?.('..:: Alwatr Customer Order Management API ::..'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {config} from './config.js'; | ||
import {storageClient} from './storage.js'; | ||
|
||
import type {AlwatrDocumentStorage} from '@alwatr/type'; | ||
import type {ComUserIncOrder, Order} from '@alwatr/type/src/customer-order-management.js'; | ||
|
||
export const getUserOrder = (userId: string): Promise<AlwatrDocumentStorage<Order>> => { | ||
return storageClient.getStorage<Order>(config.privateStorage.userOrderList.replace('${userId}', userId)); | ||
}; | ||
|
||
export const patchUserOrder = (userId: string, order: Order): Promise<Order> => { | ||
return storageClient.set<Order>(order, config.privateStorage.userOrderList.replace('${userId}', userId)); | ||
}; | ||
|
||
export const getUserListIncOrder = async (): Promise<Record<string, ComUserIncOrder>> => { | ||
const userList = (await storageClient.getStorage<ComUserIncOrder>(config.privateStorage.userList)).data; | ||
|
||
for (const user of Object.values(userList)) { | ||
if (!Object.prototype.hasOwnProperty.call(userList, user.id)) continue; | ||
user.orderList = (await getUserOrder(user.id)).data; | ||
} | ||
|
||
return userList; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {logger} from '../../lib/config.js'; | ||
import {nanoServer} from '../../lib/server.js'; | ||
import {getUserListIncOrder} from '../../lib/user-order.js'; | ||
import {validateUserAuth} from '../../lib/validate-user-auth.js'; | ||
|
||
import type {ComUser} from '@alwatr/type/customer-order-management.js'; | ||
|
||
nanoServer.route<Record<string, ComUser>>('GET', '/admin/user-list-inc-order', async (connection) => { | ||
logger.logMethod?.('get-admin-user-list-inc-order'); | ||
|
||
await validateUserAuth(connection.getUserAuth(), 'user-list-inc-order/read'); | ||
|
||
return { | ||
ok: true, | ||
data: await getUserListIncOrder(), | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.