refactor: restructure entire project for human maintainability
Server: - Add Express framework, replace custom router/request parser - Create DAO layer (12 files) centralizing all 73 SQL queries - Rewrite 7 route files as thin Express controllers calling DAOs - Add SCF-to-Express adapter (lib/serverless.js) - Add auth middleware (middleware/auth.js) - Remove dead code from lib/auth.js Admin console: - Extract DataTable component (table + pagination) - Extract ConfirmModal component (modal + form styles) - Create listMixin for paginated list pages - Move form styles to common.css for slot compatibility - Refactor device + subscription pages as examples Miniprogram: - Split 734-line BLE monolith into 4 focused modules (protocol, connection, commands, barrel index) - Create API module (utils/api.js) with named functions - Create page utilities (utils/page.js) - Refactor index + profile pages to use API module
这个提交包含在:
@@ -1,27 +1,8 @@
|
||||
require('dotenv').config({ path: require('path').join(__dirname, '..', '.env') })
|
||||
|
||||
const http = require('http')
|
||||
const config = require('../src/config')
|
||||
const { handle } = require('../src/app')
|
||||
const app = require('../src/app')
|
||||
|
||||
const server = http.createServer(async (req, res) => {
|
||||
const chunks = []
|
||||
req.on('data', chunk => chunks.push(chunk))
|
||||
req.on('end', async () => {
|
||||
const url = new URL(req.url, 'http://localhost')
|
||||
const event = {
|
||||
httpMethod: req.method,
|
||||
path: url.pathname,
|
||||
headers: req.headers,
|
||||
queryStringParameters: Object.fromEntries(url.searchParams.entries()),
|
||||
body: Buffer.concat(chunks).toString('utf8')
|
||||
}
|
||||
const result = await handle(event)
|
||||
res.writeHead(result.statusCode, result.headers)
|
||||
res.end(result.body || '')
|
||||
})
|
||||
})
|
||||
|
||||
server.listen(config.port, () => {
|
||||
console.log('SCF local server listening on http://localhost:' + config.port)
|
||||
app.listen(config.port, () => {
|
||||
console.log('Server listening on http://localhost:' + config.port)
|
||||
})
|
||||
|
||||
在新工单中引用
屏蔽一个用户