MCPcopy Create free account
hub / github.com/msgbyte/tailchat / handler

Function handler

apps/cli/src/commands/docker/init.ts:47–154  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

45 describe: 'Initialize Tailchat with docker configuration',
46 builder: undefined,
47 async handler(args) {
48 const spinner = ora();
49 try {
50 console.log(initWelcome);
51 const { dir, secret, apiUrl, fileLimit } = await inquirer.prompt([
52 {
53 name: 'dir',
54 type: 'input',
55 default: './tailchat',
56 message: 'Configurate storage directory',
57 },
58 {
59 name: 'secret',
60 type: 'input',
61 default: randomString({ length: 16 }),
62 message:
63 '(SECRET)Please enter any string, which will be used as the secret key for Tailchat to sign the user identity. Leaking this string will cause the risk of identity forgery. By default, a 16-digit string is randomly generated',
64 },
65 {
66 name: 'apiUrl',
67 type: 'input',
68 message:
69 '(API_URL)Please configure an address that can be accessed by the external network, which will affect the storage path and access address of the file, example: https://tailchat.example.com',
70 },
71 {
72 name: 'fileLimit',
73 type: 'number',
74 default: 1048576,
75 message:
76 '(FILE_LIMIT)File upload volume limit, the default is 1048576(1m)',
77 },
78 ]);
79
80 spinner.start('Start downloading the latest configuration file');
81 // eslint-disable-next-line prefer-const
82 let [rawEnv, rawConfig] = await Promise.all([
83 got(envUrl).then((res) => res.body),
84 got(configUrl).then((res) => res.body),
85 ]);
86 spinner.info('The configuration file is downloaded');
87
88 if (secret) {
89 rawEnv = setEnvValue(rawEnv, 'SECRET', secret);
90 }
91
92 if (apiUrl) {
93 rawEnv = setEnvValue(rawEnv, 'API_URL', apiUrl);
94 }
95
96 if (fileLimit) {
97 rawEnv = setEnvValue(rawEnv, 'FILE_LIMIT', fileLimit);
98 }
99
100 if (
101 await promptConfirm(
102 'Do you need to configure the email service? The email service can be used for functions such as password retrieval and email notification.'
103 )
104 ) {

Callers

nothing calls this directly

Calls 9

setEnvValueFunction · 0.85
promptConfirmFunction · 0.85
initCompletedFunction · 0.85
startMethod · 0.80
infoMethod · 0.80
joinMethod · 0.80
errorMethod · 0.80
logMethod · 0.65
allMethod · 0.45

Tested by

no test coverage detected