mirror of
https://github.com/SrIzan10/featherbin.git
synced 2026-06-06 00:56:49 +00:00
feat: initial commit
This commit is contained in:
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
.wrangler
|
||||||
|
.dev.vars
|
||||||
|
|
||||||
|
# Change them to your taste:
|
||||||
|
package-lock.json
|
||||||
|
yarn.lock
|
||||||
|
pnpm-lock.yaml
|
||||||
|
bun.lockb
|
||||||
23
README.md
Normal file
23
README.md
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# featherbin
|
||||||
|
|
||||||
|
featherbin is the fastest pastebin on the internet. it returns stuff on plaintext to experience the **true speed**.
|
||||||
|
it also has a cool name I came up with in 5 seconds and uses cheesy tech and uses hono and has only a 40-line codebase (now that's speed)
|
||||||
|
serverless btw :sunglasses:
|
||||||
|
|
||||||
|
## usage
|
||||||
|
|
||||||
|
send a `POST` request to `https://fb.srizan.dev/paste` with the body being the content you want to paste. the response will be plaintext, containing the url of the paste.
|
||||||
|
|
||||||
|
## example
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ curl -X POST https://fb.srizan.dev/paste -d "hello, world!"
|
||||||
|
asdf2
|
||||||
|
```
|
||||||
|
|
||||||
|
## technologies used
|
||||||
|
|
||||||
|
- cloudflare workers
|
||||||
|
- hono
|
||||||
|
- cloudflare kv
|
||||||
|
- typescript
|
||||||
13
package.json
Normal file
13
package.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"scripts": {
|
||||||
|
"dev": "wrangler dev src/index.ts",
|
||||||
|
"deploy": "wrangler deploy --minify src/index.ts"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"hono": "^4.2.5"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@cloudflare/workers-types": "^4.20240403.0",
|
||||||
|
"wrangler": "^3.47.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
37
src/index.ts
Normal file
37
src/index.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
type Bindings = {
|
||||||
|
featherbin: KVNamespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
import { Hono } from 'hono'
|
||||||
|
const app = new Hono<{ Bindings: Bindings }>()
|
||||||
|
|
||||||
|
function randomString(length = 5) {
|
||||||
|
const charset = 'abcdefghijklmnopqrstuvwxyz0123456789'
|
||||||
|
let res = ''
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
res += charset[Math.floor(Math.random() * charset.length)]
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
app.get('/', async (c) => {
|
||||||
|
return c.text('this is featherbin, create a paste by POSTing to /paste with the content in the body')
|
||||||
|
})
|
||||||
|
|
||||||
|
app.post('/paste', async (c) => {
|
||||||
|
const id = randomString()
|
||||||
|
const content = await c.req.text()
|
||||||
|
await c.env.featherbin.put(id, content)
|
||||||
|
return c.json({ id })
|
||||||
|
})
|
||||||
|
|
||||||
|
app.get('/:id', async (c) => {
|
||||||
|
const id = c.req.param('id')
|
||||||
|
const content = await c.env.featherbin.get(id)
|
||||||
|
if (content === null) {
|
||||||
|
return c.text('paste not found', 404)
|
||||||
|
}
|
||||||
|
return c.text(content)
|
||||||
|
})
|
||||||
|
|
||||||
|
export default app
|
||||||
16
tsconfig.json
Normal file
16
tsconfig.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ESNext",
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "Bundler",
|
||||||
|
"strict": true,
|
||||||
|
"lib": [
|
||||||
|
"ESNext"
|
||||||
|
],
|
||||||
|
"types": [
|
||||||
|
"@cloudflare/workers-types"
|
||||||
|
],
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"jsxImportSource": "hono/jsx"
|
||||||
|
},
|
||||||
|
}
|
||||||
25
wrangler.toml
Normal file
25
wrangler.toml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
name = "featherbin"
|
||||||
|
compatibility_date = "2023-12-01"
|
||||||
|
|
||||||
|
kv_namespaces = [
|
||||||
|
{ binding = "featherbin", id = "362b8cce32ee48079e0fbd201bb669a5" }
|
||||||
|
]
|
||||||
|
|
||||||
|
# [vars]
|
||||||
|
# MY_VAR = "my-variable"
|
||||||
|
|
||||||
|
# [[kv_namespaces]]
|
||||||
|
# binding = "MY_KV_NAMESPACE"
|
||||||
|
# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||||
|
|
||||||
|
# [[r2_buckets]]
|
||||||
|
# binding = "MY_BUCKET"
|
||||||
|
# bucket_name = "my-bucket"
|
||||||
|
|
||||||
|
# [[d1_databases]]
|
||||||
|
# binding = "DB"
|
||||||
|
# database_name = "my-database"
|
||||||
|
# database_id = ""
|
||||||
|
|
||||||
|
# [ai]
|
||||||
|
# binding = "AI"
|
||||||
Reference in New Issue
Block a user