feat: 实现微信小程序后端接口与用户认证系统
新增微信登录/注册合一接口、资料完善接口和token刷新接口 重构用户服务层,支持自动维护用户类型和资料完整度 引入JWT认证中间件和请求验证中间件 更新文档与测试用例,支持dist构建部署
This commit is contained in:
52
back-end/scripts/build.js
Normal file
52
back-end/scripts/build.js
Normal file
@@ -0,0 +1,52 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const rootDir = path.resolve(__dirname, '..')
|
||||
const distDir = path.join(rootDir, 'dist')
|
||||
const sourceDirs = ['src', 'spec']
|
||||
const sourceFiles = ['package.json', 'package-lock.json', '.env', 'eslint.config.js']
|
||||
|
||||
function ensureCleanDir(dirPath) {
|
||||
fs.rmSync(dirPath, { recursive: true, force: true })
|
||||
fs.mkdirSync(dirPath, { recursive: true })
|
||||
}
|
||||
|
||||
function copyRecursive(sourcePath, targetPath) {
|
||||
const stats = fs.statSync(sourcePath)
|
||||
|
||||
if (stats.isDirectory()) {
|
||||
fs.mkdirSync(targetPath, { recursive: true })
|
||||
for (const entry of fs.readdirSync(sourcePath)) {
|
||||
copyRecursive(
|
||||
path.join(sourcePath, entry),
|
||||
path.join(targetPath, entry)
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fs.mkdirSync(path.dirname(targetPath), { recursive: true })
|
||||
fs.copyFileSync(sourcePath, targetPath)
|
||||
}
|
||||
|
||||
function build() {
|
||||
ensureCleanDir(distDir)
|
||||
|
||||
for (const dir of sourceDirs) {
|
||||
const sourcePath = path.join(rootDir, dir)
|
||||
if (fs.existsSync(sourcePath)) {
|
||||
copyRecursive(sourcePath, path.join(distDir, dir))
|
||||
}
|
||||
}
|
||||
|
||||
for (const file of sourceFiles) {
|
||||
const sourcePath = path.join(rootDir, file)
|
||||
if (fs.existsSync(sourcePath)) {
|
||||
copyRecursive(sourcePath, path.join(distDir, file))
|
||||
}
|
||||
}
|
||||
|
||||
console.log('Build completed. Deployable files generated in dist/.')
|
||||
}
|
||||
|
||||
build()
|
||||
Reference in New Issue
Block a user