Skip to content

Commit a7fd7ae

Browse files
FinleyGexqvvuc121914yu
authored
Dev/v0.5.0 (#358)
* refactor: remove ts-rest (#356) * refactor: remove ts-rest - use Hono as HTTP framework - use logtape as logger - update sdk - bump zod from v3 to v4 and more structure adjustment * fix: lint erros * feat: update storage options (#353) * chore: more logs * clean code * chore: bump storage sdk version --------- Co-authored-by: Finley Ge <[email protected]> * fix: adjust parse schema (#357) * chore: upgrade bun version * fix: type error * fix: log color * chore: bump sdk to v0.3.6 * chore: use env to handle STORAGE_PUBLIC_ACCESS_EXTRA_SUB_PATH * chore: use tsdown to build sdk * fix: disable cache default value false * add log --------- Co-authored-by: roy <[email protected]> Co-authored-by: archer <[email protected]>
1 parent 9f32a85 commit a7fd7ae

File tree

239 files changed

+3195
-2275
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

239 files changed

+3195
-2275
lines changed

.github/workflows/build-image-preview.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ jobs:
7272

7373
- name: Setup bun
7474
uses: oven-sh/setup-bun@v2
75-
with:
76-
bun-version: 1.2.23
7775

7876
- name: Install dependencies
7977
run: bun install --frozen-lockfile && bun run install:plugins

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"search.exclude": {
3+
"bun.lock": true,
4+
},
25
"editor.formatOnSave": true,
36
"editor.mouseWheelZoom": true,
47
"editor.defaultFormatter": "esbenp.prettier-vscode",
@@ -10,4 +13,4 @@
1013
"[typescriptreact]": {
1114
"editor.defaultFormatter": "esbenp.prettier-vscode"
1215
}
13-
}
16+
}

bun.lock

Lines changed: 254 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/@types/hono.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { Logger } from '@logtape/logtape';
2+
3+
declare global {
4+
type Env = {
5+
Variables: {
6+
logger: Logger;
7+
requestId: string;
8+
};
9+
};
10+
}

lib/@types/http.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
interface Result<T> {
2+
code: number;
3+
msg: string;
4+
data?: T | null;
5+
}

lib/cache/index.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import type { SystemCacheKeyEnum } from './type';
22
import { randomUUID } from 'node:crypto';
33
import { initCache } from './init';
44
import { getGlobalRedisConnection } from '@/redis';
5+
import { env } from '@/env';
6+
import { getLogger } from '@logtape/logtape';
7+
import { infra } from '@/logger';
58

69
const cachePrefix = `VERSION_KEY:`;
710

@@ -20,19 +23,31 @@ export const refreshVersionKey = async (key: `${SystemCacheKeyEnum}`) => {
2023
if (!global.systemCache) initCache();
2124
const val = randomUUID();
2225
const redis = getGlobalRedisConnection();
26+
27+
const logger = getLogger(infra.redis);
28+
29+
logger.info('refreshing cache key', {
30+
key
31+
});
2332
await redis.set(`${cachePrefix}${key}`, val);
2433
};
2534

2635
export const getCachedData = async (key: `${SystemCacheKeyEnum}`) => {
2736
if (!global.systemCache) initCache();
2837

2938
const versionKey = await getVersionKey(key);
30-
const isDisableCache = process.env.DISABLE_CACHE === 'true';
39+
const isDisableCache = env.DISABLE_CACHE;
3140

3241
if (global.systemCache[key].versionKey === versionKey && !isDisableCache) {
3342
return global.systemCache[key].data;
3443
}
3544

45+
const logger = getLogger(infra.redis);
46+
47+
logger.info('refreshing cache data', {
48+
key
49+
});
50+
3651
global.systemCache[key].versionKey = versionKey;
3752
global.systemCache[key].data = await global.systemCache[key].refreshFunc();
3853

lib/cache/init.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { initTools } from '@tool/init';
22
import { SystemCacheKeyEnum } from './type';
3+
import { getLogger } from '@logtape/logtape';
4+
import { infra } from '@/logger';
35

46
export const initCache = () => {
7+
const logger = getLogger(infra.redis);
8+
logger.info('initing cache');
59
global.systemCache = {
610
[SystemCacheKeyEnum.systemTool]: {
711
versionKey: '',

lib/constants/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
export const isProd = process.env.NODE_ENV === 'production';
1+
import { env } from '@/env';
2+
3+
export const isProd = env.NODE_ENV === 'production';

lib/contract/client.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

lib/contract/index.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)