diff --git a/package.json b/package.json index 8829b8b5e6..5fe8faf01c 100644 --- a/package.json +++ b/package.json @@ -13,14 +13,13 @@ "build:1-proto": "buf generate", "build:main": "tsc -p tsconfig.json", "build:module": "tsc -p tsconfig.module.json", - "build:chat": "tsc -p tsconfig.chat.json", "fix": "run-s fix:*", "fix:prettier": "prettier \"src/**/*.ts\" --write", "fix:lint": "eslint src --ext .ts --fix", "pretest": "run-s pretest:*", "pretest:1-init-git-submodules": "[ -f './nim-waku/build/wakunode2' ] || git submodule update --init --recursive", "pretest:2-build-nim-waku": "cd nim-waku; [ -f './build/wakunode2' ] || make -j$(nproc --all 2>/dev/null || echo 2) wakunode2", - "start-chat": "ts-node chat/index.ts", + "chat:start": "ts-node src/chat/index.ts", "test": "run-s build test:*", "test:lint": "eslint src --ext .ts", "test:prettier": "prettier \"src/**/*.ts\" --list-different", diff --git a/chat/index.ts b/src/chat/index.ts similarity index 77% rename from chat/index.ts rename to src/chat/index.ts index 3b21e418bf..6e26a75f56 100644 --- a/chat/index.ts +++ b/src/chat/index.ts @@ -1,17 +1,17 @@ -import Waku from '../build/main/lib/waku'; -import { TOPIC } from '../build/main/lib/waku_relay'; -import { Message } from '../build/main/lib/waku_message'; - import readline from 'readline'; -import { delay } from '../build/main/test_utils/delay'; -;(async function() { +import Waku from '../lib/waku'; +import { Message } from '../lib/waku_message'; +import { TOPIC } from '../lib/waku_relay'; +import { delay } from '../test_utils/delay'; + +(async function () { const opts = processArguments(); const waku = await Waku.create({ listenAddresses: [opts.listenAddr] }); - // TODO: Bubble event to waku, infere topic, decode msg - waku.libp2p.pubsub.on(TOPIC, event => { + // TODO: Bubble event to waku, infer topic, decode msg + waku.libp2p.pubsub.on(TOPIC, (event) => { const msg = Message.fromBinary(event.data); console.log(msg.utf8Payload()); }); @@ -40,7 +40,7 @@ import { delay } from '../build/main/test_utils/delay'; const rl = readline.createInterface({ input: process.stdin, - output: process.stdout + output: process.stdout, }); console.log('Ready to chat!'); @@ -50,7 +50,6 @@ import { delay } from '../build/main/test_utils/delay'; const msg = Message.fromUtf8String('(js-chat) ' + line); await waku.relay.publish(msg); }); - })(); interface Options { @@ -59,9 +58,9 @@ interface Options { } function processArguments(): Options { - let passedArgs = process.argv.slice(2); + const passedArgs = process.argv.slice(2); - let opts: Options = {listenAddr: '/ip4/0.0.0.0/tcp/0'}; + let opts: Options = { listenAddr: '/ip4/0.0.0.0/tcp/0' }; while (passedArgs.length) { const arg = passedArgs.shift(); @@ -74,7 +73,7 @@ function processArguments(): Options { break; default: console.log(`Unsupported argument: ${arg}`); - process.exit(1) + process.exit(1); } } diff --git a/tsconfig.chat.json b/tsconfig.chat.json deleted file mode 100644 index 7a9b8796f6..0000000000 --- a/tsconfig.chat.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "compilerOptions": { - "incremental": true, - "target": "es2017", - "outDir": "build/chat", - "rootDir": "chat", - "moduleResolution": "node", - "module": "commonjs", - "declaration": true, - "inlineSourceMap": true, - "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, - "resolveJsonModule": true /* Include modules imported with .json extension. */, - - "strict": true /* Enable all strict type-checking options. */, - - /* Strict Type-Checking Options */ - // "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */, - // "strictNullChecks": true /* Enable strict null checks. */, - // "strictFunctionTypes": true /* Enable strict checking of function types. */, - // "strictPropertyInitialization": true /* Enable strict checking of property initialization in classes. */, - // "noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */, - // "alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */, - - /* Additional Checks */ - "noUnusedLocals": true /* Report errors on unused locals. */, - "noUnusedParameters": true /* Report errors on unused parameters. */, - "noImplicitReturns": true /* Report error when not all code paths in function return a value. */, - "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */, - - /* Debugging Options */ - "traceResolution": false /* Report module resolution log messages. */, - "listEmittedFiles": false /* Print names of generated files part of the compilation. */, - "listFiles": false /* Print names of files part of the compilation. */, - "pretty": true /* Stylize errors and messages using color and context. */, - - // Due to broken types in indirect dependencies - "skipLibCheck": true, - - /* Experimental Options */ - // "experimentalDecorators": true /* Enables experimental support for ES7 decorators. */, - // "emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */, - - "lib": ["es2017"], - "types": ["node", "mocha"], - "typeRoots": ["node_modules/@types"] - }, - "include": ["chat/**/*.ts"], - "exclude": ["node_modules/**"], - "compileOnSave": false, - "ts-node": { - "files": true - } -}