Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 67bbea8811 | |||
| dc826cb65a | |||
| 1266a814c6 | |||
| 25a7397548 | |||
| 5009bec70c | |||
| d8d7b135f7 |
@@ -12,29 +12,25 @@ stages:
|
||||
- release
|
||||
- metadata
|
||||
|
||||
before_script:
|
||||
- pnpm install -g pnpm
|
||||
- pnpm install -g @shipzone/npmci
|
||||
- npmci npm prepare
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --production --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command pnpm audit --audit-level=high --prod
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
@@ -42,11 +38,10 @@ auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=dev
|
||||
- npmci command pnpm audit --audit-level=high --dev
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
@@ -57,7 +52,6 @@ auditDevDependencies:
|
||||
testStable:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
@@ -68,7 +62,6 @@ testStable:
|
||||
testBuild:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
@@ -97,10 +90,9 @@ codequality:
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci command npm install -g typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
@@ -120,11 +112,9 @@ trigger:
|
||||
pages:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci node install lts
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command tsdoc
|
||||
- npmci command npm run buildDocs
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
|
||||
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@@ -2,28 +2,10 @@
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "current file",
|
||||
"type": "node",
|
||||
"command": "npm test",
|
||||
"name": "Run npm test",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"${relativeFile}"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
},
|
||||
{
|
||||
"name": "test.ts",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"test/test.ts"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@apiglobal/typedsocket",
|
||||
"version": "2.0.7",
|
||||
"version": "2.0.10",
|
||||
"private": false,
|
||||
"description": "a typedrequest extension supporting websockets",
|
||||
"main": "dist_ts/index.js",
|
||||
@@ -10,7 +10,8 @@
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(tstest test/ --web)",
|
||||
"build": "(tsbuild --web --allowimplicitany)"
|
||||
"build": "(tsbuild --web --allowimplicitany)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.63",
|
||||
@@ -23,9 +24,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@apiglobal/typedrequest": "^2.0.8",
|
||||
"@apiglobal/typedrequest-interfaces": "^1.0.15",
|
||||
"@apiglobal/typedrequest-interfaces": "2.0.0",
|
||||
"@pushrocks/isohash": "^2.0.0",
|
||||
"@pushrocks/smartjson": "^5.0.2",
|
||||
"@pushrocks/smartjson": "^5.0.4",
|
||||
"@pushrocks/smartsocket": "^2.0.7",
|
||||
"@pushrocks/smartstring": "^4.0.2"
|
||||
},
|
||||
|
||||
26
pnpm-lock.yaml
generated
26
pnpm-lock.yaml
generated
@@ -2,14 +2,14 @@ lockfileVersion: 5.4
|
||||
|
||||
specifiers:
|
||||
'@apiglobal/typedrequest': ^2.0.8
|
||||
'@apiglobal/typedrequest-interfaces': ^1.0.15
|
||||
'@apiglobal/typedrequest-interfaces': 2.0.0
|
||||
'@gitzone/tsbuild': ^2.1.63
|
||||
'@gitzone/tsbundle': ^2.0.6
|
||||
'@gitzone/tsrun': ^1.2.39
|
||||
'@gitzone/tstest': ^1.0.72
|
||||
'@pushrocks/isohash': ^2.0.0
|
||||
'@pushrocks/smartenv': ^5.0.2
|
||||
'@pushrocks/smartjson': ^5.0.2
|
||||
'@pushrocks/smartjson': ^5.0.4
|
||||
'@pushrocks/smartsocket': ^2.0.7
|
||||
'@pushrocks/smartstring': ^4.0.2
|
||||
'@pushrocks/tapbundle': ^5.0.4
|
||||
@@ -17,9 +17,9 @@ specifiers:
|
||||
|
||||
dependencies:
|
||||
'@apiglobal/typedrequest': 2.0.12
|
||||
'@apiglobal/typedrequest-interfaces': 1.0.15
|
||||
'@apiglobal/typedrequest-interfaces': 2.0.0
|
||||
'@pushrocks/isohash': 2.0.0
|
||||
'@pushrocks/smartjson': 5.0.2
|
||||
'@pushrocks/smartjson': 5.0.4
|
||||
'@pushrocks/smartsocket': 2.0.7
|
||||
'@pushrocks/smartstring': 4.0.5
|
||||
|
||||
@@ -47,6 +47,10 @@ packages:
|
||||
/@apiglobal/typedrequest-interfaces/1.0.15:
|
||||
resolution: {integrity: sha512-KncX168fUQJ73FeT22Cvls41mkJmtasP8dB2s9+9/OyWZpNsCzk9NEmtdRhulW2vLQwuAbQc1eoloe7ffCmhcA==}
|
||||
|
||||
/@apiglobal/typedrequest-interfaces/2.0.0:
|
||||
resolution: {integrity: sha512-UTzBVt9I0eIccncKdtrE0XTO6bK3P+jyfmYO7LAGlZGM5gAamjGBy4nDKh3JshK+x/z89VyD+02+sUyDfi2NwA==}
|
||||
dev: false
|
||||
|
||||
/@apiglobal/typedrequest/2.0.12:
|
||||
resolution: {integrity: sha512-oCxcdKEzihzPDf0jrqG4obFFSgDszvO5LO+0Fk/hH/0bZm0AQ1LssYVwaY8OHjT0ujmkTcC5JFCjaS7LgjKSgQ==}
|
||||
dependencies:
|
||||
@@ -468,7 +472,7 @@ packages:
|
||||
'@pushrocks/smartdelay': 2.0.13
|
||||
'@pushrocks/smartfile-interfaces': 1.0.7
|
||||
'@pushrocks/smarthash': 3.0.1
|
||||
'@pushrocks/smartjson': 5.0.2
|
||||
'@pushrocks/smartjson': 5.0.4
|
||||
'@pushrocks/smartmime': 1.0.5
|
||||
'@pushrocks/smartpath': 5.0.5
|
||||
'@pushrocks/smartpromise': 3.1.7
|
||||
@@ -495,7 +499,7 @@ packages:
|
||||
/@pushrocks/smarthash/3.0.1:
|
||||
resolution: {integrity: sha512-S9BiLsxTJB4KOXiiqcdp9QHc8srctHQxoWqDNVw7mGJbU6KuCHbFW6NUcEe2us5z389dGNEbbPMy7+0mAdTXVA==}
|
||||
dependencies:
|
||||
'@pushrocks/smartjson': 5.0.2
|
||||
'@pushrocks/smartjson': 5.0.4
|
||||
'@pushrocks/smartpromise': 3.1.7
|
||||
'@types/through2': 2.0.36
|
||||
through2: 4.0.2
|
||||
@@ -509,8 +513,8 @@ packages:
|
||||
fast-json-stable-stringify: 2.1.0
|
||||
lodash.clonedeep: 4.5.0
|
||||
|
||||
/@pushrocks/smartjson/5.0.2:
|
||||
resolution: {integrity: sha512-zYy4jaZhBA0JUnheDinARS82fpQZrwLZZWTBHK40UJ4q2n/a/CvFvNDaN81I1PODubV6dsRF4M0JjLk2VJ5XMA==}
|
||||
/@pushrocks/smartjson/5.0.4:
|
||||
resolution: {integrity: sha512-/a64L04y+prOp1LNfuxmbBbcIGdm+vCOSlhndDE2LWDrLn88gfLHERtQqpOdDUbrlXnTWZ1bvMTKbiPJGx9N/w==}
|
||||
dependencies:
|
||||
'@pushrocks/smartstring': 4.0.5
|
||||
'@types/buffer-json': 2.0.1
|
||||
@@ -671,7 +675,7 @@ packages:
|
||||
'@pushrocks/smartdelay': 2.0.13
|
||||
'@pushrocks/smartenv': 5.0.3
|
||||
'@pushrocks/smartexpress': 4.0.21
|
||||
'@pushrocks/smartjson': 5.0.2
|
||||
'@pushrocks/smartjson': 5.0.4
|
||||
'@pushrocks/smartlog': 3.0.1
|
||||
'@pushrocks/smartpromise': 3.1.7
|
||||
'@pushrocks/smartrx': 2.0.27
|
||||
@@ -783,7 +787,7 @@ packages:
|
||||
'@adobe/helix-fetch': 3.1.2
|
||||
'@pushrocks/smartdelay': 2.0.13
|
||||
'@pushrocks/smartenv': 5.0.3
|
||||
'@pushrocks/smartjson': 5.0.2
|
||||
'@pushrocks/smartjson': 5.0.4
|
||||
'@pushrocks/smartpromise': 3.1.7
|
||||
'@pushrocks/webstore': 2.0.5
|
||||
transitivePeerDependencies:
|
||||
@@ -795,7 +799,7 @@ packages:
|
||||
'@apiglobal/typedrequest-interfaces': 1.0.15
|
||||
'@pushrocks/lik': 6.0.0
|
||||
'@pushrocks/smartenv': 5.0.3
|
||||
'@pushrocks/smartjson': 5.0.2
|
||||
'@pushrocks/smartjson': 5.0.4
|
||||
'@pushrocks/smartpromise': 3.1.7
|
||||
'@pushrocks/smartrx': 2.0.27
|
||||
fake-indexeddb: 4.0.0
|
||||
|
||||
48
test/test.ts
48
test/test.ts
@@ -4,17 +4,18 @@ import * as typedrequestInterfaces from '@apiglobal/typedrequest-interfaces';
|
||||
|
||||
import * as typedsocket from '../ts/index.js';
|
||||
|
||||
interface IRequest_Client_Server extends typedrequestInterfaces.implementsTR<
|
||||
typedrequestInterfaces.ITypedRequest,
|
||||
IRequest_Client_Server
|
||||
> {
|
||||
interface IRequest_Client_Server
|
||||
extends typedrequestInterfaces.implementsTR<
|
||||
typedrequestInterfaces.ITypedRequest,
|
||||
IRequest_Client_Server
|
||||
> {
|
||||
method: 'sayhi';
|
||||
request: {
|
||||
greeting: string;
|
||||
};
|
||||
response: {
|
||||
answer: string
|
||||
}
|
||||
answer: string;
|
||||
};
|
||||
}
|
||||
|
||||
let testTypedSocketServer: typedsocket.TypedSocket;
|
||||
@@ -23,45 +24,52 @@ let testTypedSocketClient: typedsocket.TypedSocket;
|
||||
const testTypedRouter = new typedrequest.TypedRouter();
|
||||
|
||||
tap.test('should add some handlers', async () => {
|
||||
testTypedRouter.addTypedHandler<IRequest_Client_Server>(new typedrequest.TypedHandler('sayhi', async requestData => {
|
||||
return {
|
||||
answer: `ok, got it : ${requestData.greeting}`
|
||||
}
|
||||
}));
|
||||
})
|
||||
testTypedRouter.addTypedHandler<IRequest_Client_Server>(
|
||||
new typedrequest.TypedHandler('sayhi', async (requestData) => {
|
||||
return {
|
||||
answer: `ok, got it : ${requestData.greeting}`,
|
||||
};
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
tap.test('should create Server and Client', async (tools) => {
|
||||
testTypedSocketServer = await typedsocket.TypedSocket.createServer(testTypedRouter);
|
||||
testTypedSocketClient = await typedsocket.TypedSocket.createClient(testTypedRouter, 'http://localhost:3000');
|
||||
testTypedSocketClient = await typedsocket.TypedSocket.createClient(
|
||||
testTypedRouter,
|
||||
'http://localhost:3000'
|
||||
);
|
||||
console.log('test: waiting 5 seconds');
|
||||
await tools.delayFor(5000);
|
||||
await testTypedSocketServer.stop();
|
||||
|
||||
// lets create another server
|
||||
testTypedSocketServer = await typedsocket.TypedSocket.createServer(testTypedRouter);
|
||||
|
||||
|
||||
// lets see if auto reconnect works
|
||||
console.log('test: waiting 21 seconds for reconnect');
|
||||
await tools.delayFor(21000);
|
||||
});
|
||||
|
||||
tap.test('should process messages from both sides', async () => {
|
||||
const myServerSideTypedRequest = testTypedSocketServer.createTypedRequest<IRequest_Client_Server>('sayhi');
|
||||
const myClientSideTypedRequest = testTypedSocketClient.createTypedRequest<IRequest_Client_Server>('sayhi');
|
||||
const myServerSideTypedRequest =
|
||||
testTypedSocketServer.createTypedRequest<IRequest_Client_Server>('sayhi');
|
||||
const myClientSideTypedRequest =
|
||||
testTypedSocketClient.createTypedRequest<IRequest_Client_Server>('sayhi');
|
||||
const response = await myClientSideTypedRequest.fire({
|
||||
greeting: 'that is a greeting from the client'
|
||||
greeting: 'that is a greeting from the client',
|
||||
});
|
||||
console.log(response);
|
||||
const response2 = await myServerSideTypedRequest.fire({
|
||||
greeting: 'that is a greeting from the server'
|
||||
greeting: 'that is a greeting from the server',
|
||||
});
|
||||
console.log(response2);
|
||||
})
|
||||
});
|
||||
|
||||
tap.test('should disconnect', async (tools) => {
|
||||
await testTypedSocketClient.stop();
|
||||
await testTypedSocketServer.stop();
|
||||
tools.delayFor(1000).then(() => process.exit(0));
|
||||
})
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@apiglobal/typedsocket',
|
||||
version: '2.0.7',
|
||||
version: '2.0.10',
|
||||
description: 'a typedrequest extension supporting websockets'
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ export class TypedSocket {
|
||||
});
|
||||
}
|
||||
|
||||
public async findTargetConnectionByTag(keyArg: string, payloadArg?: any) {
|
||||
public async findTargetConnectionByTag<T extends plugins.typedrequestInterfaces.ITag>(keyArg: string, payloadArg?: any) {
|
||||
const allResults = await this.findAllTargetConnectionsByTag(keyArg, payloadArg);
|
||||
return allResults[0];
|
||||
}
|
||||
|
||||
@@ -2,10 +2,7 @@
|
||||
import * as typedrequest from '@apiglobal/typedrequest';
|
||||
import * as typedrequestInterfaces from '@apiglobal/typedrequest-interfaces';
|
||||
|
||||
export {
|
||||
typedrequest,
|
||||
typedrequestInterfaces,
|
||||
}
|
||||
export { typedrequest, typedrequestInterfaces };
|
||||
|
||||
// @pushrocks scope
|
||||
import * as isohash from '@pushrocks/isohash';
|
||||
@@ -13,9 +10,4 @@ import * as smartjson from '@pushrocks/smartjson';
|
||||
import * as smartsocket from '@pushrocks/smartsocket';
|
||||
import * as smartstring from '@pushrocks/smartstring';
|
||||
|
||||
export {
|
||||
isohash,
|
||||
smartjson,
|
||||
smartsocket,
|
||||
smartstring
|
||||
}
|
||||
export { isohash, smartjson, smartsocket, smartstring };
|
||||
|
||||
Reference in New Issue
Block a user