- Notifications
You must be signed in to change notification settings - Fork0
Pastebin on Cloudflare worker, with friendly CLI usage and rich features
License
Nyvryl/pastebin-worker
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This is a pastebin that can be deployed on Cloudflare workers. Try it onshz.al.
Philosophy: effortless deployment, friendly CLI usage, rich functionality.
Features:
- Share your paste with as short as 4 characters
- Customize the paste URL
- Update anddelete your paste as you want
- Expire your paste after a period of time
- Syntax highlighting powered by PrismJS
- Displaymarkdown file as HTML
- Used as a URL shortener
- Customize returned mimetype
You can post, update, delete your paste directly on the website (such asshz.al).
It also provides a convenient HTTP API to use. SeeAPI reference for details. You can easily call API via command line (using
curlor similar tools).pb is a bash script to make it easier to use on command line.
- If deployed on Cloudflare Worker free-tier plan, the service allows at most 100,000 reads and 1000 writes, 1000 deletes per day.
- Due to the size limit of Cloudflare KV storage, the size of each paste is bounded under 25 MB.
You are free to deploy the pastebin on your own domain if you host your domain on Cloudflare.
Install
nodeandyarn.Create a KV namespace on Cloudflare workers dashboard, remember its ID.
Clone the repository and enter the directory.
Modify entries in
wrangler.toml. Its comments will tell you how.Login to Cloudflare and deploy with the following steps:
$yarn install$yarn wrangler login$yarn deploy
- Enjoy!
If you want a private deployment (only you can upload paste, but everyone can read the paste), add the following entry to yourwrangler.toml.
[vars.BASIC_AUTH]user1 ="passwd1"user2 ="passwd2"
Now every access to POST request, and every access to static pages, requires an HTTP basic auth with the user-password pair listed above. For example:
$curl example-pb.comHTTP basic auth is required$curl -Fc=@/path/to/file example-pb.comHTTP basic auth is required$curl -u admin1:wrong-passwd -Fc=@/path/to/file example-pb.comError 401: incorrect passwd for basic auth$curl -u admin1:this-is-passwd-1 -Fc=@/path/to/file example-pb.com{ "url": "https://example-pb.com/YCDX", "suggestUrl": null, "admin": "https://example-pb.com/YCDX:Sij23HwbMjeZwKznY3K5trG8", "isPrivate": false}
Delete a paste:
$yarn delete-paste<name-of-paste>List pastes:
$yarn wrangler kv:key list --binding PB> kv_list.jsonRun a local simulator:
$yarn devRun tests:
$yarntestRun tests with coverage report:
$yarn coverageAbout
Pastebin on Cloudflare worker, with friendly CLI usage and rich features
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Languages
- JavaScript73.2%
- Shell18.8%
- HTML8.0%