GithubHelp home page GithubHelp logo

lixinyusiwen / pastebin-worker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from igdume/pastebin-worker

0.0 0.0 0.0 332 KB

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

Home Page: https://igdu.cloudns.org/

License: MIT License

Shell 35.99% JavaScript 50.68% Makefile 3.82% HTML 9.51%

pastebin-worker's Introduction

Pastebin-worker

This is a pastebin that can be deployed on Cloudflare workers. It forks from shz.al, thanks for this project.

Demo: igdu or shz.al

shz.al's original guideline should change some command line with the relates app changing, such as wrangler publish do not support or recommend now. You should change the two "wrangler publish" to "wrangler deploy" in makefile. Maybe others should remember, but I forget.

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

Features:

  1. Share your paste with as short as 4 characters
  2. Customize the paste URL
  3. Update and delete your paste as you want
  4. Expire your paste after a period of time
  5. Syntax highlighting powered by PrismJS
  6. Display markdown file as HTML
  7. Used as a URL shortener
  8. Customize returned mimetype

Usage methods

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

  2. It also provides a convenient HTTP API to use. See API reference for details. You can easily call API via command line (using curl or similar tools).

  3. pb is a 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 is bounded under 25 MB.

Deploy

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

1.Requirements: 1.1. *nix environment with bash and basic cli programs. If you are using Windows, try cygwin, WSL or something. 1.2. GNU make. 1.3. node and yarn. This part maybe be more important than you think in windows system. Recomman setting: git windows, nodejs(ltsl), cygwin(for install other dependecy app),yarn.

2.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,Remember the KV ID. Don't create a workers, just KV. Workers will be created by the command make deploy in later setting.

3.Clone the repository to your local file path and enter the directory.

4.Login to your Cloudflare account with comand wrangler login. Before that your should install the newest wrangler, the old wrangler do not support some command. Wrangler login will ask you to authenticate your cloudflare account could make change throuhg wrangler.

5.Modify entries in wrangler.toml according to your own account information (account_id, routes, kv namespace ids are what you need to modify). The env.preview section can be safely removed if you do not need a testing deployment. Refer to Cloudflare doc on how to find out these parameters.

6.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. If you need testing, also modify config.preview.json.

  1. Deploy and enjoy! Before that, check the nodejs's version, the old will not support by wrangler; and you should check whether you has installed yarn before you deploy by cloudflare wrangler. Then you could make deploy. Then you could find your pastebin service will be ok through your custom domain.

Auth

If you want a private deployment (only you can upload paste, but everyone can read the paste), add the following entry to your config.json (other configurations also contained in the outmost brace):

{
  "basicAuth": {
    "enabled": true,
    "passwd": {
      "admin1": "this-is-passwd-1",
      "admin2": "this-is-passwd-2"
    }
  }
}

Now every access to PUT or POST request, and every access to the index page, requires an HTTP basic auth with the user-password pair listed above. For example:

$ curl example-pb.com
HTTP basic auth is required

$ curl -Fc=@/path/to/file example-pb.com
HTTP basic auth is required

$ curl -u admin1:wrong-passwd -Fc=@/path/to/file example-pb.com
Error 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
}

pastebin-worker's People

Contributors

sharzyl avatar misaka13514 avatar igdume avatar ksco 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.