test deno

This commit is contained in:
2025-04-18 03:22:29 +08:00
parent d93af32354
commit a54ba4d823
25 changed files with 1989 additions and 25 deletions

View File

@@ -0,0 +1,42 @@
{
"tasks": {
"start": "deno run --allow-all index.ts"
},
"imports": {
"@kevisual/router": "https://esm.xiongxiao.me/@kevisual/router/src/mod.ts"
},
"compilerOptions": {
"types": [
"./types",
"https://esm.xiongxiao.me/@kevisual/router@0.0.10/dist/router.d.ts"
]
},
"fmt": {
"files": {
"include": ["src/"],
"exclude": []
},
"options": {
"lineWidth": 80,
"indentWidth": 2,
"useTabs": false,
"singleQuote": false,
"proseWrap": "preserve"
}
},
"lint": {
"include": [
"./src/**/*.ts",
"index.ts"
],
"exclude": [
"./types"
],
"rules": {
"tags": ["recommended"],
"include": [],
"exclude": ["require-await"]
}
}
}

View File

@@ -0,0 +1,17 @@
{
"name": "deno-router-demo",
"version": "0.0.1",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
"license": "MIT",
"packageManager": "pnpm@10.8.1",
"type": "module",
"dependencies": {
"@kevisual/router": "^0.0.11"
}
}

83
deno-router-demo/pnpm-lock.yaml generated Normal file
View File

@@ -0,0 +1,83 @@
lockfileVersion: '9.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
importers:
.:
dependencies:
'@kevisual/router':
specifier: ^0.0.11
version: 0.0.11
packages:
'@kevisual/router@0.0.11':
resolution: {integrity: sha512-i/gVqIv3UpjdyS0zZHoDWYTBnL4YWGmj/8O8GQV7xxXZXJPRXLHjLC1ylRhwEGBdb6UxabKohplr7HKRuIJ2Ag==}
'@types/node-forge@1.3.11':
resolution: {integrity: sha512-FQx220y22OKNTqaByeBGqHWYz4cl94tpcxeFdvBo3wjG6XPBuZ0BNgNZRV5J5TFmmcsJ4IzsLkmGRiQbnYsBEQ==}
'@types/node@22.14.1':
resolution: {integrity: sha512-u0HuPQwe/dHrItgHHpmw3N2fYCR6x4ivMNbPHRkBVP4CvN+kiRrKHWk3i8tXiO/joPwXLMYvF9TTF0eqgHIuOw==}
node-forge@1.3.1:
resolution: {integrity: sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==}
engines: {node: '>= 6.13.0'}
path-to-regexp@8.2.0:
resolution: {integrity: sha512-TdrF7fW9Rphjq4RjrW0Kp2AW0Ahwu9sRGTkS6bvDi0SCwZlEZYmcfDbEsTz8RVk0EHIS/Vd1bv3JhG+1xZuAyQ==}
engines: {node: '>=16'}
selfsigned@2.4.1:
resolution: {integrity: sha512-th5B4L2U+eGLq1TVh7zNRGBapioSORUeymIydxgFpwww9d2qyKvtuPU2jJuHvYAwwqi2Y596QBL3eEqcPEYL8Q==}
engines: {node: '>=10'}
undici-types@6.21.0:
resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==}
ws@8.18.1:
resolution: {integrity: sha512-RKW2aJZMXeMxVpnZ6bck+RswznaxmzdULiBr6KY7XkTnW8uvt0iT9H5DkHUChXrc+uurzwa0rVI16n/Xzjdz1w==}
engines: {node: '>=10.0.0'}
peerDependencies:
bufferutil: ^4.0.1
utf-8-validate: '>=5.0.2'
peerDependenciesMeta:
bufferutil:
optional: true
utf-8-validate:
optional: true
snapshots:
'@kevisual/router@0.0.11':
dependencies:
path-to-regexp: 8.2.0
selfsigned: 2.4.1
ws: 8.18.1
transitivePeerDependencies:
- bufferutil
- utf-8-validate
'@types/node-forge@1.3.11':
dependencies:
'@types/node': 22.14.1
'@types/node@22.14.1':
dependencies:
undici-types: 6.21.0
node-forge@1.3.1: {}
path-to-regexp@8.2.0: {}
selfsigned@2.4.1:
dependencies:
'@types/node-forge': 1.3.11
node-forge: 1.3.1
undici-types@6.21.0: {}
ws@8.18.1: {}

View File

@@ -0,0 +1,32 @@
// import { App } from '@kevisual/router';
import { App } from '@kevisual/router/mod.ts';
console.log('meta', import.meta.url);
// deno run --allow-all index.ts
// deno run --config ./deno.json --allow-all index.ts
console.log('hello world');
const app = new App({
io: true,
});
app
.route({
path: 'demo',
})
.define(async (ctx) => {
ctx.body = 'hello world';
})
.addTo(app);
app.listen(10004, () => {
console.log('Server is running on http://localhost:10004');
});
app.io.addListener('goo', async ({ data, ws, end }) => {
console.log('goo', data);
end({
code: 200,
message: 'hello world goo',
});
});

View File

@@ -0,0 +1,28 @@
const ws = new WebSocket('ws://localhost:10004/api/router');
ws.onopen = () => {
console.log('open');
};
ws.onmessage = (event) => {
console.log('message', event.data);
const data = event.data;
if (data === 'connected') {
const data = {
type: 'router',
requestId: 'requestId',
data: {
path: 'demo',
},
};
ws.send(JSON.stringify(data));
const data2= {
type: 'goo'
};
ws.send(JSON.stringify(data2));
}
};
ws.onerror = (event) => {
console.log('error', event);
};

View File

@@ -0,0 +1,41 @@
{
"compilerOptions": {
"module": "NodeNext",
"target": "esnext",
"noImplicitAny": false,
"outDir": "./dist",
"sourceMap": false,
"allowJs": true,
"newLine": "LF",
"baseUrl": "./",
"typeRoots": [
"node_modules/@types",
"src/@types"
],
"declaration": true,
"noEmit": false,
// "allowImportingTsExtensions": true,
"moduleResolution": "NodeNext",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"paths": {
"@/*": [
"src/*"
],
"*": [
"types/*"
]
}
},
"include": [
"typings.d.ts",
"src/**/*.ts"
],
"exclude": [
"node_modules",
"dist",
"src/**/*.test.ts",
"webpack.config.cjs",
],
}