修改配置项
This commit is contained in:
@@ -73,7 +73,6 @@ export function handleChatMessage(data) {
|
||||
addMessage(data);
|
||||
|
||||
const isImage = data.content && data.content.startsWith('data:image/');
|
||||
const messageType = isImage ? 'file' : 'text';
|
||||
|
||||
// 显示通知
|
||||
if (!data.isSelf) {
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
"build": "tsc -p tsconfig.build.json",
|
||||
"test": "jest --colors test/*.ts",
|
||||
"newman": "newman run test/renderstreaming.postman_collection.json",
|
||||
"start": "node ./build/index.js",
|
||||
"dev": "ts-node ./src/index.ts",
|
||||
"start": "node ./build/index.js -s -p 8080 -m private -k ./server.key -c ./server.cert",
|
||||
"dev": "ts-node ./src/index.ts -s -p 8080",
|
||||
"lint": "eslint src/**/*.ts test/**/*.ts",
|
||||
"pack": "pkg ."
|
||||
},
|
||||
|
||||
@@ -13,28 +13,30 @@ export class RenderStreaming {
|
||||
public static run(argv: string[]): RenderStreaming {
|
||||
const program = new Command();
|
||||
const readOptions = (): Options => {
|
||||
if (Array.isArray(argv)) {
|
||||
program
|
||||
.usage('[options] <apps...>')
|
||||
.option('-p, --port <n>', 'Port to start the server on.', process.env.PORT || `80`)
|
||||
.option('-s, --secure', 'Enable HTTPS (you need server.key and server.cert).', process.env.SECURE || false)
|
||||
.option('-k, --keyfile <path>', 'https key file.', process.env.KEYFILE || 'server.key')
|
||||
.option('-c, --certfile <path>', 'https cert file.', process.env.CERTFILE || 'server.cert')
|
||||
.option('-t, --type <type>', 'Type of signaling protocol, Choose websocket or http.', process.env.TYPE || 'websocket')
|
||||
.option('-m, --mode <type>', 'Choose Communication mode public or private.', process.env.MODE || 'public')
|
||||
.option('-l, --logging <type>', 'Choose http logging type combined, dev, short, tiny or none.', process.env.LOGGING || 'dev')
|
||||
.parse(argv);
|
||||
const option = program.opts();
|
||||
return {
|
||||
port: option.port,
|
||||
secure: option.secure == undefined ? false : option.secure,
|
||||
keyfile: option.keyfile,
|
||||
certfile: option.certfile,
|
||||
type: option.type == undefined ? 'websocket' : option.type,
|
||||
mode: option.mode,
|
||||
logging: option.logging,
|
||||
};
|
||||
}
|
||||
// 确保argv是数组
|
||||
const args = Array.isArray(argv) ? argv : process.argv;
|
||||
|
||||
program
|
||||
.usage('[options] <apps...>')
|
||||
.option('-p, --port <n>', 'Port to start the server on.', process.env.PORT || `80`)
|
||||
.option('-s, --secure', 'Enable HTTPS (you need server.key and server.cert).', process.env.SECURE || true)
|
||||
.option('-k, --keyfile <path>', 'https key file.', process.env.KEYFILE || 'server.key')
|
||||
.option('-c, --certfile <path>', 'https cert file.', process.env.CERTFILE || 'server.cert')
|
||||
.option('-t, --type <type>', 'Type of signaling protocol, Choose websocket or http.', process.env.TYPE || 'websocket')
|
||||
.option('-m, --mode <type>', 'Choose Communication mode public or private.', process.env.MODE || 'public')
|
||||
.option('-l, --logging <type>', 'Choose http logging type combined, dev, short, tiny or none.', process.env.LOGGING || 'dev')
|
||||
.parse(args);
|
||||
|
||||
const option = program.opts();
|
||||
return {
|
||||
port: option.port,
|
||||
secure: option.secure == undefined ? false : option.secure,
|
||||
keyfile: option.keyfile,
|
||||
certfile: option.certfile,
|
||||
type: option.type == undefined ? 'websocket' : option.type,
|
||||
mode: option.mode,
|
||||
logging: option.logging,
|
||||
};
|
||||
};
|
||||
const options = readOptions();
|
||||
return new RenderStreaming(options);
|
||||
|
||||
Reference in New Issue
Block a user