MCPcopy Create free account
hub / github.com/Y80/bmm / main

Function main

scripts/list-users.mjs:11–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9}
10
11async function main() {
12 await loadEnv()
13 checkEnvs()
14 await declareLocalType()
15
16 if (!(await testDbConnect())) {
17 echo(chalk.red('❌ 数据库连接失败,请检查'))
18 process.exit(1)
19 }
20
21 const { default: UserController } = await import('@/controllers/User.controller')
22 const users = await UserController.findAll()
23
24 if (users.length === 0) {
25 echo(chalk.yellow('当前数据库中暂无用户'))
26 await exitWithDbClose()
27 }
28
29 console.table(
30 users.map((user,) => ({
31 Email: user.email,
32 Role: user.role || 'user',
33 CreatedAt: formatDate(user.createdAt),
34 }))
35 )
36
37 await exitWithDbClose()
38}
39
40main().catch(async (error) => {
41 echo(chalk.red('❌ 获取用户列表失败'))

Callers 1

list-users.mjsFile · 0.70

Calls 6

loadEnvFunction · 0.90
checkEnvsFunction · 0.90
declareLocalTypeFunction · 0.90
testDbConnectFunction · 0.90
exitWithDbCloseFunction · 0.90
formatDateFunction · 0.70

Tested by

no test coverage detected