hello-world

This commit is contained in:
Pavel Murygin 2022-02-15 19:37:35 +03:00
parent 9d7e32eb8c
commit f36f92297a
8 changed files with 15057 additions and 8504 deletions

View File

@ -0,0 +1,8 @@
module.exports = {
semi: true,
trailingComma: 'all',
singleQuote: true,
printWidth: 120,
tabWidth: 4,
useTabs: false,
};

View File

@ -0,0 +1,5 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testPathIgnorePatterns: ['dist'],
};

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +1,29 @@
{
"name": "hello-world",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"prestart": "npm run compile-aqua",
"start": "node -r ts-node/register src/index.ts",
"compile-aqua": "aqua --import . -i ./aqua/ -o ./src/_aqua",
"watch-aqua": "chokidar \"**/*.aqua\" -c \"npm run compile-aqua\""
},
"author": "",
"license": "ISC",
"devDependencies": {
"@fluencelabs/aqua": "^0.6.0-272",
"@fluencelabs/aqua-lib": "^0.4.0",
"chokidar-cli": "^3.0.0",
"ts-node": "^10.2.1",
"typescript": "^4.4.2"
},
"dependencies": {
"@fluencelabs/fluence": "^0.19.1",
"@fluencelabs/fluence-network-environment": "^1.0.13"
}
"name": "hello-world",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"prestart": "npm run compile-aqua",
"start": "node -r ts-node/register src/index.ts",
"test": "jest",
"compile-aqua": "aqua --import . -i ./aqua/ -o ./src/_aqua",
"watch-aqua": "chokidar \"**/*.aqua\" -c \"npm run compile-aqua\""
},
"author": "",
"license": "ISC",
"devDependencies": {
"@fluencelabs/aqua": "^0.6.0-272",
"@fluencelabs/aqua-lib": "^0.4.0",
"chokidar-cli": "^3.0.0",
"ts-node": "^10.2.1",
"typescript": "^4.4.2",
"@types/jest": "^27.0.3",
"jest": "^27.4.0",
"ts-jest": "^27.0.7"
},
"dependencies": {
"@fluencelabs/fluence": "^0.19.1",
"@fluencelabs/fluence-network-environment": "^1.0.13"
}
}

View File

@ -0,0 +1,14 @@
import { main } from '../main';
describe('smoke test', () => {
it('should work', async () => {
console.log = jest.fn();
await main();
expect(console.log).toBeCalledTimes(3);
expect(console.log).toHaveBeenNthCalledWith(1, 'Hello, world!');
expect(console.log).toHaveBeenNthCalledWith(2, 'Wealth awaits you very soon.');
expect(console.log).toHaveBeenNthCalledWith(3, 'The relay time is: ', expect.anything());
});
});

View File

@ -1,36 +1,3 @@
import { Fluence } from "@fluencelabs/fluence";
import { krasnodar } from "@fluencelabs/fluence-network-environment";
import {
registerHelloWorld,
sayHello,
getRelayTime,
tellFortune,
} from "./_aqua/hello-world";
async function main() {
await Fluence.start({ connectTo: krasnodar[0] });
registerHelloWorld({
hello: (str) => {
console.log(str);
},
getFortune: async () => {
await new Promise((resolve) => {
setTimeout(resolve, 1000);
});
return "Wealth awaits you very soon.";
},
});
await sayHello();
console.log(await tellFortune());
const relayTime = await getRelayTime();
console.log("The relay time is: ", new Date(relayTime).toLocaleString());
await Fluence.stop();
}
import { main } from './main';
main();

View File

@ -0,0 +1,29 @@
import { Fluence } from '@fluencelabs/fluence';
import { krasnodar } from '@fluencelabs/fluence-network-environment';
import { registerHelloWorld, sayHello, getRelayTime, tellFortune } from './_aqua/hello-world';
export async function main() {
await Fluence.start({ connectTo: krasnodar[0] });
registerHelloWorld({
hello: (str) => {
console.log(str);
},
getFortune: async () => {
await new Promise((resolve) => {
setTimeout(resolve, 1000);
});
return 'Wealth awaits you very soon.';
},
});
await sayHello();
console.log(await tellFortune());
const relayTime = await getRelayTime();
console.log('The relay time is: ', new Date(relayTime).toLocaleString());
await Fluence.stop();
}

View File

@ -1,7 +1,25 @@
{
"compilerOptions": {
"target": "ES2015",
"module": "CommonJS",
"skipLibCheck": true
}
"lib": [
"es2015",
"dom"
],
"outDir": "./dist/",
"target": "es5",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"declaration": true,
"declarationMap": false,
"sourceMap": true,
},
"exclude": [
"node_modules",
"dist"
],
"include": [
"src"
],
}