{"id":13457224,"url":"https://github.com/xiadd/pastebin-worker","last_synced_at":"2025-03-24T12:31:04.180Z","repository":{"id":216395744,"uuid":"595874902","full_name":"xiadd/pastebin-worker","owner":"xiadd","description":"PasteBin based on Cloudflare","archived":false,"fork":false,"pushed_at":"2024-09-08T08:38:37.000Z","size":638,"stargazers_count":180,"open_issues_count":2,"forks_count":51,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-29T01:32:35.864Z","etag":null,"topics":["cloudflare","pastebin","worker"],"latest_commit_sha":null,"homepage":"https://as.al","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xiadd.png","metadata":{"files":{"readme":"README.en.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-01T01:29:01.000Z","updated_at":"2024-10-26T07:26:45.000Z","dependencies_parsed_at":"2024-05-19T07:28:14.514Z","dependency_job_id":"36c7fab7-3d21-42f6-8104-fb8e502e0dbd","html_url":"https://github.com/xiadd/pastebin-worker","commit_stats":null,"previous_names":["xiadd/pastebin-worker"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiadd%2Fpastebin-worker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiadd%2Fpastebin-worker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiadd%2Fpastebin-worker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiadd%2Fpastebin-worker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xiadd","download_url":"https://codeload.github.com/xiadd/pastebin-worker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245269762,"owners_count":20587839,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudflare","pastebin","worker"],"created_at":"2024-07-31T08:01:36.376Z","updated_at":"2025-03-24T12:31:03.759Z","avatar_url":"https://github.com/xiadd.png","language":"TypeScript","readme":"## Start Developing\n\n1. Install wrangler-cli\n\n```bash\nnpm i @cloudflare/wrangler -g\n```\n\nLog in to your Cloudflare account according to the documentation:\n\n```bash\nwrangler login\n```\n\nAfter executing the above command, a page will open in the browser, redirecting to the Cloudflare login page. Click to authorize login, and it will redirect to another page. Then input `wrangler whoami` in the terminal. If it displays your username, it means you have successfully logged in.\n\n2. Install Dependencies\n\n```bash\n# Install backend dependencies\nyarn install\n\n# Install frontend dependencies\ncd static\nyarn install\n```\n\n3. Create kv namespace in Cloudflare\n\n![image](https://as.al/file/unJ46x)\n\nWe have created two kv namespaces here, one for storing files and the other for storing text, and they are named `PBIMG` and `PB` respectively. It doesn't matter what names are given, the important thing is to remember the id, which will be used later.\n\n4. Modify wrangler.toml\n\n```toml\nname= \"pastebin-worker\"\ncompatibility_date = \"2023-11-28\"\naccount_id= \"\u003caccount_id\u003e\" # Replace this with your own account_id\nmain = \"src/index.ts\"\nworkers_dev = false\n\nvars = { ENVIRONMENT = \"production\" }\nroute = { pattern = \"\u003cyour domain\u003e\", custom_domain = true }\n\nkv_namespaces = [\n  { binding = \"PB\", id = \"\u003cPB kv id\u003e\" },\n  { binding = \"PBIMGS\", id =\"\u003cPB file id\u003e\" }\n]\n\n[site]\nbucket = \"./static/dist\"\n```\n\n`account_id`, `route`, `kv_namespaces` should be modified according to your own situation. We are using two kvs here, one for storing files and the other for storing text.\n\n`account_id` can be found in the Cloudflare dashboard. `route` is the route of your worker (i.e., the custom domain), and `kv_namespaces` is the id of the kv you created.\n\n5. Development\n\n```bash\n# Start the backend\nwrangler dev\n\n# Start the frontend\ncd static\nyarn dev\n```\n\nAfter the server is started, the backend address is `http://localhost:8787`, and the front-end address is `http://localhost:5173`. If you want to test the frontend package, directly execute `yarn build` in the static directory, and visit `http://localhost:8787`.\n\n# Deploy\n\nModify `.env.production` in the static directory, and set the environment variable to the domain name you configured above.\n\n```env\nVITE_API_URL= \u003cyour domain\u003e\n```\n\nGet the api key for your Cloudflare account, then set it as the secret for GitHub action, named `CF_API_TOKEN`. This way, whenever you push code to the main branch, it will automatically deploy to Cloudflare.\n\n### Method to get the API Token:\n\n![image](https://as.al/file/a60SQE)\n\nThen click `Create Token`:\n\n![image](https://as.al/file/iLcJMi)\n\nSelect the worker template and create it to get the api token.\n\n### Set the secret in the github action:\n\n![image](https://as.al/file/Zl8rbJ)\n\nSet your api token here.\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiadd%2Fpastebin-worker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxiadd%2Fpastebin-worker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiadd%2Fpastebin-worker/lists"}