app.js 537 B

123456789101112131415161718
  1. #!/usr/bin/env node
  2. const fs = require('fs')
  3. const path = require('path')
  4. const tmpPath = require('os').tmpdir()
  5. async function start() {
  6. // 检测是否存在 anonymous_token 文件,没有则生成
  7. if (!fs.existsSync(path.resolve(tmpPath, 'anonymous_token'))) {
  8. fs.writeFileSync(path.resolve(tmpPath, 'anonymous_token'), '', 'utf-8')
  9. }
  10. // 启动时更新anonymous_token
  11. const generateConfig = require('./generateConfig')
  12. await generateConfig()
  13. require('./server').serveNcmApi({
  14. checkVersion: true,
  15. })
  16. }
  17. start()