@@ -307,6 +307,9 @@ import "io"
307307import " io/ioutil"
308308
309309func helloWorld (ctx *flatend .Context ) {
310+ // The ID of the requester may be accessed via `ctx.ID`.
311+ _ = ctx.ID
312+
310313 // All headers must be written before writing any response body data.
311314
312315 // Headers are used to send small amounts of metadata to a requester.
@@ -347,27 +350,29 @@ func helloWorld(ctx *flatend.Context) {
347350``` js
348351const {Node } = require (" flatend" );
349352
350- interface NodeOpts {
351- // A reachable, public address which peers may reach you on.
352- // The format of the address must be [host]:[port].
353- addr?: string;
354-
355- // A list of addresses to nodes to initially reach out
356- // for/bootstrap from first.
357- addrs?: string;
358-
359- // An Ed25519 keypair. A keypair must be provided to allow for
360- // peers to reach you. A secret key may be generated by calling
361- // 'nacl.sign.keyPair()' using the 'tweetnacl' library.
362- keys?: nacl .SignKeyPair ;
363-
364- // A mapping of service names to their respective handlers.
365- services?: { [key: string]: Handler };
366-
367- // bindAddrs?: string[], (not supported yet)
353+ export interface NodeOptions {
354+ // A reachable, public address which peers may reach you on.
355+ // The format of the address must be [host]:[port].
356+ publicAddr ?: string ;
357+
358+ // A list of [host]:[port] addresses which this node will bind a listener
359+ // against to accept new Flatend nodes.
360+ bindAddrs ?: string [];
361+
362+ // A list of addresses to nodes to initially reach out
363+ // for/bootstrap from first.
364+ addrs ?: string [];
365+
366+ // An Ed25519 secret key. A secret key must be provided to allow for
367+ // peers to reach you. A secret key may be generated by calling
368+ // 'flatend.generateSecretKey()'.
369+ secretKey ?: Uint8Array ;
370+
371+ // A mapping of service names to their respective handlers.
372+ services ?: { [key : string ]: Handler };
368373}
369374
370- await Node .start (opts? : NodeOpts);
375+ await Node .start (opts: NodeOpts);
371376
372377const {Context } = require (" flatend" );
373378
@@ -378,6 +383,8 @@ const helloWorld = async ctx => {
378383 // 'ctx' is a NodeJS Duplex stream. Writing to it writes a response
379384 // body, and reading from it reads a request body.
380385
386+ _ = ctx .id ; // The ID of the requester.
387+
381388 ctx .pipe (ctx); // This would pipe all request data as response data.
382389
383390 // Headers are used to send small amounts of metadata to a requester.
0 commit comments