Git Product home page Git Product logo

yar-node's Introduction

yar-node

✨ Features:

  • client[√]
  • server[√]
  • packager: json[√]、php[√]、msgpack[×]
  • protocol: http[√]、tcp[×]、unix[×]

Server

const { YarServer } = require('yar-node');

class API {
  someMethod(args) {}
}

const server = new YarServer(new API());

server.handle();

Client

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

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

{
  i: '', // transaction id
  m: '', // the method which being called
  p: {} // parameters
}

Response

{
  i: '', // transaction id
  s: '', // status
  r: '', // return value
  o: '', // output
  e: ''  // error or exception
}

yar-node's People

Contributors

l-chris avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.