Skip to content

Commit d08d707

Browse files
feat: add epic web stack (#3)
1 parent b21d9cc commit d08d707

File tree

355 files changed

+47555
-423
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

355 files changed

+47555
-423
lines changed

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ export default defineConfig(() => {
209209

210210
When using a custom server, you'll need to:
211211

212-
1. Create a server handler (`server/app.ts`):
212+
1. Create a server handler (`server/index.ts`):
213213
```ts
214214
import { createRequestHandler } from '@react-router/express';
215215

@@ -363,7 +363,7 @@ VALUE_FROM_CLOUDFLARE = "Hello from Cloudflare"
363363
# watch_dir = "app"
364364
```
365365
366-
3. **Create Worker Entry** (`server/app.ts`):
366+
3. **Create Worker Entry** (`server/index.ts`):
367367
```ts
368368
import { createRequestHandler } from 'react-router';
369369

@@ -465,4 +465,4 @@ The plugin automatically:
465465
466466
## License
467467
468-
MIT
468+
MIT

examples/cloudflare/server/index.ts

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { createRequestHandler } from 'react-router';
2+
3+
declare global {
4+
interface CloudflareEnvironment extends Env {}
5+
interface ImportMeta {
6+
env: {
7+
MODE: string;
8+
};
9+
}
10+
}
11+
12+
declare module 'react-router' {
13+
export interface AppLoadContext {
14+
cloudflare: {
15+
env: CloudflareEnvironment;
16+
ctx: ExecutionContext;
17+
};
18+
}
19+
}
20+
// @ts-expect-error - virtual module provided by React Router at build time
21+
import * as serverBuild from 'virtual/react-router/server-build';
22+
23+
const requestHandler = createRequestHandler(serverBuild, import.meta.env.MODE);
24+
25+
export default {
26+
fetch(request, env, ctx) {
27+
return requestHandler(request, {
28+
cloudflare: { env, ctx },
29+
});
30+
},
31+
} satisfies ExportedHandler<CloudflareEnvironment>;

examples/custom-node-server/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"@rsbuild/plugin-react-router": "workspace:*",
3030
"@rsdoctor/rspack-plugin": "^0.4.13",
3131
"@types/express": "^5.0.0",
32-
"@types/express-serve-static-core": "^5.0.2",
32+
"@types/express-serve-static-core": "^5.0.6",
3333
"@types/react": "^19.0.2",
3434
"@types/react-dom": "^19.0.2",
3535
"tailwindcss": "^3.4.17",

examples/custom-node-server/server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ async function startServer() {
2020

2121
app.use(async (req, res, next) => {
2222
try {
23-
const bundle = /** @type {import("./server/app")} */ (
23+
const bundle = /** @type {import("./server/index.js")} */ (
2424
await devServer.environments.node.loadBundle('app')
2525
);
2626
await bundle.app(req, res, next);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import 'react-router';
2+
import { createRequestHandler } from '@react-router/express';
3+
4+
declare module 'react-router' {
5+
interface AppLoadContext {
6+
VALUE_FROM_EXPRESS: string;
7+
}
8+
}
9+
10+
export const index = createRequestHandler({
11+
// @ts-expect-error - virtual module provided by React Router at build time
12+
build: () => import('virtual/react-router/server-build'),
13+
getLoadContext() {
14+
return {
15+
VALUE_FROM_EXPRESS: 'Hello from Express',
16+
};
17+
},
18+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!-- Summary: Put your summary here -->
2+
3+
## Test Plan
4+
5+
<!-- What steps need to be taken to verify this works as expected? -->
6+
7+
## Checklist
8+
9+
- [ ] Tests updated
10+
- [ ] Docs updated
11+
12+
## Screenshots
13+
14+
<!-- If what you're changing is within the app, please show before/after.
15+
You can provide a video as well if that makes more sense -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
name: 🚀 Deploy
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- dev
7+
pull_request: {}
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
permissions:
14+
actions: write
15+
contents: read
16+
17+
jobs:
18+
lint:
19+
name: ⬣ ESLint
20+
runs-on: ubuntu-22.04
21+
steps:
22+
- name: ⬇️ Checkout repo
23+
uses: actions/checkout@v4
24+
25+
- name: ⎔ Setup node
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 22
29+
30+
- name: 📥 Download deps
31+
uses: bahmutov/npm-install@v1
32+
33+
- name: 🖼 Build icons
34+
run: npm run build:icons
35+
36+
- name: 🔬 Lint
37+
run: npm run lint
38+
39+
typecheck:
40+
name: ʦ TypeScript
41+
runs-on: ubuntu-22.04
42+
steps:
43+
- name: ⬇️ Checkout repo
44+
uses: actions/checkout@v4
45+
46+
- name: ⎔ Setup node
47+
uses: actions/setup-node@v4
48+
with:
49+
node-version: 22
50+
51+
- name: 📥 Download deps
52+
uses: bahmutov/npm-install@v1
53+
54+
- name: 🖼 Build icons
55+
run: npm run build:icons
56+
57+
- name: 🔎 Type check
58+
run: npm run typecheck --if-present
59+
60+
vitest:
61+
name: ⚡ Vitest
62+
runs-on: ubuntu-22.04
63+
steps:
64+
- name: ⬇️ Checkout repo
65+
uses: actions/checkout@v4
66+
67+
- name: ⎔ Setup node
68+
uses: actions/setup-node@v4
69+
with:
70+
node-version: 22
71+
72+
- name: 📥 Download deps
73+
uses: bahmutov/npm-install@v1
74+
75+
- name: 🏄 Copy test env vars
76+
run: cp .env.example .env
77+
78+
- name: 🖼 Build icons
79+
run: npm run build:icons
80+
81+
- name: ⚡ Run vitest
82+
run: npm run test -- --coverage
83+
84+
playwright:
85+
name: 🎭 Playwright
86+
runs-on: ubuntu-22.04
87+
timeout-minutes: 60
88+
steps:
89+
- name: ⬇️ Checkout repo
90+
uses: actions/checkout@v4
91+
92+
- name: 🏄 Copy test env vars
93+
run: cp .env.example .env
94+
95+
- name: ⎔ Setup node
96+
uses: actions/setup-node@v4
97+
with:
98+
node-version: 22
99+
100+
- name: 📥 Download deps
101+
uses: bahmutov/npm-install@v1
102+
103+
- name: 📥 Install Playwright Browsers
104+
run: npm run test:e2e:install
105+
106+
- name: 🛠 Setup Database
107+
run: npx prisma migrate deploy
108+
109+
- name: 🏦 Cache Database
110+
id: db-cache
111+
uses: actions/cache@v4
112+
with:
113+
path: prisma/data.db
114+
key:
115+
db-cache-schema_${{ hashFiles('./prisma/schema.prisma')
116+
}}-migrations_${{ hashFiles('./prisma/migrations/*/migration.sql')
117+
}}
118+
119+
- name: 🌱 Seed Database
120+
if: steps.db-cache.outputs.cache-hit != 'true'
121+
run: npx prisma migrate reset --force
122+
123+
- name: 🏗 Build
124+
run: npm run build
125+
126+
- name: 🎭 Playwright tests
127+
run: npx playwright test
128+
129+
- name: 📊 Upload report
130+
uses: actions/upload-artifact@v4
131+
if: always()
132+
with:
133+
name: playwright-report
134+
path: playwright-report/
135+
retention-days: 30
136+
137+
deploy:
138+
name: 🚀 Deploy
139+
runs-on: ubuntu-22.04
140+
needs: [lint, typecheck, vitest, playwright]
141+
# only build/deploy branches on pushes
142+
if: ${{ github.event_name == 'push' }}
143+
144+
steps:
145+
- name: ⬇️ Checkout repo
146+
uses: actions/checkout@v4
147+
with:
148+
fetch-depth: '50'
149+
150+
- name: 👀 Read app name
151+
uses: SebRollen/[email protected]
152+
id: app_name
153+
with:
154+
file: 'fly.toml'
155+
field: 'app'
156+
157+
- name: 🎈 Setup Fly
158+
uses: superfly/flyctl-actions/[email protected]
159+
160+
- name: 🚀 Deploy Staging
161+
if: ${{ github.ref == 'refs/heads/dev' }}
162+
run:
163+
flyctl deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }}
164+
--app ${{ steps.app_name.outputs.value }}-staging
165+
env:
166+
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
167+
168+
- name: 🚀 Deploy Production
169+
if: ${{ github.ref == 'refs/heads/main' }}
170+
run:
171+
flyctl deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }}
172+
--build-secret SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
173+
env:
174+
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: 🔖 Version
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- dev
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
version:
17+
name: 🚀 Update Version
18+
runs-on: ubuntu-22.04
19+
if: ${{ github.event_name == 'push' }}
20+
21+
steps:
22+
- name: ⬇️ Checkout repo
23+
uses: actions/checkout@v4
24+
25+
- name: 🔢 Get HEAD commit hash
26+
id: get_head_hash
27+
run: echo "HEAD_HASH=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
28+
29+
- name: 📅 Get current date
30+
id: get_date
31+
run:
32+
echo "CURRENT_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
33+
34+
- name: 📝 Update package.json
35+
run: |
36+
jq '
37+
if .["epic-stack"] then
38+
.["epic-stack"].head = "${{ steps.get_head_hash.outputs.HEAD_HASH }}" |
39+
.["epic-stack"].date = "${{ steps.get_date.outputs.CURRENT_DATE }}"
40+
else
41+
.["epic-stack"] = {
42+
"head": "${{ steps.get_head_hash.outputs.HEAD_HASH }}",
43+
"date": "${{ steps.get_date.outputs.CURRENT_DATE }}"
44+
}
45+
end
46+
' package.json > temp.json && mv temp.json package.json
47+
48+
- name: 💾 Commit changes
49+
run: |
50+
git config --local user.email "[email protected]"
51+
git config --local user.name "kody"
52+
git add package.json
53+
git commit -m "Update epic-stack version [skip ci]"
54+
git push

examples/epic-stack/.gitignore

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
node_modules
2+
.DS_store
3+
4+
/build
5+
/server-build
6+
.env
7+
.cache
8+
9+
/prisma/data.db
10+
/prisma/data.db-journal
11+
/tests/prisma
12+
13+
/test-results/
14+
/playwright-report/
15+
/playwright/.cache/
16+
/tests/fixtures/email/
17+
/coverage
18+
19+
/other/cache.db
20+
21+
# Easy way to create temporary files/folders that won't accidentally be added to git
22+
*.local.*
23+
24+
# generated files
25+
/app/components/ui/icons
26+
.react-router/

examples/epic-stack/.prettierignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
node_modules
2+
3+
/build
4+
/public/build
5+
/server-build
6+
.env
7+
8+
/test-results/
9+
/playwright-report/
10+
/playwright/.cache/
11+
/tests/fixtures/email/*.json
12+
/coverage
13+
/prisma/migrations
14+
15+
package-lock.json
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"recommendations": [
3+
"bradlc.vscode-tailwindcss",
4+
"dbaeumer.vscode-eslint",
5+
"esbenp.prettier-vscode",
6+
"prisma.prisma",
7+
"qwtel.sqlite-viewer",
8+
"yoavbls.pretty-ts-errors",
9+
"github.vscode-github-actions"
10+
]
11+
}

0 commit comments

Comments
 (0)