URL shortener service based on Cloudflare Workers and D1 database.
Deploy your own duan API service on Cloudflare Workers.
Install the Raycast extension from the Raycast Extension Store.
Or manual installation:
git clone https://github.com/insv23/duan-raycast-extension.git && cd duan-raycast-extension
npm install && npm run dev
Configure the extension with your API host and token.
Start using the extension to shorten and manage your links.
.
├── README.md
├── package.json
├── src/
│ ├── components/
│ │ ├── LinkDetail.tsx # Link edit form
│ │ └── LinkItem.tsx # List item component
│ ├── hooks/
│ │ └── useLinks.ts # Data fetching hook
│ ├── services/
│ │ ├── api/
│ │ │ ├── client.ts # API client implementation
│ │ │ ├── config.ts # API configuration
│ │ │ ├── endpoints/
│ │ │ │ ├── links.ts # Links API endpoints
│ │ │ │ └── slugs.ts # Slugs API endpoints
│ │ │ └── index.ts # API exports
│ │ ├── search.ts # Search utilities
│ │ └── validation/
│ │ ├── slug/
│ │ │ ├── cache.ts # Slug cache management
│ │ │ ├── index.ts # Slug validation logic
│ │ │ └── types.ts # Slug validation types
│ │ ├── url/
│ │ │ ├── index.ts # URL validation logic
│ │ │ └── types.ts # URL validation types
│ │ └── index.ts # Validation exports
│ ├── types/
│ │ └── index.ts # TypeScript definitions
│ ├── utils/
│ │ └── random.ts # Random slug generation
│ ├── list-links.tsx # List links command
│ └── shorten-link.tsx # Create link command
The extension provides a powerful search feature that allows users to find links by:
Search implementation supports:
Example:
// Search across all fields
const results = searchLinks(links, "github");
// Will match:
// - Short code: "gh-repo"
// - URL: "https://github.com/..."
// - Description: "My GitHub repository"
Raycast provides three different caching mechanisms, each suited for specific use cases:
To demonstrate how to choose the appropriate caching mechanism, here are two concrete examples from our project:
useCachedPromise
Cache
(low-level API)