-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
examples/node: updated all node examples
- Loading branch information
Showing
23 changed files
with
8,455 additions
and
434 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
const {Node} = require("flatend"); | ||
const { Node } = require("flatend"); | ||
|
||
let counter = 0 | ||
let counter = 0; | ||
|
||
const count = ctx => ctx.send(`${counter++}`); | ||
const count = (ctx) => ctx.send(`${counter++}`); | ||
|
||
const main = async () => { | ||
const node = new Node(); | ||
node.register('count', count); | ||
await node.dial("127.0.0.1:9000"); | ||
} | ||
await Node.start({ | ||
addrs: ["127.0.0.1:9000"], | ||
services: { count: count }, | ||
}); | ||
}; | ||
|
||
main().catch(err => console.error(err)); | ||
main().catch((err) => console.error(err)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
const {Node} = require("flatend"); | ||
const { Node } = require("flatend"); | ||
const fs = require("fs"); | ||
|
||
const main = async () => { | ||
const node = new Node(); | ||
node.register('file', ctx => fs.createReadStream("index.js").pipe(ctx)); | ||
await node.dial("127.0.0.1:9000"); | ||
} | ||
await Node.start({ | ||
addrs: ["127.0.0.1:9000"], | ||
services: { | ||
file: (ctx) => fs.createReadStream("index.js").pipe(ctx), | ||
}, | ||
}); | ||
}; | ||
|
||
main().catch(err => console.error(err)); | ||
main().catch((err) => console.error(err)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
const {Node} = require("flatend"); | ||
const { Node } = require("flatend"); | ||
|
||
const main = async () => { | ||
await Node.start({ | ||
addrs: ["127.0.0.1:9000"], | ||
services: { | ||
"hello_world": ctx => ctx.send("Hello world!"), | ||
} | ||
}); | ||
} | ||
await Node.start({ | ||
addrs: ["127.0.0.1:9000"], | ||
services: { | ||
hello_world: (ctx) => ctx.send("Hello world!"), | ||
}, | ||
}); | ||
}; | ||
|
||
main().catch(err => console.error(err)); | ||
main().catch((err) => console.error(err)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.