Skip to content

Commit

Permalink
test: 增加 js server 端工程化测试用例
Browse files Browse the repository at this point in the history
  • Loading branch information
pannanxu committed Oct 31, 2024
1 parent f0a9d48 commit 9c67d37
Show file tree
Hide file tree
Showing 12 changed files with 731 additions and 1 deletion.
24 changes: 24 additions & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
3 changes: 3 additions & 0 deletions server/lib/apis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const register = (path: string) => {
console.log('register', path);
};
30 changes: 30 additions & 0 deletions server/lib/commons/halo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
declare global {

export class Mono<T = any> {
static just<T>(value: T): Mono<T> ;
}

export class SearchService<T = any> {

constructor(_config: SearchServiceConfig)

}

export interface SearchOption {
// 根据实际需要添加属性
[key: string]: any;
}

export interface SearchResult {
keyword: string;
// 其他可能的结果字段
}

export type SearchFunction = (option: SearchOption) => Mono<SearchResult>;

export interface SearchServiceConfig {
search: SearchFunction;
}


}
9 changes: 9 additions & 0 deletions server/lib/commons/using.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

export function using<T>(path: string) {
// @ts-ignore
return Java.type(path) as T
}
export function extend<T>(type: any) {
// @ts-ignore
return Java.extend(type) as T
}
15 changes: 15 additions & 0 deletions server/lib/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {register} from "./apis.ts";

export const createImplSearchService = () => {
const impl = new SearchService({
search: (option) => {
register('hello')
console.log(option);
debugger
return Mono.just({
keyword: "test"
});
}
});
return impl;
};
2 changes: 2 additions & 0 deletions server/lib/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// <reference types="vite/client" />

19 changes: 19 additions & 0 deletions server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "script-server",
"private": true,
"version": "0.0.0",
"type": "module",
"module": "main.mjs",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"devDependencies": {
"typescript": "~5.6.2",
"vite": "^5.4.9"
},
"dependencies": {
"@types/node": "^22.8.4"
}
}
Loading

0 comments on commit 9c67d37

Please sign in to comment.