feat: refactor routing in app.ts and update createPayer function to accept address as an array
This commit is contained in:
parent
d183b82a7c
commit
6c6936097e
|
@ -11,17 +11,11 @@ console.log = Debug('invoiceIssuer:app.ts')
|
|||
const app = new Koa()
|
||||
app.use(koaBody())
|
||||
|
||||
/**
|
||||
* GET /
|
||||
* @summary 返回欢迎信息。通常用于检查服务器是否正常运行。
|
||||
* @param {Koa.Context} ctx - Koa context object
|
||||
*/
|
||||
const getRoot = route.get('/', (ctx) => {
|
||||
ctx.body = 'Hello World'
|
||||
})
|
||||
app.use(route.get('/', (ctx) => {
|
||||
ctx.body = 'Hello World'
|
||||
}))
|
||||
|
||||
|
||||
const postPayer = route.post('/payer', async (ctx) => {
|
||||
app.use(route.post('/payer', async (ctx) => {
|
||||
// TODO: 请求头验证 bearer token
|
||||
|
||||
const { name, address, email, abn } = ctx.request.body
|
||||
|
@ -41,16 +35,9 @@ const postPayer = route.post('/payer', async (ctx) => {
|
|||
ctx.throw(500, 'unknown_issues')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// 导出路由
|
||||
export { getRoot, postPayer }
|
||||
}))
|
||||
|
||||
const port = parseInt(process.env.PORT ?? '3000')
|
||||
app.listen(port, () => {
|
||||
/**
|
||||
* Server listening callback
|
||||
* @summary Logs the server start message
|
||||
*/
|
||||
console.log(`Server is running at http://localhost:${port}`)
|
||||
console.log(`Server is running at http://localhost:${port}`)
|
||||
})
|
|
@ -6,5 +6,5 @@
|
|||
* @param {string} email - 付款人的电子邮件地址
|
||||
* @param {string} abn - 付款人的澳大利亚商业号码
|
||||
*/
|
||||
export default async (name: string, address: string, email: string, abn?: string) => {
|
||||
export default async (name: string, address: string[], email: string, abn?: string) => {
|
||||
}
|
Loading…
Reference in New Issue
Block a user