add tsconfig and rawlogbot

This commit is contained in:
emerson 2021-12-05 17:44:13 -05:00
parent 918402659f
commit a84ac146a0
No known key found for this signature in database
GPG key ID: 270669502DA603E3
2 changed files with 45 additions and 0 deletions

18
.tsconfig.json Normal file
View file

@ -0,0 +1,18 @@
{
"compilerOptions": {
"lib": ["es2020"],
"module": "es2020",
"target": "es2020",
"outDir": "./lib",
"moduleResolution": "node",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": [
"src/*.ts",
"src/**/*.ts"
]
}

27
test/rawlogbot.js Normal file
View file

@ -0,0 +1,27 @@
import { readFileSync } from "fs";
import { connect } from "tls";
const config = JSON.parse(readFileSync('config.json'));
const client = connect({
host: 'localhost',
port: config["port"],
rejectUnauthorized: false
}, () => {
process.stdin.pipe(client);
process.stdin.resume();
})
client.setEncoding('utf8');
client.on('data', (data) => {
const dataArray = data.toString().split('\r\n');
dataArray.forEach(m => {
const trimmedMsg = m.replace('\r', '').replace('\n', '');
if (trimmedMsg !== '') {
console.log(`--> ${trimmedMsg}`);
}
});
});
client.on('end', () => {
console.log('server ends connection');
});