refactor: migrate to Tencent Cloud backend
这个提交包含在:
@@ -0,0 +1,27 @@
|
||||
require('dotenv').config({ path: require('path').join(__dirname, '..', '.env') })
|
||||
|
||||
const http = require('http')
|
||||
const config = require('../src/config')
|
||||
const { handle } = 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)
|
||||
})
|
||||
在新工单中引用
屏蔽一个用户