mirror of
https://github.com/fluencelabs/fluence-nodejs-template
synced 2024-12-03 21:50:25 +00:00
Add Fluence-related stack
This commit is contained in:
parent
1272450064
commit
9169684b6c
2
.gitignore
vendored
2
.gitignore
vendored
@ -18,3 +18,5 @@ node_modules/
|
||||
jspm_packages/
|
||||
|
||||
.idea
|
||||
|
||||
src/_aqua/
|
3
aqua/export.aqua
Normal file
3
aqua/export.aqua
Normal file
@ -0,0 +1,3 @@
|
||||
module Export
|
||||
import getRelayTimestamp from "hello-world"
|
||||
export getRelayTimestamp
|
8
aqua/hello-world.aqua
Normal file
8
aqua/hello-world.aqua
Normal file
@ -0,0 +1,8 @@
|
||||
module HelloWorld declares getRelayTimestamp
|
||||
|
||||
import "@fluencelabs/aqua-lib/builtin.aqua"
|
||||
|
||||
func getRelayTimestamp() -> u64:
|
||||
on HOST_PEER_ID:
|
||||
ts <- Peer.timestamp_ms()
|
||||
<- ts
|
8952
package-lock.json
generated
8952
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
18
package.json
18
package.json
@ -3,7 +3,12 @@
|
||||
"version": "0.0.1",
|
||||
"description": "Template project for Fluence in nodejs",
|
||||
"main": "index.js",
|
||||
"scripts": {},
|
||||
"scripts": {
|
||||
"start": "node -r ts-node/register src/index.ts",
|
||||
"prestart": "npm run compile-aqua",
|
||||
"compile-aqua": "aqua -i ./aqua/ -o ./src/_aqua",
|
||||
"watch-aqua": "chokidar \"**/*.aqua\" -c \"npm run compile-aqua\""
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/fluencelabs/fluence-nodejs-template.git"
|
||||
@ -15,6 +20,13 @@
|
||||
},
|
||||
"homepage": "https://github.com/fluencelabs/fluence-nodejs-template#readme",
|
||||
"devDependencies": {
|
||||
"typescript": "^4.0.0"
|
||||
}
|
||||
"@fluencelabs/aqua-lib": "^0.3.3",
|
||||
"ts-node": "^10.4.0",
|
||||
"typescript": "^4.0.0",
|
||||
"@fluencelabs/aqua": "^0.6.0-263",
|
||||
"@fluencelabs/fluence": "^0.19.0",
|
||||
"@fluencelabs/fluence-network-environment": "^1.0.13",
|
||||
"chokidar": "^3.5.3"
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
|
18
src/index.ts
Normal file
18
src/index.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { Fluence } from '@fluencelabs/fluence';
|
||||
import { krasnodar } from '@fluencelabs/fluence-network-environment';
|
||||
import { getRelayTimestamp } from './_aqua/export';
|
||||
|
||||
const relay = krasnodar[3];
|
||||
|
||||
async function main() {
|
||||
await Fluence.start({
|
||||
connectTo: relay,
|
||||
});
|
||||
|
||||
const timestamp = await getRelayTimestamp();
|
||||
console.log(new Date(timestamp));
|
||||
|
||||
await Fluence.stop();
|
||||
}
|
||||
|
||||
main().catch((err) => console.error(err));
|
Loading…
Reference in New Issue
Block a user