Skip to content

Commit

Permalink
feat: use share api
Browse files Browse the repository at this point in the history
  • Loading branch information
ooooorobo committed Aug 12, 2023
1 parent 0132812 commit f14f240
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
@@ -1,9 +1,9 @@
import { apiClient } from '../ApiClient';
import { BandalartCell, BandalartCellSchema } from '../../types/BandalartCell';

export const getBandalartCells = async (
export const getSharedBandalartCells = async (
key: string,
): Promise<BandalartCell> => {
const response = await apiClient().get(`/v1/bandalarts/${key}/cells`);
const response = await apiClient().get(`/v1/shares/${key}/bandalarts/cells`);
return BandalartCellSchema.parse(response.data);
};
Expand Up @@ -4,9 +4,9 @@ import {
BandalartDetailSchema,
} from '../../types/BandalartDetail';

export const getBandalartDetailByKey = async (
export const getSharedBandalartDetailByKey = async (
key: string,
): Promise<BandalartDetail> => {
const response = await apiClient().get(`/v1/bandalarts/${key}`);
const response = await apiClient().get(`/v1/shares/${key}/bandalarts`);
return BandalartDetailSchema.parse(response.data);
};
2 changes: 1 addition & 1 deletion src/index.ts
Expand Up @@ -15,5 +15,5 @@ app.use(serve(__dirname + '/public'));

app.listen(PORT, () => {
console.log(`Server is running on http://${HOST}:${PORT}`);
console.log(`Quick link -> http://${HOST}:${PORT}/share/9H3bp`);
console.log(`Quick link -> http://${HOST}:${PORT}/share/Ha63U`);
});
8 changes: 4 additions & 4 deletions src/server/route/viewRoute.ts
@@ -1,7 +1,7 @@
import Router from '@koa/router';
import { initApiClient } from '../../agent/ApiClient';
import { getBandalartDetailByKey } from '../../agent/bandalart/getBandalartDetailByKey';
import { getBandalartCells } from '../../agent/bandalart/getBandalartCells';
import { getSharedBandalartDetailByKey } from '../../agent/shares/getSharedBandalartDetailByKey';
import { getSharedBandalartCells } from '../../agent/shares/getSharedBandalartCells';
import { renderer } from '../../client/renderer';
import { createStore } from '../../client/stores/createStore';

Expand All @@ -11,8 +11,8 @@ viewRouter.get('/share/:key', async (ctx) => {
try {
initApiClient();
const key = ctx.params.key;
const bandalartDetail = await getBandalartDetailByKey(key);
const bandalartCells = await getBandalartCells(key);
const bandalartDetail = await getSharedBandalartDetailByKey(key);
const bandalartCells = await getSharedBandalartCells(key);
ctx.response.body = renderer({
assetPath: process.env.ASSET_PATH ?? '',
store: createStore({
Expand Down

0 comments on commit f14f240

Please sign in to comment.