This project is a URL shortener service built with Encore.ts. It allows users to create short, easy-to-share links for long URLs.
- Shorten long URLs to compact, shareable links
- Retrieve original URLs using shortened IDs
- Built with Encore.ts for efficient backend development
- Deployable to Encore's development cloud
- Encore installed on your system
- Node.js and npm (for local development)
- Docker (optional, for running containers)
-
Create a new Encore application using this template:
encore app create encore-ts-url-shortener --example=ts/empty
-
Navigate to the project directory:
cd encore-ts-url-shortener
-
Install dependencies:
npm install
To create a shortened URL:
curl -X POST https://staging-encore-url-shortener-rd32.encr.app/url -d "{\"url\": \"https://twitter.com/repatriation_23\"}" -H "Content-type: application/json"
Example response:
{"id":"BLGZchQY","url":"https://twitter.com/repatriation_23"}
To retrieve the original URL:
curl https://staging-encore-url-shortener-rd32.encr.app/url/BLGZchQY
Example response:
{"url":"https://twitter.com/repatriation_23","id":"BLGZchQY"}
To run the application locally:
encore run
While encore run
is running, open http://localhost:9400/ to view Encore's local developer dashboard.
To deploy your application to a staging environment in Encore's free development cloud:
git add -A .
git commit -m 'Commit message'
git push encore
After pushing, head over to the Cloud Dashboard to monitor your deployment and find your production URL.
Run tests using the following command:
encore test
The project uses Docker containers for the database and other services. Here's a view of the Docker containers running:
This image shows the SQL database container and other related containers used in the project.
For more information on Encore and its features, visit the Encore Documentation.