EdgePaste is a simple and lightweight pastebin application built on the Hono framework. It allows users to create, retrieve, and delete text-based pastes easily via a web interface or API. The project is designed to work with an S3-compatible storage backend for persistence. EdgePaste is built for edge runtimes.
- Web Interface: Create and view pastes through a simple and responsive frontend.
- REST API: Programmatically interact with the application to create, retrieve, and delete pastes.
- Admin Key: Securely delete pastes using a unique admin key.
- S3 Integration: Store pastes in an S3-compatible storage backend.
- CORS Support: Cross-Origin Resource Sharing enabled for API access.
- Logging: Built-in logging for debugging and monitoring.
-
Clone the repository:
git clone https://github.com/amirparsadd/edgepaste.git cd edgepaste -
Install dependencies:
npm install
-
Set up your environment variables (see Environment Variables).
-
Start the development server:
npm run dev
- Navigate to the root URL of the application.
- Create a new paste by entering text and clicking "Create".
- Copy the generated link to share the paste with others.
- Use the admin key displayed to delete the paste if needed.
- Endpoint:
POST /api/paste - Request Body:
{ "contents": "Your paste content here" } - Response:
{ "key": "pasteKey", "adminKey": "adminKey" }
- Endpoint:
GET /api/paste/:key - Response:
{ "result": "Your paste content here" }
- Endpoint:
DELETE /api/paste/:key - Request Body:
{ "adminKey": "adminKey" } - Response:
- Success:
200 OK - Invalid Admin Key:
401 Unauthorized - Paste Not Found:
404 Not Found
- Success:
The application requires the following environment variables to be set up:
| Variable | Description |
|---|---|
S3.endpoint |
The S3-compatible storage endpoint. |
S3.bucket |
The name of your S3 bucket. |
S3.accessKey |
Your S3 access key. |
S3.secretKey |
Your S3 secret key. |
BASE_URL |
The base URL of your application. |
Create a src/env.ts file in the project and add these variables.
Example:
export const S3 = {
accessKey: "123",
secretKey: "123",
endpoint: "example.com",
bucket: "bucketname"
}
export const BASE_URL = "http://localhost:3000"-
Build and serve in dev mode:
npm run dev
-
Build for Production:
npm run build
-
Build and deploy to r1ec:
npm run deploy
route/api/: Contains the API route handlers.route/app/: Contains the frontend route handlers and JSX components.storage.ts: Handles S3 storage operations (get,set,remove).utils/: Utility functions (e.g., key generation).env.ts: Environment configuration.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request with your improvements or bug fixes.
- Hono - A lightweight web framework for the Edge.
- Tailwind CSS - Utility-first CSS framework.
- Implement rate-limiting for API endpoints.
- Write tests.