feat: refactor routing in app.ts and update createPayer function to accept address as an array

This commit is contained in:
Astrian Zheng 2025-01-11 22:01:51 +11:00
parent d183b82a7c
commit 6c6936097e
Signed by: Astrian
SSH Key Fingerprint: SHA256:rVnhx3DAKjujCwWE13aDl7uV6+9U1MvydLkNRXJrBiA
2 changed files with 7 additions and 20 deletions

View File

@ -11,17 +11,11 @@ console.log = Debug('invoiceIssuer:app.ts')
const app = new Koa() const app = new Koa()
app.use(koaBody()) app.use(koaBody())
/** app.use(route.get('/', (ctx) => {
* GET /
* @summary
* @param {Koa.Context} ctx - Koa context object
*/
const getRoot = route.get('/', (ctx) => {
ctx.body = 'Hello World' ctx.body = 'Hello World'
}) }))
app.use(route.post('/payer', async (ctx) => {
const postPayer = route.post('/payer', async (ctx) => {
// TODO: 请求头验证 bearer token // TODO: 请求头验证 bearer token
const { name, address, email, abn } = ctx.request.body const { name, address, email, abn } = ctx.request.body
@ -41,16 +35,9 @@ const postPayer = route.post('/payer', async (ctx) => {
ctx.throw(500, 'unknown_issues') ctx.throw(500, 'unknown_issues')
} }
} }
}) }))
// 导出路由
export { getRoot, postPayer }
const port = parseInt(process.env.PORT ?? '3000') const port = parseInt(process.env.PORT ?? '3000')
app.listen(port, () => { 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}`)
}) })

View File

@ -6,5 +6,5 @@
* @param {string} email - * @param {string} email -
* @param {string} abn - * @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) => {
} }