feat: add short link to create endpoint response

Enhances the link creation API response by including a formatted short link URL
Combines protocol, host, and slug to create a complete, ready-to-use short URL
This commit is contained in:
ccbikai 2024-12-08 11:56:03 +08:00
parent 19e18546de
commit 172956b532

View file

@ -23,6 +23,7 @@ export default eventHandler(async (event) => {
},
})
setResponseStatus(event, 201)
return { link }
const shortLink = `${getRequestProtocol(event)}://${getRequestHost(event)}/${link.slug}`
return { ...link, shortLink }
}
})