create-workerstack 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -0
- package/bin/index.js +4 -3
- package/package.json +1 -1
- package/template/README.md +109 -0
- package/template/package.json +2 -0
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# create-workerstack
|
|
2
|
+
|
|
3
|
+
Scaffold a full-stack Cloudflare Workers app in seconds.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# With bun (recommended)
|
|
9
|
+
bunx create-workerstack@latest my-app
|
|
10
|
+
|
|
11
|
+
# With npm
|
|
12
|
+
npm create workerstack@latest my-app
|
|
13
|
+
|
|
14
|
+
# With pnpm
|
|
15
|
+
pnpm create workerstack@latest my-app
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## What's Included
|
|
19
|
+
|
|
20
|
+
| Technology | Role |
|
|
21
|
+
|---|---|
|
|
22
|
+
| **Cloudflare Workers** | Edge-first serverless runtime |
|
|
23
|
+
| **Hono** | Ultrafast web framework |
|
|
24
|
+
| **React 19** | UI library with SSR support |
|
|
25
|
+
| **MUI Material** | Production-grade component library |
|
|
26
|
+
| **Better Auth** | Authentication (email/password, OAuth, admin) |
|
|
27
|
+
| **Drizzle ORM** | Type-safe SQL ORM with PostgreSQL |
|
|
28
|
+
| **Vite** | Build tool with HMR |
|
|
29
|
+
| **Resend** | Transactional email service |
|
|
30
|
+
| **TypeScript** | End-to-end type safety |
|
|
31
|
+
|
|
32
|
+
## CLI Options
|
|
33
|
+
|
|
34
|
+
The CLI walks you through an interactive setup:
|
|
35
|
+
|
|
36
|
+
- **Project name** — also used for `package.json` and `wrangler.jsonc`
|
|
37
|
+
- **Description** — sets `package.json` description
|
|
38
|
+
- **Package manager** — bun, npm, or pnpm
|
|
39
|
+
- **Install dependencies** — run install automatically after scaffolding
|
|
40
|
+
- **Initialize git** — run `git init` in the new project
|
|
41
|
+
|
|
42
|
+
You can also pass the project name as an argument to skip the first prompt:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
bunx create-workerstack@latest my-app
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## After Scaffolding
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
cd my-app
|
|
52
|
+
cp .env.example .env # configure your environment variables
|
|
53
|
+
bun run dev # start the development server
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
|
|
58
|
+
MIT
|
package/bin/index.js
CHANGED
|
@@ -789,7 +789,8 @@ var __dirname2 = path.dirname(__filename2);
|
|
|
789
789
|
async function main() {
|
|
790
790
|
console.log();
|
|
791
791
|
we(import_picocolors3.default.bgMagenta(import_picocolors3.default.white(" create-workerstack ")));
|
|
792
|
-
const
|
|
792
|
+
const argTarget = process.argv[2];
|
|
793
|
+
const argProjectName = argTarget === "." ? path.basename(path.resolve(".")) : argTarget;
|
|
793
794
|
const options = await be({
|
|
794
795
|
projectName: () => argProjectName ? Promise.resolve(argProjectName) : ue({
|
|
795
796
|
message: "Project name:",
|
|
@@ -834,7 +835,7 @@ async function main() {
|
|
|
834
835
|
const packageManager = options.packageManager;
|
|
835
836
|
const installDeps = options.installDeps;
|
|
836
837
|
const initGit = options.initGit;
|
|
837
|
-
const targetDir = path.resolve(process.cwd(), projectName);
|
|
838
|
+
const targetDir = argTarget === "." ? path.resolve(".") : path.resolve(process.cwd(), projectName);
|
|
838
839
|
if (fs.existsSync(targetDir)) {
|
|
839
840
|
const files = fs.readdirSync(targetDir);
|
|
840
841
|
if (files.length > 0) {
|
|
@@ -892,7 +893,7 @@ async function main() {
|
|
|
892
893
|
}
|
|
893
894
|
const pmRun = packageManager === "npm" ? "npm run" : packageManager;
|
|
894
895
|
ye([
|
|
895
|
-
`cd ${projectName}`,
|
|
896
|
+
argTarget === "." ? "" : `cd ${projectName}`,
|
|
896
897
|
!installDeps ? `${packageManager} install` : "",
|
|
897
898
|
"cp .env.example .env",
|
|
898
899
|
`${pmRun} dev`
|
package/package.json
CHANGED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# WorkerStack App
|
|
2
|
+
|
|
3
|
+
Full-stack app running on Cloudflare Workers, built with [WorkerStack](https://www.npmjs.com/package/create-workerstack).
|
|
4
|
+
|
|
5
|
+
## Stack
|
|
6
|
+
|
|
7
|
+
- **Runtime** — Cloudflare Workers (edge serverless)
|
|
8
|
+
- **Backend** — Hono
|
|
9
|
+
- **Frontend** — React 19 + MUI Material
|
|
10
|
+
- **Auth** — Better Auth (email/password, admin plugin)
|
|
11
|
+
- **Database** — Drizzle ORM + PostgreSQL
|
|
12
|
+
- **Email** — Resend
|
|
13
|
+
- **Build** — Vite + TypeScript
|
|
14
|
+
|
|
15
|
+
## Prerequisites
|
|
16
|
+
|
|
17
|
+
- [Bun](https://bun.sh/) (or npm/pnpm)
|
|
18
|
+
- [Cloudflare account](https://dash.cloudflare.com/sign-up)
|
|
19
|
+
- PostgreSQL database (e.g. [Neon](https://neon.tech/), [Supabase](https://supabase.com/))
|
|
20
|
+
|
|
21
|
+
## Getting Started
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Install dependencies
|
|
25
|
+
bun install
|
|
26
|
+
|
|
27
|
+
# Set up environment variables
|
|
28
|
+
cp .env.example .env
|
|
29
|
+
# Edit .env with your DATABASE_URL, BETTER_AUTH_SECRET, etc.
|
|
30
|
+
|
|
31
|
+
# Generate Cloudflare types
|
|
32
|
+
bun run cf-typegen
|
|
33
|
+
|
|
34
|
+
# Run database migrations
|
|
35
|
+
bun run db:migrate
|
|
36
|
+
|
|
37
|
+
# Start development server
|
|
38
|
+
bun run dev
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The app will be available at `http://localhost:5000`.
|
|
42
|
+
|
|
43
|
+
## Scripts
|
|
44
|
+
|
|
45
|
+
| Script | Description |
|
|
46
|
+
|---|---|
|
|
47
|
+
| `bun run dev` | Start Vite dev server with HMR |
|
|
48
|
+
| `bun run build` | Production build |
|
|
49
|
+
| `bun run preview` | Build and preview locally |
|
|
50
|
+
| `bun run deploy` | Build and deploy to Cloudflare |
|
|
51
|
+
| `bun run deploy:dev` | Deploy to dev environment |
|
|
52
|
+
| `bun run cf-typegen` | Generate Cloudflare bindings types |
|
|
53
|
+
| `bun run typecheck:client` | Type-check client code |
|
|
54
|
+
| `bun run typecheck:server` | Type-check server code |
|
|
55
|
+
| `bun run db:generate` | Generate Drizzle migrations |
|
|
56
|
+
| `bun run db:migrate` | Run database migrations |
|
|
57
|
+
| `bun run ba:schema` | Generate Better Auth schema |
|
|
58
|
+
|
|
59
|
+
## Project Structure
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
src/
|
|
63
|
+
├── api/
|
|
64
|
+
│ ├── index.ts # API routes (Hono)
|
|
65
|
+
│ └── middlewares/
|
|
66
|
+
│ └── auth.ts # Authentication middleware
|
|
67
|
+
├── client/
|
|
68
|
+
│ ├── App.tsx # React app entry point
|
|
69
|
+
│ ├── main.tsx # React DOM mount
|
|
70
|
+
│ └── tsconfig.json # Client TypeScript config
|
|
71
|
+
├── database/
|
|
72
|
+
│ ├── db.ts # Drizzle ORM setup
|
|
73
|
+
│ ├── schema.ts # Database schema
|
|
74
|
+
│ ├── auth-schema.ts # Better Auth generated schema
|
|
75
|
+
│ └── migrations/ # SQL migrations
|
|
76
|
+
├── lib/
|
|
77
|
+
│ └── better-auth/
|
|
78
|
+
│ ├── index.ts # Auth instance factory
|
|
79
|
+
│ └── options.ts # Auth configuration
|
|
80
|
+
├── services/
|
|
81
|
+
│ └── email.ts # Email service (Resend)
|
|
82
|
+
├── utils/
|
|
83
|
+
│ ├── logger.ts # Structured logging
|
|
84
|
+
│ └── noCache.ts # Cache control middleware
|
|
85
|
+
├── index.tsx # Server entry (Hono app)
|
|
86
|
+
├── client.tsx # HTML shell renderer
|
|
87
|
+
└── style.css # Global styles
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Environment Variables
|
|
91
|
+
|
|
92
|
+
| Variable | Description |
|
|
93
|
+
|---|---|
|
|
94
|
+
| `DATABASE_URL` | PostgreSQL connection string |
|
|
95
|
+
| `BETTER_AUTH_URL` | Base URL for auth (e.g. `http://localhost:5000`) |
|
|
96
|
+
| `BETTER_AUTH_SECRET` | Secret key for sessions |
|
|
97
|
+
| `RESEND_API_KEY` | Resend API key for emails |
|
|
98
|
+
|
|
99
|
+
## Deploy
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Production
|
|
103
|
+
bun run deploy
|
|
104
|
+
|
|
105
|
+
# Dev environment
|
|
106
|
+
bun run deploy:dev
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Make sure to set your environment variables in the Cloudflare dashboard under **Workers & Pages > your-worker > Settings > Variables**.
|
package/template/package.json
CHANGED
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
"ba:schema": "bun x auth@latest generate --config better-auth.config.ts --output src/database/auth-schema.ts"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"@emotion/react": "^11.14.0",
|
|
20
|
+
"@emotion/styled": "^11.14.0",
|
|
19
21
|
"@mui/material": "^7.3.9",
|
|
20
22
|
"better-auth": "^1.5.5",
|
|
21
23
|
"drizzle-orm": "^0.45.1",
|