Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/l-chris/yar-node
Yar implemention for Nodejs.
https://github.com/l-chris/yar-node
node yar
Last synced: about 2 months ago
JSON representation
Yar implemention for Nodejs.
- Host: GitHub
- URL: https://github.com/l-chris/yar-node
- Owner: L-Chris
- License: mit
- Created: 2019-10-03T09:09:09.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-04T14:27:43.000Z (about 2 years ago)
- Last Synced: 2024-08-09T03:08:30.038Z (5 months ago)
- Topics: node, yar
- Language: TypeScript
- Homepage: https://github.com/laruence/yar
- Size: 149 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## yar-node
### ✨ Features:
- client[√]
- server[√]
- packager: json[√]、php[√]、msgpack[×]
- protocol: http[√]、tcp[×]、unix[×]### Server
```javascript
const { YarServer } = require('yar-node');class API {
someMethod(args) {}
}const server = new YarServer(new API());
server.handle();
```### Client
```javascript
const { YarClient } = require('yar-node');const client = new YarClient('http://host/api/');
client.call('someMethod', { name: 'Chris' }).then(res => {
console.log(`reponse:${res}`);
});
```### Yar Header
```C
typedef struct _yar_header {
unsigned int id; // transaction id
unsigned short version; // protocl version
unsigned int magic_num; // default is: 0x80DFEC60
unsigned int reserved;
unsigned char provider[32]; // reqeust from who
unsigned char token[32]; // request token, used for authentication
unsigned int body_len; // request body len
}
```### Request
```javascript
{
i: '', // transaction id
m: '', // the method which being called
p: {} // parameters
}
```### Response
```javascript
{
i: '', // transaction id
s: '', // status
r: '', // return value
o: '', // output
e: '' // error or exception
}
```