@plurid/opject-server
v0.0.0-1
Published
Server for Object Passing
Downloads
3
Readme
Contents
About
opject
is a specification and implementation for passing object
s through the network.
An object
is a self-contained piece of code.
The passing of the object through the network is obtained in 2 steps:
- a registered object is requested by the
opject client
from theopject server
; - the
opject client
instantiates or runs in a virtual machine the received object.
opject
has clients for
The opject server
can serve any kind of object. However, depending on the preferred language, a specific opject server
can be used for
The opject registry
grants extended functionality through a web interface. The registry can be self-hosted or cloud-hosted.
Install
Install using
npm install @plurid/opject-server
or
yarn add @plurid/opject-server
Install the peer dependencies
@plurid/deon @plurid/plurid-functions express body-parser crypto
Usage
A simple opject server
will only require passing a verifyToken
function and start
ing the server.
import OpjectServer from '@plurid/opject-server';
const opjectServer = new OpjectServer({
verifyToken: async (
token,
) => {
if (token === '__TESTS__') {
return true;
}
return false;
},
});
const PORT = 7766;
opjectServer.start(PORT);
The opject
server will use the local filesystem for storing data.
Custom functions can be passed to the opject
server to implement any kind of logic handling following the interfaces
export type VerifyToken = (
token: string,
) => Promise<boolean>;
export type GetObject = (
id: string,
) => Promise<string | undefined>;
export type GetMetadata = (
id: string,
) => Promise<OpjectMetadata | undefined>;
export type RegisterObject = (
id: string,
data: string,
) => Promise<boolean>;
export type RegisterMetadata = (
id: string,
data: OpjectMetadata,
) => Promise<boolean>;
export type RemoveObject = (
id: string,
) => Promise<boolean>;
export interface OpjectServerConfiguration {
verifyToken: VerifyToken;
getObject?: GetObject;
getMetadata?: GetMetadata;
registerObject?: RegisterObject;
registerMetadata?: RegisterMetadata;
removeObject?: RemoveObject;
options?: OpjectServerPartialOptions;
}
Packages
@plurid/opject-client-javascript • JavaScript
opject client
@plurid/opject-server-javascript • JavaScript
opject server
@plurid/opject-client-python • Python
opject client
@plurid/opject-server-python • Python
opject server