A URL shortener app that offers a landing page, creation of short links, listing of all store URLs, and copy and delete actions for all short URLs.
- Returns an HTML landing page as a static file.
- Returns an CSS file for the HTML landing page as a static file.
- Redirects to the full URL affiliated with the short code.
- Gets list of all stored URLs and short codes.
Response
Sample 200
Response:
{
"ok": true,
"data": [
{
"url": "https://appwrite.io",
"$id": "appwrite"
},
{
"url": "https://twitter.com/adityaoberai1",
"$id": "twitter"
},
{
"url": "https://appwrite.io/education",
"$id": "edu"
}
]
}
- Add URL and short code (as the document ID) to the database.
Request
{
"short": "appwrite",
"url": "https://appwrite.io"
}
Response
Sample 200
Response:
{
"ok": true,
"data": {
"short": "appwrite",
"url": "https://appwrite.io"
}
}
- Deletes the short code and affiliated full URL from the database.
Response
Sample 200
Response:
{
"ok": true
}
Setting | Value |
---|---|
Runtime | Node (22.0) |
Entrypoint | src/main.js |
Function path | functions/url-shortener |
Build Commands | npm install |
Permissions | any |
Timeout (Seconds) | 15 |
Specifiation | s-1vcpu-512mb |
Scopes | databases.write , databases.read , collections.write , collections.read , attributes.write , documents.write , documents.read |
No environment variables required mandatorily. There are two optional environment variables, however:
APPWRITE_DB_ID
: ID of Appwrite Database which will contain collection of short codes and URLsAPPWRITE_COLLECTION_ID
: ID of Appwrite Collection which will contain short codes and URLs