0.1.9 • Published 9 years ago

nector v0.1.9

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

Nector

A promise driven functional transport layer for isomorphic apps.

* please note API's are in flux here and will change as the project develops. You may find certain versions are broken until this disclaimer is removed I would probably wait until using this.

What is Nector

Nector is a simple server middleware and client that allows you to easily run promise driven functions on the server from the client.

Requirements

To use nector you need an express or connect driven node app with some clientside code that will proxy to your serverside services.

Getting started

Add nector to your project

$ npm install nector --save

On your server use nector to attach middleware to your connect driven server and define methods.

// server.js
import express from 'express';

const app = express();

const nector = createNector('/nector'); // pass in endpoint

nector.createServer({

  sayHello(place){
    return new Promise(
      (resolve, reject) => {
        resolve(`Hello ${place}.`);
      }
    );
  }
  
  doSomethingElse(){
    return new Promise(/* set up promise... */);
  }

}, app);

app.listen(3000);

Within your client code create a remote client and call a method.

const nector = createNector('/nector'); // pass in endpoint

const remoteClient = nector.createClient('http://localhost'); // pass in full location of your server
const sayHello = remoteClient('sayHello'); // Pass in the name of the remote method you wish to call

sayHello('World')
  .then((answer) => {
    console.log(answer); // 'Hello World'
  });
0.1.9

9 years ago

0.1.8

9 years ago

0.1.7

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago