A simple and efficient URL shortener built with Node.js, Bun, and Hono.
- Create short URLs with custom or auto-generated slugs
- Update existing links
- Track visits to shortened URLs
- RESTful API for easy integration
- Bun - JavaScript runtime and package manager
- Hono - Lightweight web framework
- Drizzle ORM - TypeScript ORM
- SQLite - Embedded database
Make sure you have Bun installed on your system.
-
Clone the repository:
git clone https://github.com/yourusername/node-url-shrinker.git cd node-url-shrinker -
Install dependencies:
bun install
-
Set up the database:
bun drizzle-kit migrate
To start the development server:
bash bun dev
The server will start running on http://localhost:3000 (or the port specified in your environment).
GET /:slug: Redirect to the original URLPOST /links: Create a new shortened URLGET /links: Get all links or a specific link by slugGET /links/:id: Get a specific link by IDPATCH /links/:id: Update an existing linkDELETE /links/:id: Delete a linkGET /links/:id/visits: Get all visits for a specific linkGET /links/:id/visits/:visitId: Get a specific visit for a link
For more details on the API endpoints and their usage, please refer to the comments in the src/routes/*.ts file.