https://github.com/yestool/mail-collect
📮MailBox - collect mail with Cloudflare + Huno + D1 database
https://github.com/yestool/mail-collect
Last synced: 5 months ago
JSON representation
📮MailBox - collect mail with Cloudflare + Huno + D1 database
- Host: GitHub
- URL: https://github.com/yestool/mail-collect
- Owner: yestool
- Created: 2024-01-17T08:54:38.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-17T08:56:58.000Z (over 2 years ago)
- Last Synced: 2024-05-30T12:47:29.717Z (about 2 years ago)
- Language: TypeScript
- Size: 6.84 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 📮MailBox - collect mail with Cloudflare + Huno + D1 database
[Cloudflare D1 Doc](https://developers.cloudflare.com/d1/get-started/)
## Setup
### Log in
```bash
npx wrangler login
```
```
npx wrangler d1 create
---------
✅ Successfully created DB ''
[[d1_databases]]
binding = "DB" # available in your Worker on env.DB
database_name = ""
database_id = ""
```
### Bind Worker to D1 database
in **wrangler.toml**
```
[[d1_databases]]
binding = "DB" # available in your Worker on env.DB
database_name = ""
database_id = ""
```
### init database
```
npm run initSql
```
### Deploy
```
$ npm run deploy
> analytics_with_cloudflare@0.0.0 deploy
> wrangler deploy
Proxy environment variables detected. We'll use your proxy for fetch requests.
⛅️ wrangler 3.22.5
-------------------
Your worker has access to the following bindings:
- D1 Databases:
- DB: mail_collect_db ()
Total Upload: 25.64 KiB / gzip: 9.46 KiB
Uploaded mail-collect (1.04 sec)
Published mail-collect (0.45 sec)
https://mail-collect.xxxxx.workers.dev
Current Deployment ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxx
```
## Use
check `use-demo.html`
## query data:
```
npx wrangler d1 execute mail_collect_db --command="SELECT * FROM t_address" --local
npx wrangler d1 execute mail_collect_db --command="SELECT * FROM t_mail" --local
```