https://github.com/madeindra/url-shortener
URL Shortener built using Typescript with Fastify and SQLite
https://github.com/madeindra/url-shortener
fastify shortener sqlite typescript url
Last synced: about 2 months ago
JSON representation
URL Shortener built using Typescript with Fastify and SQLite
- Host: GitHub
- URL: https://github.com/madeindra/url-shortener
- Owner: madeindra
- Created: 2023-12-21T12:50:43.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-12-25T05:48:25.000Z (over 2 years ago)
- Last Synced: 2025-02-28T12:13:56.845Z (over 1 year ago)
- Topics: fastify, shortener, sqlite, typescript, url
- Language: TypeScript
- Homepage:
- Size: 271 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# URL Shortener
Simple URL shortener built using Typescript with Fastify and SQLite.

## Installation
1. Clone the repository
```
git clone https://github.com/madeindra/url-shortener.git
```
2. Install dependencies
```
npm install
```
3. Build the project
```
npm run build
```
4. Export environment variables:
```
export PORT=3000
export HOST=localhost
export DB_PATH=database.db
export DB_TABLENAME=urls
```
5. Start the server
```
npm start
```
## Docker
1. Build the image
```
docker build \
--build-arg PORT=3000 \
--build-arg HOST=0.0.0.0 \
--build-arg DB_PATH=database.db \
--build-arg DB_TABLENAME=urls \
--no-cache \
. -t yourusername/url-shortener:latest
```
2. Run the container
```
docker run -d -p 3000:3000 yourusername/url-shortener:latest
```
## Usage
1. Open your browser and visit `http://localhost:3000`
2. Input your URL and custom slug (optional) to the form
3. Click `Shorten` button
4. Copy the shortened URL
## API Documentation
### Create Short URL
POST /shorten
```
{
"originalUrl": "https://www.google.com",
"customSlug": "google"
}
```
### Get Original URL
GET /:slug
## TODOs
- [X] Add homepage with form to shorten URL
- [X] Add docker support
- [ ] Add testings