Coder Social home page Coder Social logo

shuxiaokai / pastebin-cloudflareworker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sharzyl/pastebin-worker

0.0 0.0 0.0 253 KB

A pastebin based on Cloudflare worker, with friendly CLI usage and rich features

Home Page: https://shz.al

License: MIT License

Shell 40.46% JavaScript 45.12% Makefile 3.62% HTML 10.80%

pastebin-cloudflareworker's Introduction

Pastebin based on Cloudflare Workers

This is a pastebin that can be deployed on Cloudflare workers. Try it on shz.al.

Philosophy: effortless deployment, friendly CLI usage, rich functionality.

Features:

  1. Share your paste with as short as 4 characters
  2. Customize the paste URL as you want
  3. Make changes to uploaded paste
  4. Delete your paste after uploading
  5. Let your paste deleted from the server after a period of time
  6. Syntax highlighting powered by Prism
  7. Redirect to custom URL
  8. Specify the mimetype when fetching your paste
  9. Optional longer paste URL for better privacy

Usage

You can post, update, delete your paste directly on the website (such as shz.al).

It also provide a convenient HTTP API to use. See API reference for details. You can easily call API via command line (using curl or anything else).

pb is bash script to make it easier to use on command line.

Limitations

  1. If deployed on Cloudflare Worker free-tier plan, the service allows at most 100,000 reads and 1000 writes, 1000 deletes per day.
  2. Due to the size limit of Cloudflare KV storage, the size of each paste should be smaller than 25 MB.

Deploy

You are free to deploy the pastebin on your own domain if you host your domain on Cloudflare.

Requirements:

  1. *nix environment with bash and basic cli programs. If you are using Windows, try cygwin, WSL or something.
  2. GNU make.
  3. node and yarn.
  4. wrangler, the official cli program to manage Cloudflare workers.

Create two KV namespaces on Cloudflare workers dashboard (one for production, one for test). Remember their IDs. If you do not need testing, simply create one.

Clone the repository and enter the directory. Login to your Cloudflare account with wrangler login. Modify entries in wrangler.toml according to your own account information (account_id, zone_id, kv_namespaces.id, kv_namespaces.preview_id are what you need to modify). Refer to Cloudflare doc on how to find out these parameters.

Modify the contents in config.json (which controls the generation of static pages): BASE_URL is the URL of your site (no trailing slash); FAVICON is the URL to the favicon you want to use on your site.

Deploy and enjoy!

$ yarn install
$ mkdir dist && make deploy

pastebin-cloudflareworker's People

Contributors

misaka13514 avatar sharzyl avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.