Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6565714ee4 | ||
|
|
1783f0e6bc | ||
|
|
0a7f4de321 | ||
|
|
e8b7647f3d | ||
|
|
0284b33e50 | ||
|
|
d3809b5805 | ||
|
|
a50f9b6644 | ||
|
|
3b087850e7 | ||
|
|
19f61ac454 | ||
|
|
e6c72a5789 | ||
|
|
e9040bb02f | ||
|
|
552525d272 | ||
|
|
4420e4d0fe | ||
|
|
3cc16bdeb2 | ||
|
|
48eb7d71b2 | ||
|
|
4f81f3c0ca | ||
|
|
778f0f7994 | ||
|
|
b6085ff329 | ||
|
|
ec334bbed4 | ||
|
|
e67f6b073c | ||
|
|
569ea8833b | ||
|
|
74d83da466 | ||
|
|
aff5fa2ea4 | ||
|
|
299f32a2b7 | ||
|
|
3f125e5761 | ||
|
|
fb4f50b851 | ||
|
|
5305dc37e7 | ||
|
|
3e5ef04c9f | ||
|
|
e51ff24944 | ||
|
|
c138442530 | ||
|
|
3baec5ac0f | ||
|
|
8f84dddc64 | ||
|
|
9571980898 | ||
|
|
1ce8a6a982 | ||
|
|
f0d8297f34 | ||
|
|
f49234702c | ||
|
|
f6da7be404 | ||
|
|
c7487e37f2 | ||
|
|
873ca3e4c4 | ||
|
|
c5b3ad50ca | ||
|
|
938418cec5 | ||
|
|
5d6136a445 | ||
|
|
9a64f316b9 | ||
|
|
6199afc687 | ||
|
|
f83a7d69c8 | ||
|
|
2dd3e5b170 | ||
|
|
b9e16e2b64 | ||
|
|
7f60b4d200 | ||
|
|
6e9e014fcc | ||
|
|
a54a74d7de | ||
|
|
236fcda671 | ||
|
|
9ed054e5d0 | ||
|
|
63853f22de | ||
|
|
5dd41d8022 | ||
|
|
937758bd49 | ||
|
|
7b95998b05 | ||
|
|
f069ba3827 | ||
|
|
70a032db20 | ||
|
|
243fb094e1 | ||
|
|
84202cdbe9 | ||
|
|
6370ebe48a | ||
|
|
8b271f93ac | ||
|
|
2326693bfb | ||
|
|
b209bbf4ef | ||
|
|
c4bf13744c | ||
|
|
1e3eaf0c35 | ||
|
|
d4b52e762b | ||
|
|
a4e618f327 | ||
|
|
d1951afb3c | ||
|
|
dce31905fc | ||
|
|
e58ed86d3b | ||
|
|
d833e5f1a1 |
@@ -0,0 +1,146 @@
|
|||||||
|
name: CI/CD Pipeline
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- development
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-app:
|
||||||
|
name: Build and Push App Docker Image
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set environment variables
|
||||||
|
run: |
|
||||||
|
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
|
||||||
|
echo "DOCKER_TAG=latest" >> $GITHUB_ENV
|
||||||
|
echo "ENVIRONMENT=prod" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "DOCKER_TAG=dev" >> $GITHUB_ENV
|
||||||
|
echo "ENVIRONMENT=dev" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Build and push app Docker image
|
||||||
|
run: |
|
||||||
|
docker login git.yohler.net -u ${{ github.actor }} -p ${{ secrets.PACKAGES_TOKEN }}
|
||||||
|
|
||||||
|
docker build \
|
||||||
|
-f Dockerfile \
|
||||||
|
-t git.yohler.net/kyle/flxn-app:${{ env.DOCKER_TAG }} \
|
||||||
|
-t git.yohler.net/kyle/flxn-app:${{ github.sha }} \
|
||||||
|
.
|
||||||
|
|
||||||
|
docker push git.yohler.net/kyle/flxn-app:${{ env.DOCKER_TAG }}
|
||||||
|
docker push git.yohler.net/kyle/flxn-app:${{ github.sha }}
|
||||||
|
|
||||||
|
build-pocketbase:
|
||||||
|
name: Build and Push PocketBase Docker Image
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Check if PocketBase Dockerfile or migrations changed
|
||||||
|
id: check_changes
|
||||||
|
run: |
|
||||||
|
if [ "${{ github.event.before }}" == "0000000000000000000000000000000000000000" ] || ! git cat-file -e ${{ github.event.before }} 2>/dev/null; then
|
||||||
|
echo "changed=true" >> $GITHUB_OUTPUT
|
||||||
|
elif git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -qE "(Dockerfile.pocketbase|pb_migrations/)"; then
|
||||||
|
echo "changed=true" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "changed=false" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Build and push PocketBase Docker image
|
||||||
|
if: steps.check_changes.outputs.changed == 'true' || github.event.before == '0000000000000000000000000000000000000000'
|
||||||
|
run: |
|
||||||
|
docker login git.yohler.net -u ${{ github.actor }} -p ${{ secrets.PACKAGES_TOKEN }}
|
||||||
|
|
||||||
|
docker build \
|
||||||
|
-f Dockerfile.pocketbase \
|
||||||
|
-t git.yohler.net/kyle/flxn-pocketbase:latest \
|
||||||
|
-t git.yohler.net/kyle/flxn-pocketbase:${{ github.sha }} \
|
||||||
|
.
|
||||||
|
|
||||||
|
docker push git.yohler.net/kyle/flxn-pocketbase:latest
|
||||||
|
docker push git.yohler.net/kyle/flxn-pocketbase:${{ github.sha }}
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
name: Deploy to Kubernetes
|
||||||
|
needs: [build-app, build-pocketbase]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: pin rancher host
|
||||||
|
run: echo "192.168.4.43 rancher.yohler.net" >> /etc/hosts
|
||||||
|
|
||||||
|
- name: Set environment variables
|
||||||
|
run: |
|
||||||
|
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
|
||||||
|
echo "ENVIRONMENT=prod" >> $GITHUB_ENV
|
||||||
|
echo "NAMESPACE=flxn-prod" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "ENVIRONMENT=dev" >> $GITHUB_ENV
|
||||||
|
echo "NAMESPACE=flxn-dev" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Install kubectl
|
||||||
|
run: |
|
||||||
|
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
||||||
|
chmod +x kubectl
|
||||||
|
mv kubectl /usr/local/bin/
|
||||||
|
|
||||||
|
- name: Configure kubectl
|
||||||
|
run: |
|
||||||
|
mkdir -p $HOME/.kube
|
||||||
|
echo "${{ secrets.KUBE_CONFIG }}" | base64 -d > $HOME/.kube/config
|
||||||
|
chmod 600 $HOME/.kube/config
|
||||||
|
kubectl config set-cluster local --insecure-skip-tls-verify=true
|
||||||
|
|
||||||
|
- name: Verify kubectl access
|
||||||
|
run: |
|
||||||
|
kubectl version --client
|
||||||
|
kubectl get nodes
|
||||||
|
|
||||||
|
- name: Deploy shared services (SuperTokens)
|
||||||
|
run: |
|
||||||
|
kubectl apply -k k8s/overlays/shared/
|
||||||
|
|
||||||
|
- name: Deploy to ${{ env.ENVIRONMENT }}
|
||||||
|
run: |
|
||||||
|
kubectl apply -k k8s/overlays/${{ env.ENVIRONMENT }}/
|
||||||
|
|
||||||
|
- name: Force rollout to pull latest image
|
||||||
|
run: |
|
||||||
|
kubectl rollout restart deployment/flxn-app -n ${{ env.NAMESPACE }}
|
||||||
|
kubectl rollout restart deployment/flxn-pocketbase -n ${{ env.NAMESPACE }}
|
||||||
|
|
||||||
|
- name: Wait for rollout
|
||||||
|
run: |
|
||||||
|
kubectl rollout status deployment/flxn-app -n ${{ env.NAMESPACE }} --timeout=5m
|
||||||
|
kubectl rollout status deployment/flxn-pocketbase -n ${{ env.NAMESPACE }} --timeout=5m
|
||||||
|
|
||||||
|
- name: Verify deployment
|
||||||
|
run: |
|
||||||
|
kubectl get pods -n ${{ env.NAMESPACE }} -l app=flxn
|
||||||
|
kubectl get svc -n ${{ env.NAMESPACE }} -l app=flxn
|
||||||
|
kubectl get ingress -n ${{ env.NAMESPACE }}
|
||||||
|
|
||||||
|
- name: Check app health
|
||||||
|
run: |
|
||||||
|
sleep 15
|
||||||
|
APP_POD=$(kubectl get pod -n ${{ env.NAMESPACE }} -l component=app -o jsonpath='{.items[0].metadata.name}')
|
||||||
|
kubectl exec -n ${{ env.NAMESPACE }} $APP_POD -- wget -O- http://localhost:3000/api/health || echo "Health check failed (endpoint may not exist yet)"
|
||||||
|
|
||||||
|
- name: Check PocketBase health
|
||||||
|
run: |
|
||||||
|
PB_POD=$(kubectl get pod -n ${{ env.NAMESPACE }} -l component=pocketbase -o jsonpath='{.items[0].metadata.name}')
|
||||||
|
kubectl exec -n ${{ env.NAMESPACE }} $PB_POD -- wget -O- http://localhost:8090/api/health || echo "PocketBase health check completed"
|
||||||
@@ -17,7 +17,7 @@ yarn.lock
|
|||||||
/playwright-report/
|
/playwright-report/
|
||||||
/blob-report/
|
/blob-report/
|
||||||
/playwright/.cache/
|
/playwright/.cache/
|
||||||
/scripts/
|
/_scripts/
|
||||||
/pb_data/
|
/pb_data/
|
||||||
/.tanstack/
|
/.tanstack/
|
||||||
/dist/
|
/dist/
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
FROM oven/bun:1 AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package.json bun.lock ./
|
||||||
|
|
||||||
|
RUN bun install --frozen-lockfile
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN bun run build
|
||||||
|
|
||||||
|
FROM oven/bun:1-alpine AS runtime
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY --from=builder /app/dist ./dist
|
||||||
|
COPY --from=builder /app/server.ts ./server.ts
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
ENV PORT=3000
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
||||||
|
CMD bun -e "fetch('http://localhost:3000/api/health').then(r => r.ok ? process.exit(0) : process.exit(1)).catch(() => process.exit(1))"
|
||||||
|
|
||||||
|
CMD ["bun", "run", "server.ts"]
|
||||||
@@ -1,16 +1,23 @@
|
|||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
|
||||||
ARG PB_VERSION=0.29.2
|
ARG PB_VERSION=0.26.5
|
||||||
|
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
unzip \
|
unzip \
|
||||||
ca-certificates
|
ca-certificates
|
||||||
|
|
||||||
# download and unzip PocketBase
|
|
||||||
ADD https://github.com/pocketbase/pocketbase/releases/download/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_amd64.zip /tmp/pb.zip
|
ADD https://github.com/pocketbase/pocketbase/releases/download/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_amd64.zip /tmp/pb.zip
|
||||||
RUN unzip /tmp/pb.zip -d /pb/
|
RUN unzip /tmp/pb.zip -d /pb/ && \
|
||||||
|
rm /tmp/pb.zip && \
|
||||||
|
chmod +x /pb/pocketbase
|
||||||
|
|
||||||
|
RUN mkdir -p /pb/pb_data
|
||||||
|
|
||||||
|
COPY pb_migrations /pb/pb_migrations
|
||||||
|
|
||||||
EXPOSE 8090
|
EXPOSE 8090
|
||||||
|
|
||||||
# start PocketBase
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
||||||
CMD ["/pb/pocketbase", "serve", "--http=0.0.0.0:8090"]
|
CMD wget --no-verbose --tries=1 --spider http://localhost:8090/api/health || exit 1
|
||||||
|
|
||||||
|
CMD ["/pb/pocketbase", "serve", "--http=0.0.0.0:8090", "--dir=/pb/pb_data", "--migrationsDir=/pb/pb_migrations"]
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ services:
|
|||||||
- .env.docker
|
- .env.docker
|
||||||
volumes:
|
volumes:
|
||||||
- postgres-data:/var/lib/postgresql/data
|
- postgres-data:/var/lib/postgresql/data
|
||||||
- ./.docker-postgres-init:/docker-entrypoint-initdb.d
|
|
||||||
networks:
|
networks:
|
||||||
- app-network
|
- app-network
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,129 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: flxn-app
|
||||||
|
labels:
|
||||||
|
app: flxn
|
||||||
|
component: app
|
||||||
|
spec:
|
||||||
|
replicas: 1 # Must stay at 1 for SSE
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: flxn
|
||||||
|
component: app
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: flxn
|
||||||
|
component: app
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: flxn-app
|
||||||
|
image: git.yohler.net/kyle/flxn-app:latest
|
||||||
|
imagePullPolicy: Always
|
||||||
|
ports:
|
||||||
|
- containerPort: 3000
|
||||||
|
name: http
|
||||||
|
protocol: TCP
|
||||||
|
env:
|
||||||
|
- name: VITE_API_DOMAIN
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: flxn-config
|
||||||
|
key: vite_api_domain
|
||||||
|
- name: VITE_WEBSITE_DOMAIN
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: flxn-config
|
||||||
|
key: vite_website_domain
|
||||||
|
- name: SUPERTOKENS_URI
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: flxn-config
|
||||||
|
key: supertokens_uri
|
||||||
|
- name: POCKETBASE_URL
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: flxn-config
|
||||||
|
key: pocketbase_url
|
||||||
|
- name: SUPERTOKENS_API_KEY
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: flxn-secrets
|
||||||
|
key: supertokens_api_key
|
||||||
|
- name: PORT
|
||||||
|
value: "3000"
|
||||||
|
- name: NODE_ENV
|
||||||
|
value: "production"
|
||||||
|
|
||||||
|
- name: TWILIO_ACCOUNT_SID
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: flxn-secrets
|
||||||
|
key: twilio_account_sid
|
||||||
|
- name: TWILIO_AUTH_TOKEN
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: flxn-secrets
|
||||||
|
key: twilio_auth_token
|
||||||
|
- name: TWILIO_SERVICE_SID
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: flxn-secrets
|
||||||
|
key: twilio_service_sid
|
||||||
|
- name: POCKETBASE_ADMIN_EMAIL
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: flxn-secrets
|
||||||
|
key: pocketbase_admin_email
|
||||||
|
- name: POCKETBASE_ADMIN_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: flxn-secrets
|
||||||
|
key: pocketbase_admin_password
|
||||||
|
- name: VITE_SPOTIFY_CLIENT_ID
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: flxn-config
|
||||||
|
key: vite_spotify_client_id
|
||||||
|
- name: SPOTIFY_CLIENT_SECRET
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: flxn-secrets
|
||||||
|
key: spotify_client_secret
|
||||||
|
- name: VITE_SPOTIFY_REDIRECT_URI
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: flxn-config
|
||||||
|
key: vite_spotify_redirect_uri
|
||||||
|
- name: COOKIE_DOMAIN
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: flxn-config
|
||||||
|
key: cookie_domain
|
||||||
|
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
memory: "768Mi"
|
||||||
|
cpu: "250m"
|
||||||
|
limits:
|
||||||
|
memory: "1536Mi"
|
||||||
|
cpu: "1000m"
|
||||||
|
|
||||||
|
livenessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /api/health
|
||||||
|
port: 3000
|
||||||
|
initialDelaySeconds: 30
|
||||||
|
periodSeconds: 30
|
||||||
|
timeoutSeconds: 5
|
||||||
|
failureThreshold: 3
|
||||||
|
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /api/health
|
||||||
|
port: 3000
|
||||||
|
initialDelaySeconds: 10
|
||||||
|
periodSeconds: 10
|
||||||
|
timeoutSeconds: 3
|
||||||
|
failureThreshold: 3
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: flxn-app
|
||||||
|
labels:
|
||||||
|
app: flxn
|
||||||
|
component: app
|
||||||
|
spec:
|
||||||
|
type: ClusterIP
|
||||||
|
ports:
|
||||||
|
- port: 3000
|
||||||
|
targetPort: 3000
|
||||||
|
protocol: TCP
|
||||||
|
name: http
|
||||||
|
selector:
|
||||||
|
app: flxn
|
||||||
|
component: app
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
|
||||||
|
resources:
|
||||||
|
- app-deployment.yaml
|
||||||
|
- app-service.yaml
|
||||||
|
- pocketbase-deployment.yaml
|
||||||
|
- pocketbase-service.yaml
|
||||||
|
- pb-data-pvc.yaml
|
||||||
|
|
||||||
|
commonLabels:
|
||||||
|
app: flxn
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: flxn-pb-data
|
||||||
|
labels:
|
||||||
|
app: flxn
|
||||||
|
component: pocketbase
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 10Gi
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: flxn-pocketbase
|
||||||
|
labels:
|
||||||
|
app: flxn
|
||||||
|
component: pocketbase
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: flxn
|
||||||
|
component: pocketbase
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: flxn
|
||||||
|
component: pocketbase
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: pocketbase
|
||||||
|
image: git.yohler.net/kyle/flxn-pocketbase:latest
|
||||||
|
imagePullPolicy: Always
|
||||||
|
ports:
|
||||||
|
- containerPort: 8090
|
||||||
|
name: http
|
||||||
|
protocol: TCP
|
||||||
|
volumeMounts:
|
||||||
|
- name: pb-data
|
||||||
|
mountPath: /pb/pb_data
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
memory: "256Mi"
|
||||||
|
cpu: "100m"
|
||||||
|
limits:
|
||||||
|
memory: "512Mi"
|
||||||
|
cpu: "500m"
|
||||||
|
livenessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /api/health
|
||||||
|
port: 8090
|
||||||
|
initialDelaySeconds: 10
|
||||||
|
periodSeconds: 30
|
||||||
|
timeoutSeconds: 5
|
||||||
|
failureThreshold: 3
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /api/health
|
||||||
|
port: 8090
|
||||||
|
initialDelaySeconds: 5
|
||||||
|
periodSeconds: 10
|
||||||
|
timeoutSeconds: 3
|
||||||
|
failureThreshold: 3
|
||||||
|
volumes:
|
||||||
|
- name: pb-data
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: flxn-pb-data
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: flxn-pocketbase
|
||||||
|
labels:
|
||||||
|
app: flxn
|
||||||
|
component: pocketbase
|
||||||
|
spec:
|
||||||
|
type: NodePort
|
||||||
|
ports:
|
||||||
|
- port: 8090
|
||||||
|
targetPort: 8090
|
||||||
|
nodePort: 30090
|
||||||
|
protocol: TCP
|
||||||
|
name: http
|
||||||
|
selector:
|
||||||
|
app: flxn
|
||||||
|
component: pocketbase
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: flxn-config
|
||||||
|
namespace: flxn-dev
|
||||||
|
data:
|
||||||
|
vite_api_domain: "https://dev.flexxon.app"
|
||||||
|
vite_website_domain: "https://dev.flexxon.app"
|
||||||
|
supertokens_uri: "http://192.168.4.43:30568"
|
||||||
|
pocketbase_url: "http://192.168.4.43:30096"
|
||||||
|
vite_spotify_client_id: "3ffde6b594e84460b3d4b329b8919277"
|
||||||
|
vite_spotify_redirect_uri: "https://dev.flexxon.app/api/spotify/callback"
|
||||||
|
s3_endpoint: "https://s3.yohler.net"
|
||||||
|
s3_bucket: "flxn-dev"
|
||||||
|
cookie_domain: "dev.flexxon.app"
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: Ingress
|
||||||
|
metadata:
|
||||||
|
name: flxn-app
|
||||||
|
namespace: flxn-dev
|
||||||
|
spec:
|
||||||
|
rules:
|
||||||
|
- host: dev.flexxon.app
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- path: /
|
||||||
|
pathType: Prefix
|
||||||
|
backend:
|
||||||
|
service:
|
||||||
|
name: flxn-app
|
||||||
|
port:
|
||||||
|
number: 3000
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
|
||||||
|
namespace: flxn-dev
|
||||||
|
|
||||||
|
resources:
|
||||||
|
- namespace.yaml
|
||||||
|
- ../../base
|
||||||
|
- configmap.yaml
|
||||||
|
- ingress.yaml
|
||||||
|
|
||||||
|
images:
|
||||||
|
- name: git.yohler.net/kyle/flxn-app
|
||||||
|
newTag: dev
|
||||||
|
- name: git.yohler.net/kyle/flxn-pocketbase
|
||||||
|
newTag: latest
|
||||||
|
|
||||||
|
commonLabels:
|
||||||
|
environment: dev
|
||||||
|
|
||||||
|
patches:
|
||||||
|
- patch: |-
|
||||||
|
- op: replace
|
||||||
|
path: /spec/template/spec/containers/0/resources/requests/memory
|
||||||
|
value: "768Mi"
|
||||||
|
- op: replace
|
||||||
|
path: /spec/template/spec/containers/0/resources/limits/memory
|
||||||
|
value: "1536Mi"
|
||||||
|
target:
|
||||||
|
kind: Deployment
|
||||||
|
name: flxn-app
|
||||||
|
|
||||||
|
- patch: |-
|
||||||
|
- op: replace
|
||||||
|
path: /spec/type
|
||||||
|
value: NodePort
|
||||||
|
- op: add
|
||||||
|
path: /spec/ports/0/nodePort
|
||||||
|
value: 30083
|
||||||
|
target:
|
||||||
|
kind: Service
|
||||||
|
name: flxn-app
|
||||||
|
|
||||||
|
- patch: |-
|
||||||
|
- op: replace
|
||||||
|
path: /spec/ports/0/nodePort
|
||||||
|
value: 30096
|
||||||
|
target:
|
||||||
|
kind: Service
|
||||||
|
name: flxn-pocketbase
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: flxn-dev
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: flxn-config
|
||||||
|
namespace: flxn-prod
|
||||||
|
data:
|
||||||
|
vite_api_domain: "https://flexxon.app"
|
||||||
|
vite_website_domain: "https://flexxon.app"
|
||||||
|
supertokens_uri: "http://192.168.4.43:30568"
|
||||||
|
pocketbase_url: "http://192.168.4.43:30097"
|
||||||
|
vite_spotify_client_id: "3ffde6b594e84460b3d4b329b8919277"
|
||||||
|
vite_spotify_redirect_uri: "https://flexxon.app/api/spotify/callback"
|
||||||
|
s3_endpoint: "https://s3.yohler.net"
|
||||||
|
s3_bucket: "flxn-prod"
|
||||||
|
cookie_domain: "flexxon.app"
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: Ingress
|
||||||
|
metadata:
|
||||||
|
name: flxn-app
|
||||||
|
namespace: flxn-prod
|
||||||
|
spec:
|
||||||
|
rules:
|
||||||
|
- host: flexxon.app
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- path: /
|
||||||
|
pathType: Prefix
|
||||||
|
backend:
|
||||||
|
service:
|
||||||
|
name: flxn-app
|
||||||
|
port:
|
||||||
|
number: 3000
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
|
||||||
|
namespace: flxn-prod
|
||||||
|
|
||||||
|
resources:
|
||||||
|
- namespace.yaml
|
||||||
|
- ../../base
|
||||||
|
- configmap.yaml
|
||||||
|
- ingress.yaml
|
||||||
|
|
||||||
|
images:
|
||||||
|
- name: git.yohler.net/kyle/flxn-app
|
||||||
|
newTag: latest
|
||||||
|
- name: git.yohler.net/kyle/flxn-pocketbase
|
||||||
|
newTag: latest
|
||||||
|
|
||||||
|
commonLabels:
|
||||||
|
environment: prod
|
||||||
|
|
||||||
|
patches:
|
||||||
|
- patch: |-
|
||||||
|
- op: replace
|
||||||
|
path: /spec/template/spec/containers/0/resources/requests/memory
|
||||||
|
value: "1536Mi"
|
||||||
|
- op: replace
|
||||||
|
path: /spec/template/spec/containers/0/resources/limits/memory
|
||||||
|
value: "3Gi"
|
||||||
|
target:
|
||||||
|
kind: Deployment
|
||||||
|
name: flxn-app
|
||||||
|
|
||||||
|
- patch: |-
|
||||||
|
- op: replace
|
||||||
|
path: /spec/type
|
||||||
|
value: NodePort
|
||||||
|
- op: add
|
||||||
|
path: /spec/ports/0/nodePort
|
||||||
|
value: 30084
|
||||||
|
target:
|
||||||
|
kind: Service
|
||||||
|
name: flxn-app
|
||||||
|
|
||||||
|
- patch: |-
|
||||||
|
- op: replace
|
||||||
|
path: /spec/ports/0/nodePort
|
||||||
|
value: 30097
|
||||||
|
target:
|
||||||
|
kind: Service
|
||||||
|
name: flxn-pocketbase
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: flxn-prod
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: supertokens-config
|
||||||
|
namespace: flxn-shared
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
|
||||||
|
namespace: flxn-shared
|
||||||
|
|
||||||
|
resources:
|
||||||
|
- namespace.yaml
|
||||||
|
- supertokens-deployment.yaml
|
||||||
|
- supertokens-service.yaml
|
||||||
|
- supertokens-postgres-deployment.yaml
|
||||||
|
- supertokens-postgres-service.yaml
|
||||||
|
- supertokens-db-pvc.yaml
|
||||||
|
|
||||||
|
labels:
|
||||||
|
- pairs:
|
||||||
|
environment: shared
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: flxn-shared
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: supertokens-db-data
|
||||||
|
labels:
|
||||||
|
app: flxn
|
||||||
|
component: supertokens-db
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 2Gi
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: supertokens
|
||||||
|
labels:
|
||||||
|
app: flxn
|
||||||
|
component: supertokens
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: flxn
|
||||||
|
component: supertokens
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: flxn
|
||||||
|
component: supertokens
|
||||||
|
spec:
|
||||||
|
enableServiceLinks: false
|
||||||
|
containers:
|
||||||
|
- name: supertokens
|
||||||
|
image: registry.supertokens.io/supertokens/supertokens-postgresql:latest
|
||||||
|
ports:
|
||||||
|
- containerPort: 3567
|
||||||
|
name: http
|
||||||
|
protocol: TCP
|
||||||
|
env:
|
||||||
|
- name: PORT
|
||||||
|
value: "3567"
|
||||||
|
- name: POSTGRESQL_USER
|
||||||
|
value: supertokens
|
||||||
|
- name: POSTGRESQL_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: supertokens-secrets
|
||||||
|
key: postgres_password
|
||||||
|
- name: POSTGRESQL_HOST
|
||||||
|
value: supertokens-db
|
||||||
|
- name: POSTGRESQL_PORT
|
||||||
|
value: "5432"
|
||||||
|
- name: POSTGRESQL_DATABASE_NAME
|
||||||
|
value: supertokens
|
||||||
|
- name: API_KEYS
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: supertokens-secrets
|
||||||
|
key: api_keys
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
memory: "256Mi"
|
||||||
|
cpu: "100m"
|
||||||
|
limits:
|
||||||
|
memory: "512Mi"
|
||||||
|
cpu: "500m"
|
||||||
|
livenessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /hello
|
||||||
|
port: 3567
|
||||||
|
initialDelaySeconds: 30
|
||||||
|
periodSeconds: 30
|
||||||
|
timeoutSeconds: 5
|
||||||
|
failureThreshold: 3
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /hello
|
||||||
|
port: 3567
|
||||||
|
initialDelaySeconds: 10
|
||||||
|
periodSeconds: 10
|
||||||
|
timeoutSeconds: 3
|
||||||
|
failureThreshold: 3
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: supertokens-db
|
||||||
|
labels:
|
||||||
|
app: flxn
|
||||||
|
component: supertokens-db
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: flxn
|
||||||
|
component: supertokens-db
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: flxn
|
||||||
|
component: supertokens-db
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: postgres
|
||||||
|
image: postgres:16-alpine
|
||||||
|
ports:
|
||||||
|
- containerPort: 5432
|
||||||
|
name: postgres
|
||||||
|
protocol: TCP
|
||||||
|
env:
|
||||||
|
- name: POSTGRES_USER
|
||||||
|
value: "supertokens"
|
||||||
|
- name: POSTGRES_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: supertokens-secrets
|
||||||
|
key: postgres_password
|
||||||
|
- name: POSTGRES_DB
|
||||||
|
value: "supertokens"
|
||||||
|
- name: PGDATA
|
||||||
|
value: "/var/lib/postgresql/data/pgdata"
|
||||||
|
volumeMounts:
|
||||||
|
- name: postgres-data
|
||||||
|
mountPath: /var/lib/postgresql/data
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
memory: "128Mi"
|
||||||
|
cpu: "50m"
|
||||||
|
limits:
|
||||||
|
memory: "256Mi"
|
||||||
|
cpu: "500m"
|
||||||
|
livenessProbe:
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- pg_isready
|
||||||
|
- -U
|
||||||
|
- supertokens
|
||||||
|
initialDelaySeconds: 30
|
||||||
|
periodSeconds: 10
|
||||||
|
readinessProbe:
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- pg_isready
|
||||||
|
- -U
|
||||||
|
- supertokens
|
||||||
|
initialDelaySeconds: 5
|
||||||
|
periodSeconds: 5
|
||||||
|
volumes:
|
||||||
|
- name: postgres-data
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: supertokens-db-data
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: supertokens-db
|
||||||
|
labels:
|
||||||
|
app: flxn
|
||||||
|
component: supertokens-db
|
||||||
|
spec:
|
||||||
|
type: ClusterIP
|
||||||
|
ports:
|
||||||
|
- port: 5432
|
||||||
|
targetPort: 5432
|
||||||
|
protocol: TCP
|
||||||
|
name: postgres
|
||||||
|
selector:
|
||||||
|
app: flxn
|
||||||
|
component: supertokens-db
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: supertokens
|
||||||
|
labels:
|
||||||
|
app: flxn
|
||||||
|
component: supertokens
|
||||||
|
spec:
|
||||||
|
type: NodePort
|
||||||
|
ports:
|
||||||
|
- port: 3567
|
||||||
|
targetPort: 3567
|
||||||
|
nodePort: 30568
|
||||||
|
protocol: TCP
|
||||||
|
name: http
|
||||||
|
selector:
|
||||||
|
app: flxn
|
||||||
|
component: supertokens
|
||||||
@@ -5,66 +5,53 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev --host 0.0.0.0",
|
"dev": "vite dev --host 0.0.0.0",
|
||||||
"build": "vite build && tsc --noEmit",
|
"build": "vite build && tsc --noEmit && bun scripts/generate-sw.mjs",
|
||||||
"start": "bun run .output/server/index.mjs",
|
"start": "bun run server.ts"
|
||||||
"start:node": "node .output/server/index.mjs"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hello-pangea/dnd": "^18.0.1",
|
"@hello-pangea/dnd": "^18.0.1",
|
||||||
"@mantine/carousel": "^8.2.4",
|
"@mantine/carousel": "^8.2.4",
|
||||||
"@mantine/charts": "^8.2.4",
|
|
||||||
"@mantine/core": "^8.2.4",
|
"@mantine/core": "^8.2.4",
|
||||||
"@mantine/dates": "^8.2.4",
|
"@mantine/dates": "^8.2.4",
|
||||||
"@mantine/form": "^8.2.4",
|
"@mantine/form": "^8.2.4",
|
||||||
"@mantine/hooks": "^8.2.4",
|
"@mantine/hooks": "^8.2.4",
|
||||||
"@mantine/tiptap": "^8.2.4",
|
"@mantine/tiptap": "^8.2.4",
|
||||||
"@phosphor-icons/react": "^2.1.10",
|
"@phosphor-icons/react": "^2.1.10",
|
||||||
"@svgmoji/noto": "^3.2.0",
|
|
||||||
"@tanstack/react-devtools": "^0.7.6",
|
"@tanstack/react-devtools": "^0.7.6",
|
||||||
"@tanstack/react-query": "^5.66.0",
|
"@tanstack/react-query": "^5.101.2",
|
||||||
"@tanstack/react-query-devtools": "^5.66.0",
|
"@tanstack/react-query-devtools": "^5.101.2",
|
||||||
"@tanstack/react-router": "^1.130.12",
|
"@tanstack/react-router": "^1.170.17",
|
||||||
"@tanstack/react-router-devtools": "^1.130.13",
|
"@tanstack/react-router-devtools": "^1.167.0",
|
||||||
"@tanstack/react-router-with-query": "^1.130.12",
|
"@tanstack/react-router-ssr-query": "^1.167.1",
|
||||||
"@tanstack/react-start": "^1.132.2",
|
"@tanstack/react-start": "^1.168.27",
|
||||||
"@tanstack/react-virtual": "^3.13.12",
|
|
||||||
"@tiptap/pm": "^3.4.3",
|
"@tiptap/pm": "^3.4.3",
|
||||||
"@tiptap/react": "^3.4.3",
|
"@tiptap/react": "^3.4.3",
|
||||||
"@tiptap/starter-kit": "^3.4.3",
|
"@tiptap/starter-kit": "^3.4.3",
|
||||||
"@types/bun": "^1.2.22",
|
"@types/bun": "^1.2.22",
|
||||||
"@types/ioredis": "^4.28.10",
|
|
||||||
"browser-image-compression": "^2.0.2",
|
"browser-image-compression": "^2.0.2",
|
||||||
"dotenv": "^17.2.2",
|
"dotenv": "^17.2.2",
|
||||||
"embla-carousel-react": "^8.6.0",
|
"embla-carousel-react": "^8.6.0",
|
||||||
|
"facehash": "^0.0.7",
|
||||||
"framer-motion": "^12.23.12",
|
"framer-motion": "^12.23.12",
|
||||||
"ioredis": "^5.7.0",
|
|
||||||
"pg": "^8.16.3",
|
|
||||||
"pocketbase": "^0.26.2",
|
"pocketbase": "^0.26.2",
|
||||||
"react": "^19.0.0",
|
"react": "^19.2.7",
|
||||||
"react-dom": "^19.0.0",
|
"react-dom": "^19.2.7",
|
||||||
"react-imask": "^7.6.1",
|
"react-imask": "^7.6.1",
|
||||||
"react-scan": "^0.4.3",
|
|
||||||
"react-use-draggable-scroll": "^0.4.7",
|
|
||||||
"recharts": "^3.1.2",
|
|
||||||
"redaxios": "^0.5.1",
|
"redaxios": "^0.5.1",
|
||||||
"sonner": "^2.0.7",
|
"sonner": "^2.0.7",
|
||||||
"supertokens-node": "^23.0.1",
|
"supertokens-node": "^23.0.1",
|
||||||
"supertokens-web-js": "^0.15.0",
|
"supertokens-web-js": "^0.15.0",
|
||||||
"twilio": "^5.8.0",
|
"twilio": "^5.8.0",
|
||||||
"vaul": "^1.1.2",
|
"vaul": "^1.1.2",
|
||||||
"xlsx": "^0.18.5",
|
"zod": "^4.0.15"
|
||||||
"zod": "^4.0.15",
|
|
||||||
"zustand": "^5.0.7"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tanstack/react-router-ssr-query": "^1.132.2",
|
|
||||||
"@tanstack/router-plugin": "^1.132.2",
|
|
||||||
"@types/node": "^22.5.4",
|
"@types/node": "^22.5.4",
|
||||||
"@types/pg": "^8.15.5",
|
"@types/react": "^19.2.17",
|
||||||
"@types/react": "^19.0.8",
|
"@types/react-dom": "^19.2.3",
|
||||||
"@types/react-dom": "^19.0.3",
|
|
||||||
"@vitejs/plugin-react": "^5.0.0",
|
"@vitejs/plugin-react": "^5.0.0",
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.20",
|
||||||
|
"babel-plugin-react-compiler": "^1.0.0",
|
||||||
"dotenv-cli": "^10.0.0",
|
"dotenv-cli": "^10.0.0",
|
||||||
"postcss": "^8.5.1",
|
"postcss": "^8.5.1",
|
||||||
"postcss-preset-mantine": "^1.18.0",
|
"postcss-preset-mantine": "^1.18.0",
|
||||||
@@ -72,6 +59,7 @@
|
|||||||
"tsx": "^4.20.3",
|
"tsx": "^4.20.3",
|
||||||
"typescript": "^5.7.2",
|
"typescript": "^5.7.2",
|
||||||
"vite": "^7.1.7",
|
"vite": "^7.1.7",
|
||||||
"vite-tsconfig-paths": "^5.1.4"
|
"vite-tsconfig-paths": "^5.1.4",
|
||||||
|
"workbox-build": "^7.4.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
/// <reference path="../pb_data/types.d.ts" />
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
migrate((app) => {
|
migrate((app) => {
|
||||||
|
try {
|
||||||
const collection = app.findCollectionByNameOrId("pbc_4251874343");
|
const collection = app.findCollectionByNameOrId("pbc_4251874343");
|
||||||
|
|
||||||
return app.delete(collection);
|
return app.delete(collection);
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Collection pbc_4251874343 not found, skipping deletion");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}, (app) => {
|
}, (app) => {
|
||||||
const collection = new Collection({
|
const collection = new Collection({
|
||||||
"createRule": null,
|
"createRule": null,
|
||||||
|
|||||||
@@ -0,0 +1,109 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((app) => {
|
||||||
|
const collection = new Collection({
|
||||||
|
"createRule": null,
|
||||||
|
"deleteRule": null,
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"autogeneratePattern": "[a-z0-9]{15}",
|
||||||
|
"hidden": false,
|
||||||
|
"id": "text3208210256",
|
||||||
|
"max": 15,
|
||||||
|
"min": 15,
|
||||||
|
"name": "id",
|
||||||
|
"pattern": "^[a-z0-9]+$",
|
||||||
|
"presentable": false,
|
||||||
|
"primaryKey": true,
|
||||||
|
"required": true,
|
||||||
|
"system": true,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cascadeDelete": false,
|
||||||
|
"collectionId": "pbc_340646327",
|
||||||
|
"hidden": false,
|
||||||
|
"id": "relation3177167065",
|
||||||
|
"maxSelect": 1,
|
||||||
|
"minSelect": 0,
|
||||||
|
"name": "tournament",
|
||||||
|
"presentable": false,
|
||||||
|
"required": false,
|
||||||
|
"system": false,
|
||||||
|
"type": "relation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"autogeneratePattern": "",
|
||||||
|
"hidden": false,
|
||||||
|
"id": "text1579384326",
|
||||||
|
"max": 0,
|
||||||
|
"min": 0,
|
||||||
|
"name": "name",
|
||||||
|
"pattern": "",
|
||||||
|
"presentable": false,
|
||||||
|
"primaryKey": false,
|
||||||
|
"required": false,
|
||||||
|
"system": false,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hidden": false,
|
||||||
|
"id": "number4113142680",
|
||||||
|
"max": null,
|
||||||
|
"min": null,
|
||||||
|
"name": "order",
|
||||||
|
"onlyInt": false,
|
||||||
|
"presentable": false,
|
||||||
|
"required": false,
|
||||||
|
"system": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cascadeDelete": false,
|
||||||
|
"collectionId": "pbc_1568971955",
|
||||||
|
"hidden": false,
|
||||||
|
"id": "relation2529305176",
|
||||||
|
"maxSelect": 999,
|
||||||
|
"minSelect": 0,
|
||||||
|
"name": "teams",
|
||||||
|
"presentable": false,
|
||||||
|
"required": false,
|
||||||
|
"system": false,
|
||||||
|
"type": "relation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hidden": false,
|
||||||
|
"id": "autodate2990389176",
|
||||||
|
"name": "created",
|
||||||
|
"onCreate": true,
|
||||||
|
"onUpdate": false,
|
||||||
|
"presentable": false,
|
||||||
|
"system": false,
|
||||||
|
"type": "autodate"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hidden": false,
|
||||||
|
"id": "autodate3332085495",
|
||||||
|
"name": "updated",
|
||||||
|
"onCreate": true,
|
||||||
|
"onUpdate": true,
|
||||||
|
"presentable": false,
|
||||||
|
"system": false,
|
||||||
|
"type": "autodate"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"id": "pbc_3346940990",
|
||||||
|
"indexes": [],
|
||||||
|
"listRule": null,
|
||||||
|
"name": "groups",
|
||||||
|
"system": false,
|
||||||
|
"type": "base",
|
||||||
|
"updateRule": null,
|
||||||
|
"viewRule": null
|
||||||
|
});
|
||||||
|
|
||||||
|
return app.save(collection);
|
||||||
|
}, (app) => {
|
||||||
|
const collection = app.findCollectionByNameOrId("pbc_3346940990");
|
||||||
|
|
||||||
|
return app.delete(collection);
|
||||||
|
})
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((app) => {
|
||||||
|
const collection = app.findCollectionByNameOrId("pbc_340646327")
|
||||||
|
|
||||||
|
// remove field
|
||||||
|
collection.fields.removeById("select3736761055")
|
||||||
|
|
||||||
|
// add field
|
||||||
|
collection.fields.addAt(13, new Field({
|
||||||
|
"autogeneratePattern": "",
|
||||||
|
"hidden": false,
|
||||||
|
"id": "text3736761055",
|
||||||
|
"max": 0,
|
||||||
|
"min": 0,
|
||||||
|
"name": "format",
|
||||||
|
"pattern": "",
|
||||||
|
"presentable": false,
|
||||||
|
"primaryKey": false,
|
||||||
|
"required": false,
|
||||||
|
"system": false,
|
||||||
|
"type": "text"
|
||||||
|
}))
|
||||||
|
|
||||||
|
return app.save(collection)
|
||||||
|
}, (app) => {
|
||||||
|
const collection = app.findCollectionByNameOrId("pbc_340646327")
|
||||||
|
|
||||||
|
// add field
|
||||||
|
collection.fields.addAt(13, new Field({
|
||||||
|
"hidden": false,
|
||||||
|
"id": "select3736761055",
|
||||||
|
"maxSelect": 1,
|
||||||
|
"name": "format",
|
||||||
|
"presentable": false,
|
||||||
|
"required": false,
|
||||||
|
"system": false,
|
||||||
|
"type": "select",
|
||||||
|
"values": [
|
||||||
|
"single_elim",
|
||||||
|
"double_elim",
|
||||||
|
"groups",
|
||||||
|
"swiss",
|
||||||
|
"swiss_bracket",
|
||||||
|
"round_robin"
|
||||||
|
]
|
||||||
|
}))
|
||||||
|
|
||||||
|
// remove field
|
||||||
|
collection.fields.removeById("text3736761055")
|
||||||
|
|
||||||
|
return app.save(collection)
|
||||||
|
})
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((app) => {
|
||||||
|
const collection = app.findCollectionByNameOrId("pbc_340646327")
|
||||||
|
|
||||||
|
// add field
|
||||||
|
collection.fields.addAt(14, new Field({
|
||||||
|
"hidden": false,
|
||||||
|
"id": "json118290348",
|
||||||
|
"maxSize": 0,
|
||||||
|
"name": "group_config",
|
||||||
|
"presentable": false,
|
||||||
|
"required": false,
|
||||||
|
"system": false,
|
||||||
|
"type": "json"
|
||||||
|
}))
|
||||||
|
|
||||||
|
return app.save(collection)
|
||||||
|
}, (app) => {
|
||||||
|
const collection = app.findCollectionByNameOrId("pbc_340646327")
|
||||||
|
|
||||||
|
// remove field
|
||||||
|
collection.fields.removeById("json118290348")
|
||||||
|
|
||||||
|
return app.save(collection)
|
||||||
|
})
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((app) => {
|
||||||
|
const collection = app.findCollectionByNameOrId("pbc_340646327")
|
||||||
|
|
||||||
|
// add field
|
||||||
|
collection.fields.addAt(15, new Field({
|
||||||
|
"autogeneratePattern": "",
|
||||||
|
"hidden": false,
|
||||||
|
"id": "text2982008523",
|
||||||
|
"max": 0,
|
||||||
|
"min": 0,
|
||||||
|
"name": "phase",
|
||||||
|
"pattern": "",
|
||||||
|
"presentable": false,
|
||||||
|
"primaryKey": false,
|
||||||
|
"required": false,
|
||||||
|
"system": false,
|
||||||
|
"type": "text"
|
||||||
|
}))
|
||||||
|
|
||||||
|
return app.save(collection)
|
||||||
|
}, (app) => {
|
||||||
|
const collection = app.findCollectionByNameOrId("pbc_340646327")
|
||||||
|
|
||||||
|
// remove field
|
||||||
|
collection.fields.removeById("text2982008523")
|
||||||
|
|
||||||
|
return app.save(collection)
|
||||||
|
})
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((app) => {
|
||||||
|
const collection = app.findCollectionByNameOrId("pbc_2541054544")
|
||||||
|
|
||||||
|
// add field
|
||||||
|
collection.fields.addAt(22, new Field({
|
||||||
|
"cascadeDelete": false,
|
||||||
|
"collectionId": "pbc_3346940990",
|
||||||
|
"hidden": false,
|
||||||
|
"id": "relation1841317061",
|
||||||
|
"maxSelect": 1,
|
||||||
|
"minSelect": 0,
|
||||||
|
"name": "group",
|
||||||
|
"presentable": false,
|
||||||
|
"required": false,
|
||||||
|
"system": false,
|
||||||
|
"type": "relation"
|
||||||
|
}))
|
||||||
|
|
||||||
|
// add field
|
||||||
|
collection.fields.addAt(23, new Field({
|
||||||
|
"autogeneratePattern": "",
|
||||||
|
"hidden": false,
|
||||||
|
"id": "text3987859035",
|
||||||
|
"max": 0,
|
||||||
|
"min": 0,
|
||||||
|
"name": "match_type",
|
||||||
|
"pattern": "",
|
||||||
|
"presentable": false,
|
||||||
|
"primaryKey": false,
|
||||||
|
"required": false,
|
||||||
|
"system": false,
|
||||||
|
"type": "text"
|
||||||
|
}))
|
||||||
|
|
||||||
|
return app.save(collection)
|
||||||
|
}, (app) => {
|
||||||
|
const collection = app.findCollectionByNameOrId("pbc_2541054544")
|
||||||
|
|
||||||
|
// remove field
|
||||||
|
collection.fields.removeById("relation1841317061")
|
||||||
|
|
||||||
|
// remove field
|
||||||
|
collection.fields.removeById("text3987859035")
|
||||||
|
|
||||||
|
return app.save(collection)
|
||||||
|
})
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
// Rewrites the player stats views from a cartesian LIKE-join over
|
||||||
|
// players x teams x matches (which forced a full re-scan per row and took
|
||||||
|
// ~1.5-2s per request) to equi-joins driven by matches, with team rosters
|
||||||
|
// expanded once via json_each. Results are byte-identical; each view now
|
||||||
|
// runs in well under 100ms. The unary "+" in the regional filter prevents
|
||||||
|
// the query planner from picking a pathological join order.
|
||||||
|
migrate((app) => {
|
||||||
|
{
|
||||||
|
const collection = app.findCollectionByNameOrId("player_stats");
|
||||||
|
unmarshal({
|
||||||
|
"viewQuery": "SELECT\n p.id as id,\n p.id as player_id,\n (p.first_name || ' ' || p.last_name) as player_name,\n COUNT(mt.match_id) as matches,\n COUNT(DISTINCT mt.tournament) as tournaments,\n SUM(CASE WHEN mt.cups_for > mt.cups_against THEN 1 ELSE 0 END) as wins,\n SUM(CASE WHEN mt.cups_for < mt.cups_against THEN 1 ELSE 0 END) as losses,\n SUM(mt.cups_for) as total_cups_made,\n SUM(mt.cups_against) as total_cups_against,\n ROUND((CAST(SUM(CASE WHEN mt.cups_for > mt.cups_against THEN 1 ELSE 0 END) AS REAL) / COUNT(mt.match_id)) * 100, 2) as win_percentage,\n ROUND(CAST(SUM(mt.cups_for) AS REAL) / COUNT(mt.match_id), 2) as avg_cups_per_match,\n ROUND(AVG(CASE WHEN mt.cups_for > mt.cups_against THEN mt.cups_for - mt.cups_against ELSE NULL END), 2) as margin_of_victory,\n ROUND(AVG(CASE WHEN mt.cups_for < mt.cups_against THEN mt.cups_against - mt.cups_for ELSE NULL END), 2) as margin_of_loss\n FROM (\n SELECT m.id as match_id, m.tournament as tournament, m.home as team_id, m.home_cups as cups_for, m.away_cups as cups_against\n FROM matches m\n JOIN tournaments tour ON m.tournament = tour.id\n WHERE m.status = 'ended'\n UNION ALL\n SELECT m.id, m.tournament, m.away, m.away_cups, m.home_cups\n FROM matches m\n JOIN tournaments tour ON m.tournament = tour.id\n WHERE m.status = 'ended'\n ) mt\n JOIN (\n SELECT teams.id AS team_id, je.value AS player_id\n FROM teams, json_each(ifnull(nullif(teams.players, ''), '[]')) je\n GROUP BY teams.id, je.value\n ) tp ON tp.team_id = mt.team_id\n JOIN players p ON p.id = tp.player_id\n GROUP BY p.id"
|
||||||
|
}, collection);
|
||||||
|
app.save(collection);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const collection = app.findCollectionByNameOrId("player_mainline_stats");
|
||||||
|
unmarshal({
|
||||||
|
"viewQuery": "SELECT\n p.id as id,\n p.id as player_id,\n (p.first_name || ' ' || p.last_name) as player_name,\n COUNT(mt.match_id) as matches,\n COUNT(DISTINCT mt.tournament) as tournaments,\n SUM(CASE WHEN mt.cups_for > mt.cups_against THEN 1 ELSE 0 END) as wins,\n SUM(CASE WHEN mt.cups_for < mt.cups_against THEN 1 ELSE 0 END) as losses,\n SUM(mt.cups_for) as total_cups_made,\n SUM(mt.cups_against) as total_cups_against,\n ROUND((CAST(SUM(CASE WHEN mt.cups_for > mt.cups_against THEN 1 ELSE 0 END) AS REAL) / COUNT(mt.match_id)) * 100, 2) as win_percentage,\n ROUND(CAST(SUM(mt.cups_for) AS REAL) / COUNT(mt.match_id), 2) as avg_cups_per_match,\n ROUND(AVG(CASE WHEN mt.cups_for > mt.cups_against THEN mt.cups_for - mt.cups_against ELSE NULL END), 2) as margin_of_victory,\n ROUND(AVG(CASE WHEN mt.cups_for < mt.cups_against THEN mt.cups_against - mt.cups_for ELSE NULL END), 2) as margin_of_loss\n FROM (\n SELECT m.id as match_id, m.tournament as tournament, m.home as team_id, m.home_cups as cups_for, m.away_cups as cups_against\n FROM matches m\n JOIN tournaments tour ON m.tournament = tour.id\n WHERE m.status = 'ended' AND (tour.regional = false OR tour.regional IS NULL)\n UNION ALL\n SELECT m.id, m.tournament, m.away, m.away_cups, m.home_cups\n FROM matches m\n JOIN tournaments tour ON m.tournament = tour.id\n WHERE m.status = 'ended' AND (tour.regional = false OR tour.regional IS NULL)\n ) mt\n JOIN (\n SELECT teams.id AS team_id, je.value AS player_id\n FROM teams, json_each(ifnull(nullif(teams.players, ''), '[]')) je\n GROUP BY teams.id, je.value\n ) tp ON tp.team_id = mt.team_id\n JOIN players p ON p.id = tp.player_id\n GROUP BY p.id"
|
||||||
|
}, collection);
|
||||||
|
app.save(collection);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const collection = app.findCollectionByNameOrId("player_regional_stats");
|
||||||
|
unmarshal({
|
||||||
|
"viewQuery": "SELECT\n p.id as id,\n p.id as player_id,\n (p.first_name || ' ' || p.last_name) as player_name,\n COUNT(mt.match_id) as matches,\n COUNT(DISTINCT mt.tournament) as tournaments,\n SUM(CASE WHEN mt.cups_for > mt.cups_against THEN 1 ELSE 0 END) as wins,\n SUM(CASE WHEN mt.cups_for < mt.cups_against THEN 1 ELSE 0 END) as losses,\n SUM(mt.cups_for) as total_cups_made,\n SUM(mt.cups_against) as total_cups_against,\n ROUND((CAST(SUM(CASE WHEN mt.cups_for > mt.cups_against THEN 1 ELSE 0 END) AS REAL) / COUNT(mt.match_id)) * 100, 2) as win_percentage,\n ROUND(CAST(SUM(mt.cups_for) AS REAL) / COUNT(mt.match_id), 2) as avg_cups_per_match,\n ROUND(AVG(CASE WHEN mt.cups_for > mt.cups_against THEN mt.cups_for - mt.cups_against ELSE NULL END), 2) as margin_of_victory,\n ROUND(AVG(CASE WHEN mt.cups_for < mt.cups_against THEN mt.cups_against - mt.cups_for ELSE NULL END), 2) as margin_of_loss\n FROM (\n SELECT m.id as match_id, m.tournament as tournament, m.home as team_id, m.home_cups as cups_for, m.away_cups as cups_against\n FROM matches m\n JOIN tournaments tour ON m.tournament = tour.id\n WHERE m.status = 'ended' AND +tour.regional = true\n UNION ALL\n SELECT m.id, m.tournament, m.away, m.away_cups, m.home_cups\n FROM matches m\n JOIN tournaments tour ON m.tournament = tour.id\n WHERE m.status = 'ended' AND +tour.regional = true\n ) mt\n JOIN (\n SELECT teams.id AS team_id, je.value AS player_id\n FROM teams, json_each(ifnull(nullif(teams.players, ''), '[]')) je\n GROUP BY teams.id, je.value\n ) tp ON tp.team_id = mt.team_id\n JOIN players p ON p.id = tp.player_id\n GROUP BY p.id"
|
||||||
|
}, collection);
|
||||||
|
app.save(collection);
|
||||||
|
}
|
||||||
|
}, (app) => {
|
||||||
|
{
|
||||||
|
const collection = app.findCollectionByNameOrId("player_stats");
|
||||||
|
unmarshal({
|
||||||
|
"viewQuery": "SELECT\n p.id as id,\n p.id as player_id,\n (p.first_name || ' ' || p.last_name) as player_name,\n COUNT(m.id) as matches,\n COUNT(DISTINCT m.tournament) as tournaments,\n SUM(CASE\n WHEN (m.home = t.id AND m.home_cups > m.away_cups) OR\n (m.away = t.id AND m.away_cups > m.home_cups)\n THEN 1 ELSE 0\n END) as wins,\n SUM(CASE\n WHEN (m.home = t.id AND m.home_cups < m.away_cups) OR\n (m.away = t.id AND m.away_cups < m.home_cups)\n THEN 1 ELSE 0\n END) as losses,\n SUM(CASE\n WHEN m.home = t.id THEN m.home_cups\n WHEN m.away = t.id THEN m.away_cups\n ELSE 0\n END) as total_cups_made,\n SUM(CASE\n WHEN m.home = t.id THEN m.away_cups\n WHEN m.away = t.id THEN m.home_cups\n ELSE 0\n END) as total_cups_against,\n -- Win percentage\n ROUND((CAST(SUM(CASE\n WHEN (m.home = t.id AND m.home_cups > m.away_cups) OR\n (m.away = t.id AND m.away_cups > m.home_cups)\n THEN 1 ELSE 0\n END) AS REAL) / COUNT(m.id)) * 100, 2) as win_percentage,\n -- Average cups per match\n ROUND(CAST(SUM(CASE\n WHEN m.home = t.id THEN m.home_cups\n WHEN m.away = t.id THEN m.away_cups\n ELSE 0\n END) AS REAL) / COUNT(m.id), 2) as avg_cups_per_match,\n -- Margin of Victory\n ROUND(AVG(CASE\n WHEN m.home = t.id AND m.home_cups > m.away_cups\n THEN m.home_cups - m.away_cups\n WHEN m.away = t.id AND m.away_cups > m.home_cups\n THEN m.away_cups - m.home_cups\n ELSE NULL\n END), 2) as margin_of_victory,\n -- Margin of Loss\n ROUND(AVG(CASE\n WHEN m.home = t.id AND m.home_cups < m.away_cups\n THEN m.away_cups - m.home_cups\n WHEN m.away = t.id AND m.away_cups < m.home_cups\n THEN m.home_cups - m.away_cups\n ELSE NULL\n END), 2) as margin_of_loss\n FROM players p, teams t, matches m, tournaments tour\n WHERE\n t.players LIKE '%\"' || p.id || '\"%' AND\n (m.home = t.id OR m.away = t.id) AND\n m.tournament = tour.id AND\n m.status = 'ended'\n GROUP BY p.id"
|
||||||
|
}, collection);
|
||||||
|
app.save(collection);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const collection = app.findCollectionByNameOrId("player_mainline_stats");
|
||||||
|
unmarshal({
|
||||||
|
"viewQuery": "SELECT\n p.id as id,\n p.id as player_id,\n (p.first_name || ' ' || p.last_name) as player_name,\n COUNT(m.id) as matches,\n COUNT(DISTINCT m.tournament) as tournaments,\n SUM(CASE\n WHEN (m.home = t.id AND m.home_cups > m.away_cups) OR\n (m.away = t.id AND m.away_cups > m.home_cups)\n THEN 1 ELSE 0\n END) as wins,\n SUM(CASE\n WHEN (m.home = t.id AND m.home_cups < m.away_cups) OR\n (m.away = t.id AND m.away_cups < m.home_cups)\n THEN 1 ELSE 0\n END) as losses,\n SUM(CASE\n WHEN m.home = t.id THEN m.home_cups\n WHEN m.away = t.id THEN m.away_cups\n ELSE 0\n END) as total_cups_made,\n SUM(CASE\n WHEN m.home = t.id THEN m.away_cups\n WHEN m.away = t.id THEN m.home_cups\n ELSE 0\n END) as total_cups_against,\n -- Win percentage\n ROUND((CAST(SUM(CASE\n WHEN (m.home = t.id AND m.home_cups > m.away_cups) OR\n (m.away = t.id AND m.away_cups > m.home_cups)\n THEN 1 ELSE 0\n END) AS REAL) / COUNT(m.id)) * 100, 2) as win_percentage,\n -- Average cups per match\n ROUND(CAST(SUM(CASE\n WHEN m.home = t.id THEN m.home_cups\n WHEN m.away = t.id THEN m.away_cups\n ELSE 0\n END) AS REAL) / COUNT(m.id), 2) as avg_cups_per_match,\n -- Margin of Victory\n ROUND(AVG(CASE\n WHEN m.home = t.id AND m.home_cups > m.away_cups\n THEN m.home_cups - m.away_cups\n WHEN m.away = t.id AND m.away_cups > m.home_cups\n THEN m.away_cups - m.home_cups\n ELSE NULL\n END), 2) as margin_of_victory,\n -- Margin of Loss\n ROUND(AVG(CASE\n WHEN m.home = t.id AND m.home_cups < m.away_cups\n THEN m.away_cups - m.home_cups\n WHEN m.away = t.id AND m.away_cups < m.home_cups\n THEN m.home_cups - m.away_cups\n ELSE NULL\n END), 2) as margin_of_loss\n FROM players p, teams t, matches m, tournaments tour\n WHERE\n t.players LIKE '%\"' || p.id || '\"%' AND\n (m.home = t.id OR m.away = t.id) AND\n m.tournament = tour.id AND\n m.status = 'ended' AND\n (tour.regional = false OR tour.regional IS NULL)\n GROUP BY p.id"
|
||||||
|
}, collection);
|
||||||
|
app.save(collection);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const collection = app.findCollectionByNameOrId("player_regional_stats");
|
||||||
|
unmarshal({
|
||||||
|
"viewQuery": "SELECT\n p.id as id,\n p.id as player_id,\n (p.first_name || ' ' || p.last_name) as player_name,\n COUNT(m.id) as matches,\n COUNT(DISTINCT m.tournament) as tournaments,\n SUM(CASE\n WHEN (m.home = t.id AND m.home_cups > m.away_cups) OR\n (m.away = t.id AND m.away_cups > m.home_cups)\n THEN 1 ELSE 0\n END) as wins,\n SUM(CASE\n WHEN (m.home = t.id AND m.home_cups < m.away_cups) OR\n (m.away = t.id AND m.away_cups < m.home_cups)\n THEN 1 ELSE 0\n END) as losses,\n SUM(CASE\n WHEN m.home = t.id THEN m.home_cups\n WHEN m.away = t.id THEN m.away_cups\n ELSE 0\n END) as total_cups_made,\n SUM(CASE\n WHEN m.home = t.id THEN m.away_cups\n WHEN m.away = t.id THEN m.home_cups\n ELSE 0\n END) as total_cups_against,\n -- Win percentage\n ROUND((CAST(SUM(CASE\n WHEN (m.home = t.id AND m.home_cups > m.away_cups) OR\n (m.away = t.id AND m.away_cups > m.home_cups)\n THEN 1 ELSE 0\n END) AS REAL) / COUNT(m.id)) * 100, 2) as win_percentage,\n -- Average cups per match\n ROUND(CAST(SUM(CASE\n WHEN m.home = t.id THEN m.home_cups\n WHEN m.away = t.id THEN m.away_cups\n ELSE 0\n END) AS REAL) / COUNT(m.id), 2) as avg_cups_per_match,\n -- Margin of Victory\n ROUND(AVG(CASE\n WHEN m.home = t.id AND m.home_cups > m.away_cups\n THEN m.home_cups - m.away_cups\n WHEN m.away = t.id AND m.away_cups > m.home_cups\n THEN m.away_cups - m.home_cups\n ELSE NULL\n END), 2) as margin_of_victory,\n -- Margin of Loss\n ROUND(AVG(CASE\n WHEN m.home = t.id AND m.home_cups < m.away_cups\n THEN m.away_cups - m.home_cups\n WHEN m.away = t.id AND m.away_cups < m.home_cups\n THEN m.home_cups - m.away_cups\n ELSE NULL\n END), 2) as margin_of_loss\n FROM players p, teams t, matches m, tournaments tour\n WHERE\n t.players LIKE '%\"' || p.id || '\"%' AND\n (m.home = t.id OR m.away = t.id) AND\n m.tournament = tour.id AND\n m.status = 'ended' AND\n tour.regional = true\n GROUP BY p.id"
|
||||||
|
}, collection);
|
||||||
|
app.save(collection);
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((app) => {
|
||||||
|
const collection = new Collection({
|
||||||
|
"createRule": null,
|
||||||
|
"deleteRule": null,
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"autogeneratePattern": "[a-z0-9]{15}",
|
||||||
|
"hidden": false,
|
||||||
|
"id": "text3208210256",
|
||||||
|
"max": 15,
|
||||||
|
"min": 15,
|
||||||
|
"name": "id",
|
||||||
|
"pattern": "^[a-z0-9]+$",
|
||||||
|
"presentable": false,
|
||||||
|
"primaryKey": true,
|
||||||
|
"required": true,
|
||||||
|
"system": true,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cascadeDelete": true,
|
||||||
|
"collectionId": "pbc_340646327",
|
||||||
|
"hidden": false,
|
||||||
|
"id": "relation3177167065",
|
||||||
|
"maxSelect": 1,
|
||||||
|
"minSelect": 0,
|
||||||
|
"name": "tournament",
|
||||||
|
"presentable": false,
|
||||||
|
"required": true,
|
||||||
|
"system": false,
|
||||||
|
"type": "relation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cascadeDelete": true,
|
||||||
|
"collectionId": "pbc_3072146508",
|
||||||
|
"hidden": false,
|
||||||
|
"id": "relation2551806565",
|
||||||
|
"maxSelect": 1,
|
||||||
|
"minSelect": 0,
|
||||||
|
"name": "player",
|
||||||
|
"presentable": false,
|
||||||
|
"required": true,
|
||||||
|
"system": false,
|
||||||
|
"type": "relation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hidden": false,
|
||||||
|
"id": "json2153001328",
|
||||||
|
"maxSize": 0,
|
||||||
|
"name": "picks",
|
||||||
|
"presentable": false,
|
||||||
|
"required": false,
|
||||||
|
"system": false,
|
||||||
|
"type": "json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hidden": false,
|
||||||
|
"id": "autodate2990389176",
|
||||||
|
"name": "created",
|
||||||
|
"onCreate": true,
|
||||||
|
"onUpdate": false,
|
||||||
|
"presentable": false,
|
||||||
|
"system": false,
|
||||||
|
"type": "autodate"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hidden": false,
|
||||||
|
"id": "autodate3332085495",
|
||||||
|
"name": "updated",
|
||||||
|
"onCreate": true,
|
||||||
|
"onUpdate": true,
|
||||||
|
"presentable": false,
|
||||||
|
"system": false,
|
||||||
|
"type": "autodate"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"id": "pbc_1784007613",
|
||||||
|
"indexes": [
|
||||||
|
"CREATE UNIQUE INDEX `idx_predictions_tournament_player` ON `predictions` (`tournament`, `player`)"
|
||||||
|
],
|
||||||
|
"listRule": null,
|
||||||
|
"name": "predictions",
|
||||||
|
"system": false,
|
||||||
|
"type": "base",
|
||||||
|
"updateRule": null,
|
||||||
|
"viewRule": null
|
||||||
|
});
|
||||||
|
|
||||||
|
return app.save(collection);
|
||||||
|
}, (app) => {
|
||||||
|
const collection = app.findCollectionByNameOrId("pbc_1784007613");
|
||||||
|
|
||||||
|
return app.delete(collection);
|
||||||
|
})
|
||||||
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 64 KiB |
@@ -1,17 +1,28 @@
|
|||||||
{
|
{
|
||||||
"name": "FLXN IX",
|
|
||||||
"short_name": "FLXN",
|
"short_name": "FLXN",
|
||||||
|
"name": "FLXN",
|
||||||
|
"description": "Amicus meus madidus",
|
||||||
"icons": [
|
"icons": [
|
||||||
{
|
{
|
||||||
"src": "/favicon.png",
|
"src": "/icon-192x192.png",
|
||||||
|
"type": "image/png",
|
||||||
"sizes": "192x192",
|
"sizes": "192x192",
|
||||||
"type": "image/png"
|
"purpose": "any maskable"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "/favicon.png",
|
"src": "/icon-512x512.png",
|
||||||
|
"type": "image/png",
|
||||||
"sizes": "512x512",
|
"sizes": "512x512",
|
||||||
"type": "image/png"
|
"purpose": "any maskable"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"display": "standalone"
|
"start_url": "/",
|
||||||
|
"display": "standalone",
|
||||||
|
"theme_color": "#242424",
|
||||||
|
"background_color": "#242424",
|
||||||
|
"orientation": "portrait-primary",
|
||||||
|
"scope": "/",
|
||||||
|
"categories": ["games", "social", "beer pong"],
|
||||||
|
"prefer_related_applications": false,
|
||||||
|
"shortcuts": []
|
||||||
}
|
}
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 436 KiB After Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 273 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 138 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 189 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 112 KiB After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 45 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 147 KiB After Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 284 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 142 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 226 KiB After Width: | Height: | Size: 31 KiB |
@@ -29,3 +29,27 @@
|
|||||||
[data-drawer-level="3"].drawer-scaling {
|
[data-drawer-level="3"].drawer-scaling {
|
||||||
transform: scale(0.90) translateY(-4px);
|
transform: scale(0.90) translateY(-4px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.app,
|
||||||
|
[data-drawer-level] {
|
||||||
|
transition: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app.drawer-scaling,
|
||||||
|
[data-drawer-level].drawer-scaling {
|
||||||
|
transform: none;
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-vaul-drawer],
|
||||||
|
[data-vaul-overlay] {
|
||||||
|
animation: none !important;
|
||||||
|
transition: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
from { transform: rotate(0deg); }
|
||||||
|
to { transform: rotate(0deg); }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
import { generateSW } from 'workbox-build'
|
||||||
|
|
||||||
|
const ONE_YEAR = 60 * 60 * 24 * 365
|
||||||
|
const THIRTY_DAYS = 60 * 60 * 24 * 30
|
||||||
|
|
||||||
|
const { count, size, warnings } = await generateSW({
|
||||||
|
swDest: 'dist/client/sw.js',
|
||||||
|
globDirectory: 'dist/client',
|
||||||
|
globPatterns: [
|
||||||
|
'assets/**/*.{js,css}',
|
||||||
|
'favicon*.{ico,png}',
|
||||||
|
'apple-touch-icon.png',
|
||||||
|
'icon-192x192.png',
|
||||||
|
'icon-512x512.png',
|
||||||
|
'site.webmanifest',
|
||||||
|
'styles.css',
|
||||||
|
],
|
||||||
|
navigateFallback: null,
|
||||||
|
skipWaiting: true,
|
||||||
|
clientsClaim: true,
|
||||||
|
cleanupOutdatedCaches: true,
|
||||||
|
sourcemap: false,
|
||||||
|
runtimeCaching: [
|
||||||
|
{
|
||||||
|
urlPattern: ({ url, request }) =>
|
||||||
|
url.origin === self.location.origin && request.destination === 'image',
|
||||||
|
handler: 'CacheFirst',
|
||||||
|
options: {
|
||||||
|
cacheName: 'images-cache',
|
||||||
|
expiration: {
|
||||||
|
maxEntries: 60,
|
||||||
|
maxAgeSeconds: THIRTY_DAYS,
|
||||||
|
},
|
||||||
|
cacheableResponse: {
|
||||||
|
statuses: [0, 200],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
urlPattern: /^https:\/\/fonts\.googleapis\.com\/.*/i,
|
||||||
|
handler: 'StaleWhileRevalidate',
|
||||||
|
options: {
|
||||||
|
cacheName: 'google-fonts-cache',
|
||||||
|
expiration: {
|
||||||
|
maxEntries: 10,
|
||||||
|
maxAgeSeconds: ONE_YEAR,
|
||||||
|
},
|
||||||
|
cacheableResponse: {
|
||||||
|
statuses: [0, 200],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
urlPattern: /^https:\/\/fonts\.gstatic\.com\/.*/i,
|
||||||
|
handler: 'CacheFirst',
|
||||||
|
options: {
|
||||||
|
cacheName: 'gstatic-fonts-cache',
|
||||||
|
expiration: {
|
||||||
|
maxEntries: 10,
|
||||||
|
maxAgeSeconds: ONE_YEAR,
|
||||||
|
},
|
||||||
|
cacheableResponse: {
|
||||||
|
statuses: [0, 200],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
|
for (const warning of warnings) console.warn(warning)
|
||||||
|
console.log(
|
||||||
|
`sw.js generated: precached ${count} files, ${(size / 1024).toFixed(1)} KiB`,
|
||||||
|
)
|
||||||
@@ -16,73 +16,133 @@
|
|||||||
* - Server port number
|
* - Server port number
|
||||||
* - Default: 3000
|
* - Default: 3000
|
||||||
*
|
*
|
||||||
* STATIC_PRELOAD_MAX_BYTES (number)
|
* ASSET_PRELOAD_MAX_SIZE (number)
|
||||||
* - Maximum file size in bytes to preload into memory
|
* - Maximum file size in bytes to preload into memory
|
||||||
* - Files larger than this will be served on-demand from disk
|
* - Files larger than this will be served on-demand from disk
|
||||||
* - Default: 5242880 (5MB)
|
* - Default: 5242880 (5MB)
|
||||||
* - Example: STATIC_PRELOAD_MAX_BYTES=5242880 (5MB)
|
* - Example: ASSET_PRELOAD_MAX_SIZE=5242880 (5MB)
|
||||||
*
|
*
|
||||||
* STATIC_PRELOAD_INCLUDE (string)
|
* ASSET_PRELOAD_INCLUDE_PATTERNS (string)
|
||||||
* - Comma-separated list of glob patterns for files to include
|
* - Comma-separated list of glob patterns for files to include
|
||||||
* - If specified, only matching files are eligible for preloading
|
* - If specified, only matching files are eligible for preloading
|
||||||
* - Patterns are matched against filenames only, not full paths
|
* - Patterns are matched against filenames only, not full paths
|
||||||
* - Example: STATIC_PRELOAD_INCLUDE="*.js,*.css,*.woff2"
|
* - Example: ASSET_PRELOAD_INCLUDE_PATTERNS="*.js,*.css,*.woff2"
|
||||||
*
|
*
|
||||||
* STATIC_PRELOAD_EXCLUDE (string)
|
* ASSET_PRELOAD_EXCLUDE_PATTERNS (string)
|
||||||
* - Comma-separated list of glob patterns for files to exclude
|
* - Comma-separated list of glob patterns for files to exclude
|
||||||
* - Applied after include patterns
|
* - Applied after include patterns
|
||||||
* - Patterns are matched against filenames only, not full paths
|
* - Patterns are matched against filenames only, not full paths
|
||||||
* - Example: STATIC_PRELOAD_EXCLUDE="*.map,*.txt"
|
* - Example: ASSET_PRELOAD_EXCLUDE_PATTERNS="*.map,*.txt"
|
||||||
*
|
*
|
||||||
* STATIC_PRELOAD_VERBOSE (boolean)
|
* ASSET_PRELOAD_VERBOSE_LOGGING (boolean)
|
||||||
* - Enable detailed logging of loaded and skipped files
|
* - Enable detailed logging of loaded and skipped files
|
||||||
* - Default: false
|
* - Default: false
|
||||||
* - Set to "true" to enable verbose output
|
* - Set to "true" to enable verbose output
|
||||||
*
|
*
|
||||||
|
* ASSET_PRELOAD_ENABLE_ETAG (boolean)
|
||||||
|
* - Enable ETag generation for preloaded assets
|
||||||
|
* - Default: true
|
||||||
|
* - Set to "false" to disable ETag support
|
||||||
|
*
|
||||||
|
* ASSET_PRELOAD_ENABLE_GZIP (boolean)
|
||||||
|
* - Enable Gzip compression for eligible assets
|
||||||
|
* - Default: true
|
||||||
|
* - Set to "false" to disable Gzip compression
|
||||||
|
*
|
||||||
|
* ASSET_PRELOAD_GZIP_MIN_SIZE (number)
|
||||||
|
* - Minimum file size in bytes required for Gzip compression
|
||||||
|
* - Files smaller than this will not be compressed
|
||||||
|
* - Default: 1024 (1KB)
|
||||||
|
*
|
||||||
|
* ASSET_PRELOAD_GZIP_MIME_TYPES (string)
|
||||||
|
* - Comma-separated list of MIME types eligible for Gzip compression
|
||||||
|
* - Supports partial matching for types ending with "/"
|
||||||
|
* - Default: text/,application/javascript,application/json,application/xml,image/svg+xml
|
||||||
|
*
|
||||||
* Usage:
|
* Usage:
|
||||||
* bun run server.ts
|
* bun run server.ts
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { readdir } from 'node:fs/promises'
|
import path from 'node:path'
|
||||||
import { join } from 'node:path'
|
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
const PORT = Number(process.env.PORT ?? 3000)
|
const SERVER_PORT = Number(process.env.PORT ?? 3000)
|
||||||
const CLIENT_DIR = './dist/client'
|
const CLIENT_DIRECTORY = './dist/client'
|
||||||
const SERVER_ENTRY = './dist/server/server.js'
|
const SERVER_ENTRY_POINT = './dist/server/server.js'
|
||||||
|
|
||||||
|
// Logging utilities for professional output
|
||||||
|
const log = {
|
||||||
|
info: (message: string) => {
|
||||||
|
console.log(`[INFO] ${message}`)
|
||||||
|
},
|
||||||
|
success: (message: string) => {
|
||||||
|
console.log(`[SUCCESS] ${message}`)
|
||||||
|
},
|
||||||
|
warning: (message: string) => {
|
||||||
|
console.log(`[WARNING] ${message}`)
|
||||||
|
},
|
||||||
|
error: (message: string) => {
|
||||||
|
console.log(`[ERROR] ${message}`)
|
||||||
|
},
|
||||||
|
header: (message: string) => {
|
||||||
|
console.log(`\n${message}\n`)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
// Preloading configuration from environment variables
|
// Preloading configuration from environment variables
|
||||||
const MAX_PRELOAD_BYTES = Number(
|
const MAX_PRELOAD_BYTES = Number(
|
||||||
process.env.STATIC_PRELOAD_MAX_BYTES ?? 5 * 1024 * 1024, // 5MB default
|
process.env.ASSET_PRELOAD_MAX_SIZE ?? 5 * 1024 * 1024, // 5MB default
|
||||||
)
|
)
|
||||||
|
|
||||||
// Parse comma-separated include patterns (no defaults)
|
// Parse comma-separated include patterns (no defaults)
|
||||||
const INCLUDE_PATTERNS = (process.env.STATIC_PRELOAD_INCLUDE ?? '')
|
const INCLUDE_PATTERNS = (process.env.ASSET_PRELOAD_INCLUDE_PATTERNS ?? '')
|
||||||
.split(',')
|
.split(',')
|
||||||
.map((s) => s.trim())
|
.map((s) => s.trim())
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.map(globToRegExp)
|
.map((pattern: string) => convertGlobToRegExp(pattern))
|
||||||
|
|
||||||
// Parse comma-separated exclude patterns (no defaults)
|
// Parse comma-separated exclude patterns (no defaults)
|
||||||
const EXCLUDE_PATTERNS = (process.env.STATIC_PRELOAD_EXCLUDE ?? '')
|
const EXCLUDE_PATTERNS = (process.env.ASSET_PRELOAD_EXCLUDE_PATTERNS ?? '')
|
||||||
.split(',')
|
.split(',')
|
||||||
.map((s) => s.trim())
|
.map((s) => s.trim())
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.map(globToRegExp)
|
.map((pattern: string) => convertGlobToRegExp(pattern))
|
||||||
|
|
||||||
// Verbose logging flag
|
// Verbose logging flag
|
||||||
const VERBOSE = process.env.STATIC_PRELOAD_VERBOSE === 'true'
|
const VERBOSE = process.env.ASSET_PRELOAD_VERBOSE_LOGGING === 'true'
|
||||||
|
|
||||||
|
// Optional ETag feature
|
||||||
|
const ENABLE_ETAG = (process.env.ASSET_PRELOAD_ENABLE_ETAG ?? 'true') === 'true'
|
||||||
|
|
||||||
|
// Optional Gzip feature
|
||||||
|
const ENABLE_GZIP = (process.env.ASSET_PRELOAD_ENABLE_GZIP ?? 'true') === 'true'
|
||||||
|
const GZIP_MIN_BYTES = Number(process.env.ASSET_PRELOAD_GZIP_MIN_SIZE ?? 1024) // 1KB
|
||||||
|
const GZIP_TYPES = (
|
||||||
|
process.env.ASSET_PRELOAD_GZIP_MIME_TYPES ??
|
||||||
|
'text/,application/javascript,application/json,application/xml,image/svg+xml'
|
||||||
|
)
|
||||||
|
.split(',')
|
||||||
|
.map((v) => v.trim())
|
||||||
|
.filter(Boolean)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a simple glob pattern to a regular expression
|
* Convert a simple glob pattern to a regular expression
|
||||||
* Supports * wildcard for matching any characters
|
* Supports * wildcard for matching any characters
|
||||||
*/
|
*/
|
||||||
function globToRegExp(glob: string): RegExp {
|
function convertGlobToRegExp(globPattern: string): RegExp {
|
||||||
// Escape regex special chars except *, then replace * with .*
|
// Escape regex special chars except *, then replace * with .*
|
||||||
const escaped = glob
|
const escapedPattern = globPattern
|
||||||
.replace(/[-/\\^$+?.()|[\]{}]/g, '\\$&')
|
.replace(/[-/\\^$+?.()|[\]{}]/g, '\\$&')
|
||||||
.replace(/\*/g, '.*')
|
.replace(/\*/g, '.*')
|
||||||
return new RegExp(`^${escaped}$`, 'i')
|
return new RegExp(`^${escapedPattern}$`, 'i')
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compute ETag for a given data buffer
|
||||||
|
*/
|
||||||
|
function computeEtag(data: Uint8Array): string {
|
||||||
|
const hash = Bun.hash(data)
|
||||||
|
return `W/"${hash.toString(16)}-${data.byteLength.toString()}"`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,18 +155,30 @@ interface AssetMetadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result of static asset preloading process
|
* In-memory asset with ETag and Gzip support
|
||||||
*/
|
*/
|
||||||
interface PreloadResult {
|
interface InMemoryAsset {
|
||||||
routes: Record<string, () => Response>
|
raw: Uint8Array
|
||||||
loaded: Array<AssetMetadata>
|
gz?: Uint8Array
|
||||||
skipped: Array<AssetMetadata>
|
etag?: string
|
||||||
|
type: string
|
||||||
|
immutable: boolean
|
||||||
|
size: number
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a file should be included based on configured patterns
|
* Result of static asset preloading process
|
||||||
*/
|
*/
|
||||||
function shouldInclude(relativePath: string): boolean {
|
interface PreloadResult {
|
||||||
|
routes: Record<string, (req: Request) => Response | Promise<Response>>
|
||||||
|
loaded: AssetMetadata[]
|
||||||
|
skipped: AssetMetadata[]
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a file is eligible for preloading based on configured patterns
|
||||||
|
*/
|
||||||
|
function isFileEligibleForPreloading(relativePath: string): boolean {
|
||||||
const fileName = relativePath.split(/[/\\]/).pop() ?? relativePath
|
const fileName = relativePath.split(/[/\\]/).pop() ?? relativePath
|
||||||
|
|
||||||
// If include patterns are specified, file must match at least one
|
// If include patterns are specified, file must match at least one
|
||||||
@@ -125,38 +197,122 @@ function shouldInclude(relativePath: string): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build static routes with intelligent preloading strategy
|
* Check if a MIME type is compressible
|
||||||
|
*/
|
||||||
|
function isMimeTypeCompressible(mimeType: string): boolean {
|
||||||
|
return GZIP_TYPES.some((type) =>
|
||||||
|
type.endsWith('/') ? mimeType.startsWith(type) : mimeType === type,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Conditionally compress data based on size and MIME type
|
||||||
|
*/
|
||||||
|
function compressDataIfAppropriate(
|
||||||
|
data: Uint8Array,
|
||||||
|
mimeType: string,
|
||||||
|
): Uint8Array | undefined {
|
||||||
|
if (!ENABLE_GZIP) return undefined
|
||||||
|
if (data.byteLength < GZIP_MIN_BYTES) return undefined
|
||||||
|
if (!isMimeTypeCompressible(mimeType)) return undefined
|
||||||
|
try {
|
||||||
|
return Bun.gzipSync(data.buffer as ArrayBuffer)
|
||||||
|
} catch {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create response handler function with ETag and Gzip support
|
||||||
|
*/
|
||||||
|
function createResponseHandler(
|
||||||
|
asset: InMemoryAsset,
|
||||||
|
): (req: Request) => Response {
|
||||||
|
return (req: Request) => {
|
||||||
|
const headers: Record<string, string> = {
|
||||||
|
'Content-Type': asset.type,
|
||||||
|
'Cache-Control': asset.immutable
|
||||||
|
? 'public, max-age=31536000, immutable'
|
||||||
|
: 'public, max-age=3600',
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ENABLE_ETAG && asset.etag) {
|
||||||
|
const ifNone = req.headers.get('if-none-match')
|
||||||
|
if (ifNone && ifNone === asset.etag) {
|
||||||
|
return new Response(null, {
|
||||||
|
status: 304,
|
||||||
|
headers: { ETag: asset.etag },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
headers.ETag = asset.etag
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
ENABLE_GZIP &&
|
||||||
|
asset.gz &&
|
||||||
|
req.headers.get('accept-encoding')?.includes('gzip')
|
||||||
|
) {
|
||||||
|
headers['Content-Encoding'] = 'gzip'
|
||||||
|
headers['Content-Length'] = String(asset.gz.byteLength)
|
||||||
|
const gzCopy = new Uint8Array(asset.gz)
|
||||||
|
return new Response(gzCopy, { status: 200, headers })
|
||||||
|
}
|
||||||
|
|
||||||
|
headers['Content-Length'] = String(asset.raw.byteLength)
|
||||||
|
const rawCopy = new Uint8Array(asset.raw)
|
||||||
|
return new Response(rawCopy, { status: 200, headers })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create composite glob pattern from include patterns
|
||||||
|
*/
|
||||||
|
function createCompositeGlobPattern(): Bun.Glob {
|
||||||
|
const raw = (process.env.ASSET_PRELOAD_INCLUDE_PATTERNS ?? '')
|
||||||
|
.split(',')
|
||||||
|
.map((s) => s.trim())
|
||||||
|
.filter(Boolean)
|
||||||
|
if (raw.length === 0) return new Bun.Glob('**/*')
|
||||||
|
if (raw.length === 1) return new Bun.Glob(raw[0])
|
||||||
|
return new Bun.Glob(`{${raw.join(',')}}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize static routes with intelligent preloading strategy
|
||||||
* Small files are loaded into memory, large files are served on-demand
|
* Small files are loaded into memory, large files are served on-demand
|
||||||
*/
|
*/
|
||||||
async function buildStaticRoutes(clientDir: string): Promise<PreloadResult> {
|
async function initializeStaticRoutes(
|
||||||
const routes: Record<string, () => Response> = {}
|
clientDirectory: string,
|
||||||
const loaded: Array<AssetMetadata> = []
|
): Promise<PreloadResult> {
|
||||||
const skipped: Array<AssetMetadata> = []
|
const routes: Record<string, (req: Request) => Response | Promise<Response>> =
|
||||||
|
{}
|
||||||
|
const loaded: AssetMetadata[] = []
|
||||||
|
const skipped: AssetMetadata[] = []
|
||||||
|
|
||||||
console.log(`📦 Loading static assets from ${clientDir}...`)
|
log.info(`Loading static assets from ${clientDirectory}...`)
|
||||||
|
if (VERBOSE) {
|
||||||
console.log(
|
console.log(
|
||||||
`Max preload size: ${(MAX_PRELOAD_BYTES / 1024 / 1024).toFixed(2)} MB`,
|
`Max preload size: ${(MAX_PRELOAD_BYTES / 1024 / 1024).toFixed(2)} MB`,
|
||||||
)
|
)
|
||||||
if (INCLUDE_PATTERNS.length > 0) {
|
if (INCLUDE_PATTERNS.length > 0) {
|
||||||
console.log(
|
console.log(
|
||||||
` Include patterns: ${process.env.STATIC_PRELOAD_INCLUDE ?? ''}`,
|
`Include patterns: ${process.env.ASSET_PRELOAD_INCLUDE_PATTERNS ?? ''}`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (EXCLUDE_PATTERNS.length > 0) {
|
if (EXCLUDE_PATTERNS.length > 0) {
|
||||||
console.log(
|
console.log(
|
||||||
` Exclude patterns: ${process.env.STATIC_PRELOAD_EXCLUDE ?? ''}`,
|
`Exclude patterns: ${process.env.ASSET_PRELOAD_EXCLUDE_PATTERNS ?? ''}`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let totalPreloadedBytes = 0
|
let totalPreloadedBytes = 0
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Read all files recursively
|
const glob = createCompositeGlobPattern()
|
||||||
const files = await readdir(clientDir, { recursive: true })
|
for await (const relativePath of glob.scan({ cwd: clientDirectory })) {
|
||||||
|
const filepath = path.join(clientDirectory, relativePath)
|
||||||
for (const relativePath of files) {
|
const route = `/${relativePath.split(path.sep).join(path.posix.sep)}`
|
||||||
const filepath = join(clientDir, relativePath)
|
|
||||||
const route = '/' + relativePath.replace(/\\/g, '/') // Handle Windows paths
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Get file metadata
|
// Get file metadata
|
||||||
@@ -174,20 +330,26 @@ async function buildStaticRoutes(clientDir: string): Promise<PreloadResult> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Determine if file should be preloaded
|
// Determine if file should be preloaded
|
||||||
const matchesPattern = shouldInclude(relativePath)
|
const matchesPattern = isFileEligibleForPreloading(relativePath)
|
||||||
const withinSizeLimit = file.size <= MAX_PRELOAD_BYTES
|
const withinSizeLimit = file.size <= MAX_PRELOAD_BYTES
|
||||||
|
|
||||||
if (matchesPattern && withinSizeLimit) {
|
if (matchesPattern && withinSizeLimit) {
|
||||||
// Preload small files into memory
|
// Preload small files into memory with ETag and Gzip support
|
||||||
const bytes = await file.bytes()
|
const bytes = new Uint8Array(await file.arrayBuffer())
|
||||||
|
const gz = compressDataIfAppropriate(bytes, metadata.type)
|
||||||
routes[route] = () =>
|
const etag = ENABLE_ETAG ? computeEtag(bytes) : undefined
|
||||||
new Response(bytes, {
|
const asset: InMemoryAsset = {
|
||||||
headers: {
|
raw: bytes,
|
||||||
'Content-Type': metadata.type,
|
gz,
|
||||||
'Cache-Control': 'public, max-age=31536000, immutable',
|
etag,
|
||||||
},
|
type: metadata.type,
|
||||||
})
|
// Only Vite's content-hashed output under /assets/ is safe to
|
||||||
|
// cache immutably; unhashed files (favicon, manifest, images)
|
||||||
|
// can change between deploys and must revalidate.
|
||||||
|
immutable: route.startsWith('/assets/'),
|
||||||
|
size: bytes.byteLength,
|
||||||
|
}
|
||||||
|
routes[route] = createResponseHandler(asset)
|
||||||
|
|
||||||
loaded.push({ ...metadata, size: bytes.byteLength })
|
loaded.push({ ...metadata, size: bytes.byteLength })
|
||||||
totalPreloadedBytes += bytes.byteLength
|
totalPreloadedBytes += bytes.byteLength
|
||||||
@@ -207,13 +369,13 @@ async function buildStaticRoutes(clientDir: string): Promise<PreloadResult> {
|
|||||||
}
|
}
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
if (error instanceof Error && error.name !== 'EISDIR') {
|
if (error instanceof Error && error.name !== 'EISDIR') {
|
||||||
console.error(`❌ Failed to load ${filepath}:`, error)
|
log.error(`Failed to load ${filepath}: ${error.message}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always show file overview in Vite-like format first
|
// Show detailed file overview only when verbose mode is enabled
|
||||||
if (loaded.length > 0 || skipped.length > 0) {
|
if (VERBOSE && (loaded.length > 0 || skipped.length > 0)) {
|
||||||
const allFiles = [...loaded, ...skipped].sort((a, b) =>
|
const allFiles = [...loaded, ...skipped].sort((a, b) =>
|
||||||
a.route.localeCompare(b.route),
|
a.route.localeCompare(b.route),
|
||||||
)
|
)
|
||||||
@@ -224,124 +386,157 @@ async function buildStaticRoutes(clientDir: string): Promise<PreloadResult> {
|
|||||||
60,
|
60,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Format file size with KB and gzip estimation
|
// Format file size with KB and actual gzip size
|
||||||
const formatFileSize = (bytes: number) => {
|
const formatFileSize = (bytes: number, gzBytes?: number) => {
|
||||||
const kb = bytes / 1024
|
const kb = bytes / 1024
|
||||||
// Rough gzip estimation (typically 30-70% compression)
|
const sizeStr = kb < 100 ? kb.toFixed(2) : kb.toFixed(1)
|
||||||
|
|
||||||
|
if (gzBytes !== undefined) {
|
||||||
|
const gzKb = gzBytes / 1024
|
||||||
|
const gzStr = gzKb < 100 ? gzKb.toFixed(2) : gzKb.toFixed(1)
|
||||||
|
return {
|
||||||
|
size: sizeStr,
|
||||||
|
gzip: gzStr,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rough gzip estimation (typically 30-70% compression) if no actual gzip data
|
||||||
const gzipKb = kb * 0.35
|
const gzipKb = kb * 0.35
|
||||||
return {
|
return {
|
||||||
size: kb < 100 ? kb.toFixed(2) : kb.toFixed(1),
|
size: sizeStr,
|
||||||
gzip: gzipKb < 100 ? gzipKb.toFixed(2) : gzipKb.toFixed(1),
|
gzip: gzipKb < 100 ? gzipKb.toFixed(2) : gzipKb.toFixed(1),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loaded.length > 0) {
|
if (loaded.length > 0) {
|
||||||
console.log('\n📁 Preloaded into memory:')
|
console.log('\n📁 Preloaded into memory:')
|
||||||
|
console.log(
|
||||||
|
'Path │ Size │ Gzip Size',
|
||||||
|
)
|
||||||
loaded
|
loaded
|
||||||
.sort((a, b) => a.route.localeCompare(b.route))
|
.sort((a, b) => a.route.localeCompare(b.route))
|
||||||
.forEach((file) => {
|
.forEach((file) => {
|
||||||
const { size, gzip } = formatFileSize(file.size)
|
const { size, gzip } = formatFileSize(file.size)
|
||||||
const paddedPath = file.route.padEnd(maxPathLength)
|
const paddedPath = file.route.padEnd(maxPathLength)
|
||||||
const sizeStr = `${size.padStart(7)} kB`
|
const sizeStr = `${size.padStart(7)} kB`
|
||||||
const gzipStr = `gzip: ${gzip.padStart(6)} kB`
|
const gzipStr = `${gzip.padStart(7)} kB`
|
||||||
console.log(` ${paddedPath} ${sizeStr} │ ${gzipStr}`)
|
console.log(`${paddedPath} │ ${sizeStr} │ ${gzipStr}`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skipped.length > 0) {
|
if (skipped.length > 0) {
|
||||||
console.log('\n💾 Served on-demand:')
|
console.log('\n💾 Served on-demand:')
|
||||||
|
console.log(
|
||||||
|
'Path │ Size │ Gzip Size',
|
||||||
|
)
|
||||||
skipped
|
skipped
|
||||||
.sort((a, b) => a.route.localeCompare(b.route))
|
.sort((a, b) => a.route.localeCompare(b.route))
|
||||||
.forEach((file) => {
|
.forEach((file) => {
|
||||||
const { size, gzip } = formatFileSize(file.size)
|
const { size, gzip } = formatFileSize(file.size)
|
||||||
const paddedPath = file.route.padEnd(maxPathLength)
|
const paddedPath = file.route.padEnd(maxPathLength)
|
||||||
const sizeStr = `${size.padStart(7)} kB`
|
const sizeStr = `${size.padStart(7)} kB`
|
||||||
const gzipStr = `gzip: ${gzip.padStart(6)} kB`
|
const gzipStr = `${gzip.padStart(7)} kB`
|
||||||
console.log(` ${paddedPath} ${sizeStr} │ ${gzipStr}`)
|
console.log(`${paddedPath} │ ${sizeStr} │ ${gzipStr}`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Show detailed verbose info if enabled
|
// Show detailed verbose info if enabled
|
||||||
if (VERBOSE) {
|
if (VERBOSE) {
|
||||||
|
if (loaded.length > 0 || skipped.length > 0) {
|
||||||
|
const allFiles = [...loaded, ...skipped].sort((a, b) =>
|
||||||
|
a.route.localeCompare(b.route),
|
||||||
|
)
|
||||||
console.log('\n📊 Detailed file information:')
|
console.log('\n📊 Detailed file information:')
|
||||||
|
console.log(
|
||||||
|
'Status │ Path │ MIME Type │ Reason',
|
||||||
|
)
|
||||||
allFiles.forEach((file) => {
|
allFiles.forEach((file) => {
|
||||||
const isPreloaded = loaded.includes(file)
|
const isPreloaded = loaded.includes(file)
|
||||||
const status = isPreloaded ? '[MEMORY]' : '[ON-DEMAND]'
|
const status = isPreloaded ? 'MEMORY' : 'ON-DEMAND'
|
||||||
const reason =
|
const reason =
|
||||||
!isPreloaded && file.size > MAX_PRELOAD_BYTES
|
!isPreloaded && file.size > MAX_PRELOAD_BYTES
|
||||||
? ' (too large)'
|
? 'too large'
|
||||||
: !isPreloaded
|
: !isPreloaded
|
||||||
? ' (filtered)'
|
? 'filtered'
|
||||||
: ''
|
: 'preloaded'
|
||||||
|
const route =
|
||||||
|
file.route.length > 30
|
||||||
|
? file.route.substring(0, 27) + '...'
|
||||||
|
: file.route
|
||||||
console.log(
|
console.log(
|
||||||
` ${status.padEnd(12)} ${file.route} - ${file.type}${reason}`,
|
`${status.padEnd(12)} │ ${route.padEnd(30)} │ ${file.type.padEnd(28)} │ ${reason.padEnd(10)}`,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
console.log('\n📊 No files found to display')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log summary after the file list
|
// Log summary after the file list
|
||||||
console.log() // Empty line for separation
|
console.log() // Empty line for separation
|
||||||
if (loaded.length > 0) {
|
if (loaded.length > 0) {
|
||||||
console.log(
|
log.success(
|
||||||
`✅ Preloaded ${String(loaded.length)} files (${(totalPreloadedBytes / 1024 / 1024).toFixed(2)} MB) into memory`,
|
`Preloaded ${String(loaded.length)} files (${(totalPreloadedBytes / 1024 / 1024).toFixed(2)} MB) into memory`,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
console.log('ℹ️ No files preloaded into memory')
|
log.info('No files preloaded into memory')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skipped.length > 0) {
|
if (skipped.length > 0) {
|
||||||
const tooLarge = skipped.filter((f) => f.size > MAX_PRELOAD_BYTES).length
|
const tooLarge = skipped.filter((f) => f.size > MAX_PRELOAD_BYTES).length
|
||||||
const filtered = skipped.length - tooLarge
|
const filtered = skipped.length - tooLarge
|
||||||
console.log(
|
log.info(
|
||||||
`ℹ️ ${String(skipped.length)} files will be served on-demand (${String(tooLarge)} too large, ${String(filtered)} filtered)`,
|
`${String(skipped.length)} files will be served on-demand (${String(tooLarge)} too large, ${String(filtered)} filtered)`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`❌ Failed to load static files from ${clientDir}:`, error)
|
log.error(
|
||||||
|
`Failed to load static files from ${clientDirectory}: ${String(error)}`,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return { routes, loaded, skipped }
|
return { routes, loaded, skipped }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start the production server
|
* Initialize the server
|
||||||
*/
|
*/
|
||||||
async function startServer() {
|
async function initializeServer() {
|
||||||
console.log('🚀 Starting production server...')
|
log.header('Starting Production Server')
|
||||||
|
|
||||||
// Load TanStack Start server handler
|
// Load TanStack Start server handler
|
||||||
let handler: { fetch: (request: Request) => Response | Promise<Response> }
|
let handler: { fetch: (request: Request) => Response | Promise<Response> }
|
||||||
try {
|
try {
|
||||||
const serverModule = (await import(SERVER_ENTRY)) as {
|
const serverModule = (await import(SERVER_ENTRY_POINT)) as {
|
||||||
default: { fetch: (request: Request) => Response | Promise<Response> }
|
default: { fetch: (request: Request) => Response | Promise<Response> }
|
||||||
}
|
}
|
||||||
handler = serverModule.default
|
handler = serverModule.default
|
||||||
console.log('✅ TanStack Start handler loaded')
|
log.success('TanStack Start application handler initialized')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('❌ Failed to load server handler:', error)
|
log.error(`Failed to load server handler: ${String(error)}`)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build static routes with intelligent preloading
|
// Build static routes with intelligent preloading
|
||||||
const { routes } = await buildStaticRoutes(CLIENT_DIR)
|
const { routes } = await initializeStaticRoutes(CLIENT_DIRECTORY)
|
||||||
|
|
||||||
// Create Bun server
|
// Create Bun server
|
||||||
const server = Bun.serve({
|
const server = Bun.serve({
|
||||||
port: PORT,
|
port: SERVER_PORT,
|
||||||
|
|
||||||
idleTimeout: 255,
|
|
||||||
|
|
||||||
routes: {
|
routes: {
|
||||||
// Serve static assets (preloaded or on-demand)
|
// Serve static assets (preloaded or on-demand)
|
||||||
...routes,
|
...routes,
|
||||||
|
|
||||||
// Fallback to TanStack Start handler for all other routes
|
// Fallback to TanStack Start handler for all other routes
|
||||||
'/*': (request) => {
|
'/*': async (req: Request) => {
|
||||||
try {
|
try {
|
||||||
return handler.fetch(request)
|
// Return the handler's Response as-is so streaming bodies
|
||||||
|
// (SSR streaming, SSE event streams) pass through unbuffered.
|
||||||
|
return await handler.fetch(req)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Server handler error:', error)
|
log.error(`Server handler error: ${String(error)}`)
|
||||||
return new Response('Internal Server Error', { status: 500 })
|
return new Response('Internal Server Error', { status: 500 })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -349,18 +544,18 @@ async function startServer() {
|
|||||||
|
|
||||||
// Global error handler
|
// Global error handler
|
||||||
error(error) {
|
error(error) {
|
||||||
console.error('Uncaught server error:', error)
|
log.error(
|
||||||
|
`Uncaught server error: ${error instanceof Error ? error.message : String(error)}`,
|
||||||
|
)
|
||||||
return new Response('Internal Server Error', { status: 500 })
|
return new Response('Internal Server Error', { status: 500 })
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(
|
log.success(`Server listening on http://localhost:${String(server.port)}`)
|
||||||
`\n🚀 Server running at http://localhost:${String(server.port)}\n`,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the server
|
// Initialize the server
|
||||||
startServer().catch((error: unknown) => {
|
initializeServer().catch((error: unknown) => {
|
||||||
console.error('Failed to start server:', error)
|
log.error(`Failed to start server: ${String(error)}`)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
})
|
})
|
||||||
@@ -14,6 +14,7 @@ import { Route as LogoutRouteImport } from './routes/logout'
|
|||||||
import { Route as LoginRouteImport } from './routes/login'
|
import { Route as LoginRouteImport } from './routes/login'
|
||||||
import { Route as AuthedRouteImport } from './routes/_authed'
|
import { Route as AuthedRouteImport } from './routes/_authed'
|
||||||
import { Route as AuthedIndexRouteImport } from './routes/_authed/index'
|
import { Route as AuthedIndexRouteImport } from './routes/_authed/index'
|
||||||
|
import { Route as ApiHealthRouteImport } from './routes/api/health'
|
||||||
import { Route as AuthedStatsRouteImport } from './routes/_authed/stats'
|
import { Route as AuthedStatsRouteImport } from './routes/_authed/stats'
|
||||||
import { Route as AuthedSettingsRouteImport } from './routes/_authed/settings'
|
import { Route as AuthedSettingsRouteImport } from './routes/_authed/settings'
|
||||||
import { Route as AuthedBadgesRouteImport } from './routes/_authed/badges'
|
import { Route as AuthedBadgesRouteImport } from './routes/_authed/badges'
|
||||||
@@ -37,11 +38,16 @@ import { Route as AuthedAdminPreviewRouteImport } from './routes/_authed/admin/p
|
|||||||
import { Route as AuthedAdminBadgesRouteImport } from './routes/_authed/admin/badges'
|
import { Route as AuthedAdminBadgesRouteImport } from './routes/_authed/admin/badges'
|
||||||
import { Route as AuthedAdminActivitiesRouteImport } from './routes/_authed/admin/activities'
|
import { Route as AuthedAdminActivitiesRouteImport } from './routes/_authed/admin/activities'
|
||||||
import { Route as AuthedAdminTournamentsIndexRouteImport } from './routes/_authed/admin/tournaments/index'
|
import { Route as AuthedAdminTournamentsIndexRouteImport } from './routes/_authed/admin/tournaments/index'
|
||||||
|
import { Route as AuthedTournamentsIdPredictionsRouteImport } from './routes/_authed/tournaments/$id.predictions'
|
||||||
|
import { Route as AuthedTournamentsIdGroupsRouteImport } from './routes/_authed/tournaments/$id.groups'
|
||||||
import { Route as AuthedTournamentsIdBracketRouteImport } from './routes/_authed/tournaments/$id.bracket'
|
import { Route as AuthedTournamentsIdBracketRouteImport } from './routes/_authed/tournaments/$id.bracket'
|
||||||
import { Route as AuthedAdminTournamentsIdIndexRouteImport } from './routes/_authed/admin/tournaments/$id/index'
|
import { Route as AuthedAdminTournamentsIdIndexRouteImport } from './routes/_authed/admin/tournaments/$id/index'
|
||||||
import { Route as ApiFilesCollectionRecordIdFileRouteImport } from './routes/api/files/$collection/$recordId/$file'
|
import { Route as ApiFilesCollectionRecordIdFileRouteImport } from './routes/api/files/$collection/$recordId/$file'
|
||||||
|
import { Route as AuthedTournamentsIdPredictionsMakeRouteImport } from './routes/_authed/tournaments/$id.predictions_.make'
|
||||||
|
import { Route as AuthedTournamentsIdPredictionsPlayerIdRouteImport } from './routes/_authed/tournaments/$id.predictions_.$playerId'
|
||||||
import { Route as AuthedAdminTournamentsRunIdRouteImport } from './routes/_authed/admin/tournaments/run.$id'
|
import { Route as AuthedAdminTournamentsRunIdRouteImport } from './routes/_authed/admin/tournaments/run.$id'
|
||||||
import { Route as AuthedAdminTournamentsIdTeamsRouteImport } from './routes/_authed/admin/tournaments/$id/teams'
|
import { Route as AuthedAdminTournamentsIdTeamsRouteImport } from './routes/_authed/admin/tournaments/$id/teams'
|
||||||
|
import { Route as AuthedAdminTournamentsIdAssignPartnersRouteImport } from './routes/_authed/admin/tournaments/$id/assign-partners'
|
||||||
|
|
||||||
const RefreshSessionRoute = RefreshSessionRouteImport.update({
|
const RefreshSessionRoute = RefreshSessionRouteImport.update({
|
||||||
id: '/refresh-session',
|
id: '/refresh-session',
|
||||||
@@ -67,6 +73,11 @@ const AuthedIndexRoute = AuthedIndexRouteImport.update({
|
|||||||
path: '/',
|
path: '/',
|
||||||
getParentRoute: () => AuthedRoute,
|
getParentRoute: () => AuthedRoute,
|
||||||
} as any)
|
} as any)
|
||||||
|
const ApiHealthRoute = ApiHealthRouteImport.update({
|
||||||
|
id: '/api/health',
|
||||||
|
path: '/api/health',
|
||||||
|
getParentRoute: () => rootRouteImport,
|
||||||
|
} as any)
|
||||||
const AuthedStatsRoute = AuthedStatsRouteImport.update({
|
const AuthedStatsRoute = AuthedStatsRouteImport.update({
|
||||||
id: '/stats',
|
id: '/stats',
|
||||||
path: '/stats',
|
path: '/stats',
|
||||||
@@ -185,6 +196,18 @@ const AuthedAdminTournamentsIndexRoute =
|
|||||||
path: '/tournaments/',
|
path: '/tournaments/',
|
||||||
getParentRoute: () => AuthedAdminRoute,
|
getParentRoute: () => AuthedAdminRoute,
|
||||||
} as any)
|
} as any)
|
||||||
|
const AuthedTournamentsIdPredictionsRoute =
|
||||||
|
AuthedTournamentsIdPredictionsRouteImport.update({
|
||||||
|
id: '/tournaments/$id/predictions',
|
||||||
|
path: '/tournaments/$id/predictions',
|
||||||
|
getParentRoute: () => AuthedRoute,
|
||||||
|
} as any)
|
||||||
|
const AuthedTournamentsIdGroupsRoute =
|
||||||
|
AuthedTournamentsIdGroupsRouteImport.update({
|
||||||
|
id: '/tournaments/$id/groups',
|
||||||
|
path: '/tournaments/$id/groups',
|
||||||
|
getParentRoute: () => AuthedRoute,
|
||||||
|
} as any)
|
||||||
const AuthedTournamentsIdBracketRoute =
|
const AuthedTournamentsIdBracketRoute =
|
||||||
AuthedTournamentsIdBracketRouteImport.update({
|
AuthedTournamentsIdBracketRouteImport.update({
|
||||||
id: '/tournaments/$id/bracket',
|
id: '/tournaments/$id/bracket',
|
||||||
@@ -203,6 +226,18 @@ const ApiFilesCollectionRecordIdFileRoute =
|
|||||||
path: '/api/files/$collection/$recordId/$file',
|
path: '/api/files/$collection/$recordId/$file',
|
||||||
getParentRoute: () => rootRouteImport,
|
getParentRoute: () => rootRouteImport,
|
||||||
} as any)
|
} as any)
|
||||||
|
const AuthedTournamentsIdPredictionsMakeRoute =
|
||||||
|
AuthedTournamentsIdPredictionsMakeRouteImport.update({
|
||||||
|
id: '/tournaments/$id/predictions_/make',
|
||||||
|
path: '/tournaments/$id/predictions/make',
|
||||||
|
getParentRoute: () => AuthedRoute,
|
||||||
|
} as any)
|
||||||
|
const AuthedTournamentsIdPredictionsPlayerIdRoute =
|
||||||
|
AuthedTournamentsIdPredictionsPlayerIdRouteImport.update({
|
||||||
|
id: '/tournaments/$id/predictions_/$playerId',
|
||||||
|
path: '/tournaments/$id/predictions/$playerId',
|
||||||
|
getParentRoute: () => AuthedRoute,
|
||||||
|
} as any)
|
||||||
const AuthedAdminTournamentsRunIdRoute =
|
const AuthedAdminTournamentsRunIdRoute =
|
||||||
AuthedAdminTournamentsRunIdRouteImport.update({
|
AuthedAdminTournamentsRunIdRouteImport.update({
|
||||||
id: '/tournaments/run/$id',
|
id: '/tournaments/run/$id',
|
||||||
@@ -215,8 +250,15 @@ const AuthedAdminTournamentsIdTeamsRoute =
|
|||||||
path: '/tournaments/$id/teams',
|
path: '/tournaments/$id/teams',
|
||||||
getParentRoute: () => AuthedAdminRoute,
|
getParentRoute: () => AuthedAdminRoute,
|
||||||
} as any)
|
} as any)
|
||||||
|
const AuthedAdminTournamentsIdAssignPartnersRoute =
|
||||||
|
AuthedAdminTournamentsIdAssignPartnersRouteImport.update({
|
||||||
|
id: '/tournaments/$id/assign-partners',
|
||||||
|
path: '/tournaments/$id/assign-partners',
|
||||||
|
getParentRoute: () => AuthedAdminRoute,
|
||||||
|
} as any)
|
||||||
|
|
||||||
export interface FileRoutesByFullPath {
|
export interface FileRoutesByFullPath {
|
||||||
|
'/': typeof AuthedIndexRoute
|
||||||
'/login': typeof LoginRoute
|
'/login': typeof LoginRoute
|
||||||
'/logout': typeof LogoutRoute
|
'/logout': typeof LogoutRoute
|
||||||
'/refresh-session': typeof RefreshSessionRoute
|
'/refresh-session': typeof RefreshSessionRoute
|
||||||
@@ -224,7 +266,7 @@ export interface FileRoutesByFullPath {
|
|||||||
'/badges': typeof AuthedBadgesRoute
|
'/badges': typeof AuthedBadgesRoute
|
||||||
'/settings': typeof AuthedSettingsRoute
|
'/settings': typeof AuthedSettingsRoute
|
||||||
'/stats': typeof AuthedStatsRoute
|
'/stats': typeof AuthedStatsRoute
|
||||||
'/': typeof AuthedIndexRoute
|
'/api/health': typeof ApiHealthRoute
|
||||||
'/admin/activities': typeof AuthedAdminActivitiesRoute
|
'/admin/activities': typeof AuthedAdminActivitiesRoute
|
||||||
'/admin/badges': typeof AuthedAdminBadgesRoute
|
'/admin/badges': typeof AuthedAdminBadgesRoute
|
||||||
'/admin/preview': typeof AuthedAdminPreviewRoute
|
'/admin/preview': typeof AuthedAdminPreviewRoute
|
||||||
@@ -242,13 +284,18 @@ export interface FileRoutesByFullPath {
|
|||||||
'/api/teams/upload-logo': typeof ApiTeamsUploadLogoRoute
|
'/api/teams/upload-logo': typeof ApiTeamsUploadLogoRoute
|
||||||
'/api/tournaments/upload-logo': typeof ApiTournamentsUploadLogoRoute
|
'/api/tournaments/upload-logo': typeof ApiTournamentsUploadLogoRoute
|
||||||
'/admin/': typeof AuthedAdminIndexRoute
|
'/admin/': typeof AuthedAdminIndexRoute
|
||||||
'/tournaments': typeof AuthedTournamentsIndexRoute
|
'/tournaments/': typeof AuthedTournamentsIndexRoute
|
||||||
'/tournaments/$id/bracket': typeof AuthedTournamentsIdBracketRoute
|
'/tournaments/$id/bracket': typeof AuthedTournamentsIdBracketRoute
|
||||||
'/admin/tournaments': typeof AuthedAdminTournamentsIndexRoute
|
'/tournaments/$id/groups': typeof AuthedTournamentsIdGroupsRoute
|
||||||
|
'/tournaments/$id/predictions': typeof AuthedTournamentsIdPredictionsRoute
|
||||||
|
'/admin/tournaments/': typeof AuthedAdminTournamentsIndexRoute
|
||||||
|
'/admin/tournaments/$id/assign-partners': typeof AuthedAdminTournamentsIdAssignPartnersRoute
|
||||||
'/admin/tournaments/$id/teams': typeof AuthedAdminTournamentsIdTeamsRoute
|
'/admin/tournaments/$id/teams': typeof AuthedAdminTournamentsIdTeamsRoute
|
||||||
'/admin/tournaments/run/$id': typeof AuthedAdminTournamentsRunIdRoute
|
'/admin/tournaments/run/$id': typeof AuthedAdminTournamentsRunIdRoute
|
||||||
|
'/tournaments/$id/predictions/$playerId': typeof AuthedTournamentsIdPredictionsPlayerIdRoute
|
||||||
|
'/tournaments/$id/predictions/make': typeof AuthedTournamentsIdPredictionsMakeRoute
|
||||||
'/api/files/$collection/$recordId/$file': typeof ApiFilesCollectionRecordIdFileRoute
|
'/api/files/$collection/$recordId/$file': typeof ApiFilesCollectionRecordIdFileRoute
|
||||||
'/admin/tournaments/$id': typeof AuthedAdminTournamentsIdIndexRoute
|
'/admin/tournaments/$id/': typeof AuthedAdminTournamentsIdIndexRoute
|
||||||
}
|
}
|
||||||
export interface FileRoutesByTo {
|
export interface FileRoutesByTo {
|
||||||
'/login': typeof LoginRoute
|
'/login': typeof LoginRoute
|
||||||
@@ -257,6 +304,7 @@ export interface FileRoutesByTo {
|
|||||||
'/badges': typeof AuthedBadgesRoute
|
'/badges': typeof AuthedBadgesRoute
|
||||||
'/settings': typeof AuthedSettingsRoute
|
'/settings': typeof AuthedSettingsRoute
|
||||||
'/stats': typeof AuthedStatsRoute
|
'/stats': typeof AuthedStatsRoute
|
||||||
|
'/api/health': typeof ApiHealthRoute
|
||||||
'/': typeof AuthedIndexRoute
|
'/': typeof AuthedIndexRoute
|
||||||
'/admin/activities': typeof AuthedAdminActivitiesRoute
|
'/admin/activities': typeof AuthedAdminActivitiesRoute
|
||||||
'/admin/badges': typeof AuthedAdminBadgesRoute
|
'/admin/badges': typeof AuthedAdminBadgesRoute
|
||||||
@@ -277,9 +325,14 @@ export interface FileRoutesByTo {
|
|||||||
'/admin': typeof AuthedAdminIndexRoute
|
'/admin': typeof AuthedAdminIndexRoute
|
||||||
'/tournaments': typeof AuthedTournamentsIndexRoute
|
'/tournaments': typeof AuthedTournamentsIndexRoute
|
||||||
'/tournaments/$id/bracket': typeof AuthedTournamentsIdBracketRoute
|
'/tournaments/$id/bracket': typeof AuthedTournamentsIdBracketRoute
|
||||||
|
'/tournaments/$id/groups': typeof AuthedTournamentsIdGroupsRoute
|
||||||
|
'/tournaments/$id/predictions': typeof AuthedTournamentsIdPredictionsRoute
|
||||||
'/admin/tournaments': typeof AuthedAdminTournamentsIndexRoute
|
'/admin/tournaments': typeof AuthedAdminTournamentsIndexRoute
|
||||||
|
'/admin/tournaments/$id/assign-partners': typeof AuthedAdminTournamentsIdAssignPartnersRoute
|
||||||
'/admin/tournaments/$id/teams': typeof AuthedAdminTournamentsIdTeamsRoute
|
'/admin/tournaments/$id/teams': typeof AuthedAdminTournamentsIdTeamsRoute
|
||||||
'/admin/tournaments/run/$id': typeof AuthedAdminTournamentsRunIdRoute
|
'/admin/tournaments/run/$id': typeof AuthedAdminTournamentsRunIdRoute
|
||||||
|
'/tournaments/$id/predictions/$playerId': typeof AuthedTournamentsIdPredictionsPlayerIdRoute
|
||||||
|
'/tournaments/$id/predictions/make': typeof AuthedTournamentsIdPredictionsMakeRoute
|
||||||
'/api/files/$collection/$recordId/$file': typeof ApiFilesCollectionRecordIdFileRoute
|
'/api/files/$collection/$recordId/$file': typeof ApiFilesCollectionRecordIdFileRoute
|
||||||
'/admin/tournaments/$id': typeof AuthedAdminTournamentsIdIndexRoute
|
'/admin/tournaments/$id': typeof AuthedAdminTournamentsIdIndexRoute
|
||||||
}
|
}
|
||||||
@@ -293,6 +346,7 @@ export interface FileRoutesById {
|
|||||||
'/_authed/badges': typeof AuthedBadgesRoute
|
'/_authed/badges': typeof AuthedBadgesRoute
|
||||||
'/_authed/settings': typeof AuthedSettingsRoute
|
'/_authed/settings': typeof AuthedSettingsRoute
|
||||||
'/_authed/stats': typeof AuthedStatsRoute
|
'/_authed/stats': typeof AuthedStatsRoute
|
||||||
|
'/api/health': typeof ApiHealthRoute
|
||||||
'/_authed/': typeof AuthedIndexRoute
|
'/_authed/': typeof AuthedIndexRoute
|
||||||
'/_authed/admin/activities': typeof AuthedAdminActivitiesRoute
|
'/_authed/admin/activities': typeof AuthedAdminActivitiesRoute
|
||||||
'/_authed/admin/badges': typeof AuthedAdminBadgesRoute
|
'/_authed/admin/badges': typeof AuthedAdminBadgesRoute
|
||||||
@@ -313,15 +367,21 @@ export interface FileRoutesById {
|
|||||||
'/_authed/admin/': typeof AuthedAdminIndexRoute
|
'/_authed/admin/': typeof AuthedAdminIndexRoute
|
||||||
'/_authed/tournaments/': typeof AuthedTournamentsIndexRoute
|
'/_authed/tournaments/': typeof AuthedTournamentsIndexRoute
|
||||||
'/_authed/tournaments/$id/bracket': typeof AuthedTournamentsIdBracketRoute
|
'/_authed/tournaments/$id/bracket': typeof AuthedTournamentsIdBracketRoute
|
||||||
|
'/_authed/tournaments/$id/groups': typeof AuthedTournamentsIdGroupsRoute
|
||||||
|
'/_authed/tournaments/$id/predictions': typeof AuthedTournamentsIdPredictionsRoute
|
||||||
'/_authed/admin/tournaments/': typeof AuthedAdminTournamentsIndexRoute
|
'/_authed/admin/tournaments/': typeof AuthedAdminTournamentsIndexRoute
|
||||||
|
'/_authed/admin/tournaments/$id/assign-partners': typeof AuthedAdminTournamentsIdAssignPartnersRoute
|
||||||
'/_authed/admin/tournaments/$id/teams': typeof AuthedAdminTournamentsIdTeamsRoute
|
'/_authed/admin/tournaments/$id/teams': typeof AuthedAdminTournamentsIdTeamsRoute
|
||||||
'/_authed/admin/tournaments/run/$id': typeof AuthedAdminTournamentsRunIdRoute
|
'/_authed/admin/tournaments/run/$id': typeof AuthedAdminTournamentsRunIdRoute
|
||||||
|
'/_authed/tournaments/$id/predictions_/$playerId': typeof AuthedTournamentsIdPredictionsPlayerIdRoute
|
||||||
|
'/_authed/tournaments/$id/predictions_/make': typeof AuthedTournamentsIdPredictionsMakeRoute
|
||||||
'/api/files/$collection/$recordId/$file': typeof ApiFilesCollectionRecordIdFileRoute
|
'/api/files/$collection/$recordId/$file': typeof ApiFilesCollectionRecordIdFileRoute
|
||||||
'/_authed/admin/tournaments/$id/': typeof AuthedAdminTournamentsIdIndexRoute
|
'/_authed/admin/tournaments/$id/': typeof AuthedAdminTournamentsIdIndexRoute
|
||||||
}
|
}
|
||||||
export interface FileRouteTypes {
|
export interface FileRouteTypes {
|
||||||
fileRoutesByFullPath: FileRoutesByFullPath
|
fileRoutesByFullPath: FileRoutesByFullPath
|
||||||
fullPaths:
|
fullPaths:
|
||||||
|
| '/'
|
||||||
| '/login'
|
| '/login'
|
||||||
| '/logout'
|
| '/logout'
|
||||||
| '/refresh-session'
|
| '/refresh-session'
|
||||||
@@ -329,7 +389,7 @@ export interface FileRouteTypes {
|
|||||||
| '/badges'
|
| '/badges'
|
||||||
| '/settings'
|
| '/settings'
|
||||||
| '/stats'
|
| '/stats'
|
||||||
| '/'
|
| '/api/health'
|
||||||
| '/admin/activities'
|
| '/admin/activities'
|
||||||
| '/admin/badges'
|
| '/admin/badges'
|
||||||
| '/admin/preview'
|
| '/admin/preview'
|
||||||
@@ -347,13 +407,18 @@ export interface FileRouteTypes {
|
|||||||
| '/api/teams/upload-logo'
|
| '/api/teams/upload-logo'
|
||||||
| '/api/tournaments/upload-logo'
|
| '/api/tournaments/upload-logo'
|
||||||
| '/admin/'
|
| '/admin/'
|
||||||
| '/tournaments'
|
| '/tournaments/'
|
||||||
| '/tournaments/$id/bracket'
|
| '/tournaments/$id/bracket'
|
||||||
| '/admin/tournaments'
|
| '/tournaments/$id/groups'
|
||||||
|
| '/tournaments/$id/predictions'
|
||||||
|
| '/admin/tournaments/'
|
||||||
|
| '/admin/tournaments/$id/assign-partners'
|
||||||
| '/admin/tournaments/$id/teams'
|
| '/admin/tournaments/$id/teams'
|
||||||
| '/admin/tournaments/run/$id'
|
| '/admin/tournaments/run/$id'
|
||||||
|
| '/tournaments/$id/predictions/$playerId'
|
||||||
|
| '/tournaments/$id/predictions/make'
|
||||||
| '/api/files/$collection/$recordId/$file'
|
| '/api/files/$collection/$recordId/$file'
|
||||||
| '/admin/tournaments/$id'
|
| '/admin/tournaments/$id/'
|
||||||
fileRoutesByTo: FileRoutesByTo
|
fileRoutesByTo: FileRoutesByTo
|
||||||
to:
|
to:
|
||||||
| '/login'
|
| '/login'
|
||||||
@@ -362,6 +427,7 @@ export interface FileRouteTypes {
|
|||||||
| '/badges'
|
| '/badges'
|
||||||
| '/settings'
|
| '/settings'
|
||||||
| '/stats'
|
| '/stats'
|
||||||
|
| '/api/health'
|
||||||
| '/'
|
| '/'
|
||||||
| '/admin/activities'
|
| '/admin/activities'
|
||||||
| '/admin/badges'
|
| '/admin/badges'
|
||||||
@@ -382,9 +448,14 @@ export interface FileRouteTypes {
|
|||||||
| '/admin'
|
| '/admin'
|
||||||
| '/tournaments'
|
| '/tournaments'
|
||||||
| '/tournaments/$id/bracket'
|
| '/tournaments/$id/bracket'
|
||||||
|
| '/tournaments/$id/groups'
|
||||||
|
| '/tournaments/$id/predictions'
|
||||||
| '/admin/tournaments'
|
| '/admin/tournaments'
|
||||||
|
| '/admin/tournaments/$id/assign-partners'
|
||||||
| '/admin/tournaments/$id/teams'
|
| '/admin/tournaments/$id/teams'
|
||||||
| '/admin/tournaments/run/$id'
|
| '/admin/tournaments/run/$id'
|
||||||
|
| '/tournaments/$id/predictions/$playerId'
|
||||||
|
| '/tournaments/$id/predictions/make'
|
||||||
| '/api/files/$collection/$recordId/$file'
|
| '/api/files/$collection/$recordId/$file'
|
||||||
| '/admin/tournaments/$id'
|
| '/admin/tournaments/$id'
|
||||||
id:
|
id:
|
||||||
@@ -397,6 +468,7 @@ export interface FileRouteTypes {
|
|||||||
| '/_authed/badges'
|
| '/_authed/badges'
|
||||||
| '/_authed/settings'
|
| '/_authed/settings'
|
||||||
| '/_authed/stats'
|
| '/_authed/stats'
|
||||||
|
| '/api/health'
|
||||||
| '/_authed/'
|
| '/_authed/'
|
||||||
| '/_authed/admin/activities'
|
| '/_authed/admin/activities'
|
||||||
| '/_authed/admin/badges'
|
| '/_authed/admin/badges'
|
||||||
@@ -417,9 +489,14 @@ export interface FileRouteTypes {
|
|||||||
| '/_authed/admin/'
|
| '/_authed/admin/'
|
||||||
| '/_authed/tournaments/'
|
| '/_authed/tournaments/'
|
||||||
| '/_authed/tournaments/$id/bracket'
|
| '/_authed/tournaments/$id/bracket'
|
||||||
|
| '/_authed/tournaments/$id/groups'
|
||||||
|
| '/_authed/tournaments/$id/predictions'
|
||||||
| '/_authed/admin/tournaments/'
|
| '/_authed/admin/tournaments/'
|
||||||
|
| '/_authed/admin/tournaments/$id/assign-partners'
|
||||||
| '/_authed/admin/tournaments/$id/teams'
|
| '/_authed/admin/tournaments/$id/teams'
|
||||||
| '/_authed/admin/tournaments/run/$id'
|
| '/_authed/admin/tournaments/run/$id'
|
||||||
|
| '/_authed/tournaments/$id/predictions_/$playerId'
|
||||||
|
| '/_authed/tournaments/$id/predictions_/make'
|
||||||
| '/api/files/$collection/$recordId/$file'
|
| '/api/files/$collection/$recordId/$file'
|
||||||
| '/_authed/admin/tournaments/$id/'
|
| '/_authed/admin/tournaments/$id/'
|
||||||
fileRoutesById: FileRoutesById
|
fileRoutesById: FileRoutesById
|
||||||
@@ -429,6 +506,7 @@ export interface RootRouteChildren {
|
|||||||
LoginRoute: typeof LoginRoute
|
LoginRoute: typeof LoginRoute
|
||||||
LogoutRoute: typeof LogoutRoute
|
LogoutRoute: typeof LogoutRoute
|
||||||
RefreshSessionRoute: typeof RefreshSessionRoute
|
RefreshSessionRoute: typeof RefreshSessionRoute
|
||||||
|
ApiHealthRoute: typeof ApiHealthRoute
|
||||||
ApiAuthSplatRoute: typeof ApiAuthSplatRoute
|
ApiAuthSplatRoute: typeof ApiAuthSplatRoute
|
||||||
ApiEventsSplatRoute: typeof ApiEventsSplatRoute
|
ApiEventsSplatRoute: typeof ApiEventsSplatRoute
|
||||||
ApiSpotifyCallbackRoute: typeof ApiSpotifyCallbackRoute
|
ApiSpotifyCallbackRoute: typeof ApiSpotifyCallbackRoute
|
||||||
@@ -468,7 +546,7 @@ declare module '@tanstack/react-router' {
|
|||||||
'/_authed': {
|
'/_authed': {
|
||||||
id: '/_authed'
|
id: '/_authed'
|
||||||
path: ''
|
path: ''
|
||||||
fullPath: ''
|
fullPath: '/'
|
||||||
preLoaderRoute: typeof AuthedRouteImport
|
preLoaderRoute: typeof AuthedRouteImport
|
||||||
parentRoute: typeof rootRouteImport
|
parentRoute: typeof rootRouteImport
|
||||||
}
|
}
|
||||||
@@ -479,6 +557,13 @@ declare module '@tanstack/react-router' {
|
|||||||
preLoaderRoute: typeof AuthedIndexRouteImport
|
preLoaderRoute: typeof AuthedIndexRouteImport
|
||||||
parentRoute: typeof AuthedRoute
|
parentRoute: typeof AuthedRoute
|
||||||
}
|
}
|
||||||
|
'/api/health': {
|
||||||
|
id: '/api/health'
|
||||||
|
path: '/api/health'
|
||||||
|
fullPath: '/api/health'
|
||||||
|
preLoaderRoute: typeof ApiHealthRouteImport
|
||||||
|
parentRoute: typeof rootRouteImport
|
||||||
|
}
|
||||||
'/_authed/stats': {
|
'/_authed/stats': {
|
||||||
id: '/_authed/stats'
|
id: '/_authed/stats'
|
||||||
path: '/stats'
|
path: '/stats'
|
||||||
@@ -510,7 +595,7 @@ declare module '@tanstack/react-router' {
|
|||||||
'/_authed/tournaments/': {
|
'/_authed/tournaments/': {
|
||||||
id: '/_authed/tournaments/'
|
id: '/_authed/tournaments/'
|
||||||
path: '/tournaments'
|
path: '/tournaments'
|
||||||
fullPath: '/tournaments'
|
fullPath: '/tournaments/'
|
||||||
preLoaderRoute: typeof AuthedTournamentsIndexRouteImport
|
preLoaderRoute: typeof AuthedTournamentsIndexRouteImport
|
||||||
parentRoute: typeof AuthedRoute
|
parentRoute: typeof AuthedRoute
|
||||||
}
|
}
|
||||||
@@ -636,10 +721,24 @@ declare module '@tanstack/react-router' {
|
|||||||
'/_authed/admin/tournaments/': {
|
'/_authed/admin/tournaments/': {
|
||||||
id: '/_authed/admin/tournaments/'
|
id: '/_authed/admin/tournaments/'
|
||||||
path: '/tournaments'
|
path: '/tournaments'
|
||||||
fullPath: '/admin/tournaments'
|
fullPath: '/admin/tournaments/'
|
||||||
preLoaderRoute: typeof AuthedAdminTournamentsIndexRouteImport
|
preLoaderRoute: typeof AuthedAdminTournamentsIndexRouteImport
|
||||||
parentRoute: typeof AuthedAdminRoute
|
parentRoute: typeof AuthedAdminRoute
|
||||||
}
|
}
|
||||||
|
'/_authed/tournaments/$id/predictions': {
|
||||||
|
id: '/_authed/tournaments/$id/predictions'
|
||||||
|
path: '/tournaments/$id/predictions'
|
||||||
|
fullPath: '/tournaments/$id/predictions'
|
||||||
|
preLoaderRoute: typeof AuthedTournamentsIdPredictionsRouteImport
|
||||||
|
parentRoute: typeof AuthedRoute
|
||||||
|
}
|
||||||
|
'/_authed/tournaments/$id/groups': {
|
||||||
|
id: '/_authed/tournaments/$id/groups'
|
||||||
|
path: '/tournaments/$id/groups'
|
||||||
|
fullPath: '/tournaments/$id/groups'
|
||||||
|
preLoaderRoute: typeof AuthedTournamentsIdGroupsRouteImport
|
||||||
|
parentRoute: typeof AuthedRoute
|
||||||
|
}
|
||||||
'/_authed/tournaments/$id/bracket': {
|
'/_authed/tournaments/$id/bracket': {
|
||||||
id: '/_authed/tournaments/$id/bracket'
|
id: '/_authed/tournaments/$id/bracket'
|
||||||
path: '/tournaments/$id/bracket'
|
path: '/tournaments/$id/bracket'
|
||||||
@@ -650,7 +749,7 @@ declare module '@tanstack/react-router' {
|
|||||||
'/_authed/admin/tournaments/$id/': {
|
'/_authed/admin/tournaments/$id/': {
|
||||||
id: '/_authed/admin/tournaments/$id/'
|
id: '/_authed/admin/tournaments/$id/'
|
||||||
path: '/tournaments/$id'
|
path: '/tournaments/$id'
|
||||||
fullPath: '/admin/tournaments/$id'
|
fullPath: '/admin/tournaments/$id/'
|
||||||
preLoaderRoute: typeof AuthedAdminTournamentsIdIndexRouteImport
|
preLoaderRoute: typeof AuthedAdminTournamentsIdIndexRouteImport
|
||||||
parentRoute: typeof AuthedAdminRoute
|
parentRoute: typeof AuthedAdminRoute
|
||||||
}
|
}
|
||||||
@@ -661,6 +760,20 @@ declare module '@tanstack/react-router' {
|
|||||||
preLoaderRoute: typeof ApiFilesCollectionRecordIdFileRouteImport
|
preLoaderRoute: typeof ApiFilesCollectionRecordIdFileRouteImport
|
||||||
parentRoute: typeof rootRouteImport
|
parentRoute: typeof rootRouteImport
|
||||||
}
|
}
|
||||||
|
'/_authed/tournaments/$id/predictions_/make': {
|
||||||
|
id: '/_authed/tournaments/$id/predictions_/make'
|
||||||
|
path: '/tournaments/$id/predictions/make'
|
||||||
|
fullPath: '/tournaments/$id/predictions/make'
|
||||||
|
preLoaderRoute: typeof AuthedTournamentsIdPredictionsMakeRouteImport
|
||||||
|
parentRoute: typeof AuthedRoute
|
||||||
|
}
|
||||||
|
'/_authed/tournaments/$id/predictions_/$playerId': {
|
||||||
|
id: '/_authed/tournaments/$id/predictions_/$playerId'
|
||||||
|
path: '/tournaments/$id/predictions/$playerId'
|
||||||
|
fullPath: '/tournaments/$id/predictions/$playerId'
|
||||||
|
preLoaderRoute: typeof AuthedTournamentsIdPredictionsPlayerIdRouteImport
|
||||||
|
parentRoute: typeof AuthedRoute
|
||||||
|
}
|
||||||
'/_authed/admin/tournaments/run/$id': {
|
'/_authed/admin/tournaments/run/$id': {
|
||||||
id: '/_authed/admin/tournaments/run/$id'
|
id: '/_authed/admin/tournaments/run/$id'
|
||||||
path: '/tournaments/run/$id'
|
path: '/tournaments/run/$id'
|
||||||
@@ -675,6 +788,13 @@ declare module '@tanstack/react-router' {
|
|||||||
preLoaderRoute: typeof AuthedAdminTournamentsIdTeamsRouteImport
|
preLoaderRoute: typeof AuthedAdminTournamentsIdTeamsRouteImport
|
||||||
parentRoute: typeof AuthedAdminRoute
|
parentRoute: typeof AuthedAdminRoute
|
||||||
}
|
}
|
||||||
|
'/_authed/admin/tournaments/$id/assign-partners': {
|
||||||
|
id: '/_authed/admin/tournaments/$id/assign-partners'
|
||||||
|
path: '/tournaments/$id/assign-partners'
|
||||||
|
fullPath: '/admin/tournaments/$id/assign-partners'
|
||||||
|
preLoaderRoute: typeof AuthedAdminTournamentsIdAssignPartnersRouteImport
|
||||||
|
parentRoute: typeof AuthedAdminRoute
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -684,6 +804,7 @@ interface AuthedAdminRouteChildren {
|
|||||||
AuthedAdminPreviewRoute: typeof AuthedAdminPreviewRoute
|
AuthedAdminPreviewRoute: typeof AuthedAdminPreviewRoute
|
||||||
AuthedAdminIndexRoute: typeof AuthedAdminIndexRoute
|
AuthedAdminIndexRoute: typeof AuthedAdminIndexRoute
|
||||||
AuthedAdminTournamentsIndexRoute: typeof AuthedAdminTournamentsIndexRoute
|
AuthedAdminTournamentsIndexRoute: typeof AuthedAdminTournamentsIndexRoute
|
||||||
|
AuthedAdminTournamentsIdAssignPartnersRoute: typeof AuthedAdminTournamentsIdAssignPartnersRoute
|
||||||
AuthedAdminTournamentsIdTeamsRoute: typeof AuthedAdminTournamentsIdTeamsRoute
|
AuthedAdminTournamentsIdTeamsRoute: typeof AuthedAdminTournamentsIdTeamsRoute
|
||||||
AuthedAdminTournamentsRunIdRoute: typeof AuthedAdminTournamentsRunIdRoute
|
AuthedAdminTournamentsRunIdRoute: typeof AuthedAdminTournamentsRunIdRoute
|
||||||
AuthedAdminTournamentsIdIndexRoute: typeof AuthedAdminTournamentsIdIndexRoute
|
AuthedAdminTournamentsIdIndexRoute: typeof AuthedAdminTournamentsIdIndexRoute
|
||||||
@@ -695,6 +816,8 @@ const AuthedAdminRouteChildren: AuthedAdminRouteChildren = {
|
|||||||
AuthedAdminPreviewRoute: AuthedAdminPreviewRoute,
|
AuthedAdminPreviewRoute: AuthedAdminPreviewRoute,
|
||||||
AuthedAdminIndexRoute: AuthedAdminIndexRoute,
|
AuthedAdminIndexRoute: AuthedAdminIndexRoute,
|
||||||
AuthedAdminTournamentsIndexRoute: AuthedAdminTournamentsIndexRoute,
|
AuthedAdminTournamentsIndexRoute: AuthedAdminTournamentsIndexRoute,
|
||||||
|
AuthedAdminTournamentsIdAssignPartnersRoute:
|
||||||
|
AuthedAdminTournamentsIdAssignPartnersRoute,
|
||||||
AuthedAdminTournamentsIdTeamsRoute: AuthedAdminTournamentsIdTeamsRoute,
|
AuthedAdminTournamentsIdTeamsRoute: AuthedAdminTournamentsIdTeamsRoute,
|
||||||
AuthedAdminTournamentsRunIdRoute: AuthedAdminTournamentsRunIdRoute,
|
AuthedAdminTournamentsRunIdRoute: AuthedAdminTournamentsRunIdRoute,
|
||||||
AuthedAdminTournamentsIdIndexRoute: AuthedAdminTournamentsIdIndexRoute,
|
AuthedAdminTournamentsIdIndexRoute: AuthedAdminTournamentsIdIndexRoute,
|
||||||
@@ -715,6 +838,10 @@ interface AuthedRouteChildren {
|
|||||||
AuthedTournamentsTournamentIdRoute: typeof AuthedTournamentsTournamentIdRoute
|
AuthedTournamentsTournamentIdRoute: typeof AuthedTournamentsTournamentIdRoute
|
||||||
AuthedTournamentsIndexRoute: typeof AuthedTournamentsIndexRoute
|
AuthedTournamentsIndexRoute: typeof AuthedTournamentsIndexRoute
|
||||||
AuthedTournamentsIdBracketRoute: typeof AuthedTournamentsIdBracketRoute
|
AuthedTournamentsIdBracketRoute: typeof AuthedTournamentsIdBracketRoute
|
||||||
|
AuthedTournamentsIdGroupsRoute: typeof AuthedTournamentsIdGroupsRoute
|
||||||
|
AuthedTournamentsIdPredictionsRoute: typeof AuthedTournamentsIdPredictionsRoute
|
||||||
|
AuthedTournamentsIdPredictionsPlayerIdRoute: typeof AuthedTournamentsIdPredictionsPlayerIdRoute
|
||||||
|
AuthedTournamentsIdPredictionsMakeRoute: typeof AuthedTournamentsIdPredictionsMakeRoute
|
||||||
}
|
}
|
||||||
|
|
||||||
const AuthedRouteChildren: AuthedRouteChildren = {
|
const AuthedRouteChildren: AuthedRouteChildren = {
|
||||||
@@ -728,6 +855,12 @@ const AuthedRouteChildren: AuthedRouteChildren = {
|
|||||||
AuthedTournamentsTournamentIdRoute: AuthedTournamentsTournamentIdRoute,
|
AuthedTournamentsTournamentIdRoute: AuthedTournamentsTournamentIdRoute,
|
||||||
AuthedTournamentsIndexRoute: AuthedTournamentsIndexRoute,
|
AuthedTournamentsIndexRoute: AuthedTournamentsIndexRoute,
|
||||||
AuthedTournamentsIdBracketRoute: AuthedTournamentsIdBracketRoute,
|
AuthedTournamentsIdBracketRoute: AuthedTournamentsIdBracketRoute,
|
||||||
|
AuthedTournamentsIdGroupsRoute: AuthedTournamentsIdGroupsRoute,
|
||||||
|
AuthedTournamentsIdPredictionsRoute: AuthedTournamentsIdPredictionsRoute,
|
||||||
|
AuthedTournamentsIdPredictionsPlayerIdRoute:
|
||||||
|
AuthedTournamentsIdPredictionsPlayerIdRoute,
|
||||||
|
AuthedTournamentsIdPredictionsMakeRoute:
|
||||||
|
AuthedTournamentsIdPredictionsMakeRoute,
|
||||||
}
|
}
|
||||||
|
|
||||||
const AuthedRouteWithChildren =
|
const AuthedRouteWithChildren =
|
||||||
@@ -738,6 +871,7 @@ const rootRouteChildren: RootRouteChildren = {
|
|||||||
LoginRoute: LoginRoute,
|
LoginRoute: LoginRoute,
|
||||||
LogoutRoute: LogoutRoute,
|
LogoutRoute: LogoutRoute,
|
||||||
RefreshSessionRoute: RefreshSessionRoute,
|
RefreshSessionRoute: RefreshSessionRoute,
|
||||||
|
ApiHealthRoute: ApiHealthRoute,
|
||||||
ApiAuthSplatRoute: ApiAuthSplatRoute,
|
ApiAuthSplatRoute: ApiAuthSplatRoute,
|
||||||
ApiEventsSplatRoute: ApiEventsSplatRoute,
|
ApiEventsSplatRoute: ApiEventsSplatRoute,
|
||||||
ApiSpotifyCallbackRoute: ApiSpotifyCallbackRoute,
|
ApiSpotifyCallbackRoute: ApiSpotifyCallbackRoute,
|
||||||
|
|||||||
@@ -29,9 +29,8 @@ export function getRouter() {
|
|||||||
fullWidth: false,
|
fullWidth: false,
|
||||||
},
|
},
|
||||||
defaultPreload: "intent",
|
defaultPreload: "intent",
|
||||||
|
defaultPreloadStaleTime: 60_000,
|
||||||
defaultErrorComponent: DefaultCatchBoundary,
|
defaultErrorComponent: DefaultCatchBoundary,
|
||||||
scrollRestoration: true,
|
|
||||||
defaultViewTransition: false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
setupRouterSsrQueryIntegration({
|
setupRouterSsrQueryIntegration({
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
Outlet,
|
Outlet,
|
||||||
Scripts,
|
Scripts,
|
||||||
createRootRouteWithContext,
|
createRootRouteWithContext,
|
||||||
|
isRedirect,
|
||||||
} from "@tanstack/react-router";
|
} from "@tanstack/react-router";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { DefaultCatchBoundary } from "@/components/DefaultCatchBoundary";
|
import { DefaultCatchBoundary } from "@/components/DefaultCatchBoundary";
|
||||||
@@ -11,11 +12,14 @@ import { type QueryClient } from "@tanstack/react-query";
|
|||||||
import { ensureSuperTokensFrontend } from "@/lib/supertokens/client";
|
import { ensureSuperTokensFrontend } from "@/lib/supertokens/client";
|
||||||
import { AuthContextType } from "@/contexts/auth-context";
|
import { AuthContextType } from "@/contexts/auth-context";
|
||||||
import Providers from "@/features/core/components/providers";
|
import Providers from "@/features/core/components/providers";
|
||||||
|
import { SessionMonitor } from "@/components/session-monitor";
|
||||||
|
import { IOSInstallPrompt } from "@/components/ios-install-prompt";
|
||||||
import { ColorSchemeScript, mantineHtmlProps } from "@mantine/core";
|
import { ColorSchemeScript, mantineHtmlProps } from "@mantine/core";
|
||||||
import { HeaderConfig } from "@/features/core/types/header-config";
|
import { HeaderConfig } from "@/features/core/types/header-config";
|
||||||
import { playerQueries } from "@/features/players/queries";
|
import { playerQueries } from "@/features/players/queries";
|
||||||
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||||
import FullScreenLoader from "@/components/full-screen-loader";
|
import FullScreenLoader from "@/components/full-screen-loader";
|
||||||
|
import { CHROME_COLORS } from "@/lib/mantine/theme-colors";
|
||||||
import mantineCssUrl from '@mantine/core/styles.css?url'
|
import mantineCssUrl from '@mantine/core/styles.css?url'
|
||||||
import mantineDatesCssUrl from '@mantine/dates/styles.css?url'
|
import mantineDatesCssUrl from '@mantine/dates/styles.css?url'
|
||||||
import mantineCarouselCssUrl from '@mantine/carousel/styles.css?url'
|
import mantineCarouselCssUrl from '@mantine/carousel/styles.css?url'
|
||||||
@@ -38,32 +42,46 @@ export const Route = createRootRouteWithContext<{
|
|||||||
{
|
{
|
||||||
name: "viewport",
|
name: "viewport",
|
||||||
content:
|
content:
|
||||||
"width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, interactive-widget=resizes-content",
|
"width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, interactive-widget=resizes-content, viewport-fit=cover",
|
||||||
},
|
},
|
||||||
{ property: 'og:title', content: 'FLXN IX' },
|
{ name: 'description', content: 'Amicus meus madidus' },
|
||||||
{ property: 'og:description', content: 'Register for FLXN IX and view FLXN stats' },
|
{ name: 'keywords', content: 'FLXN, beer pong, tournament, sports, statistics, pong' },
|
||||||
|
{ property: 'og:title', content: 'FLXN' },
|
||||||
|
{ property: 'og:description', content: 'Amicus meus madidus' },
|
||||||
{ property: 'og:url', content: 'https://flexxon.app' },
|
{ property: 'og:url', content: 'https://flexxon.app' },
|
||||||
{ property: 'og:type', content: 'website' },
|
{ property: 'og:type', content: 'website' },
|
||||||
{ property: 'og:site_name', content: 'FLXN IX' },
|
{ property: 'og:site_name', content: 'FLXN' },
|
||||||
{ property: 'og:image', content: 'https://flexxon.app/favicon.png' },
|
{ property: 'og:image', content: 'https://flexxon.app/favicon.png' },
|
||||||
|
{ property: 'og:image:width', content: '512' },
|
||||||
|
{ property: 'og:image:height', content: '512' },
|
||||||
|
{ property: 'og:image:alt', content: 'FLXN logo' },
|
||||||
|
{ property: 'og:locale', content: 'en_US' },
|
||||||
|
{ name: 'twitter:card', content: 'summary' },
|
||||||
|
{ name: 'twitter:title', content: 'FLXN' },
|
||||||
|
{ name: 'twitter:description', content: 'Amicus meus madidus' },
|
||||||
|
{ name: 'twitter:image', content: 'https://flexxon.app/favicon.png' },
|
||||||
|
{ name: 'mobile-web-app-capable', content: 'yes' },
|
||||||
|
{ name: 'apple-mobile-web-app-capable', content: 'yes' },
|
||||||
|
{ name: 'apple-mobile-web-app-status-bar-style', content: 'default' },
|
||||||
|
{ name: 'apple-mobile-web-app-title', content: 'FLXN' },
|
||||||
],
|
],
|
||||||
links: [
|
links: [
|
||||||
{
|
{
|
||||||
rel: "apple-touch-icon",
|
rel: "apple-touch-icon",
|
||||||
sizes: "180x180",
|
sizes: "180x180",
|
||||||
href: "/favicon.png",
|
href: "/apple-touch-icon.png",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
rel: "icon",
|
rel: "icon",
|
||||||
type: "image/png",
|
type: "image/png",
|
||||||
sizes: "32x32",
|
sizes: "32x32",
|
||||||
href: "/favicon.png",
|
href: "/favicon-32x32.png",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
rel: "icon",
|
rel: "icon",
|
||||||
type: "image/png",
|
type: "image/png",
|
||||||
sizes: "16x16",
|
sizes: "16x16",
|
||||||
href: "/favicon.png",
|
href: "/favicon-16x16.png",
|
||||||
},
|
},
|
||||||
{ rel: "manifest", href: "/site.webmanifest" },
|
{ rel: "manifest", href: "/site.webmanifest" },
|
||||||
{ rel: "icon", href: "/favicon.ico" },
|
{ rel: "icon", href: "/favicon.ico" },
|
||||||
@@ -95,23 +113,37 @@ export const Route = createRootRouteWithContext<{
|
|||||||
component: RootComponent,
|
component: RootComponent,
|
||||||
notFoundComponent: () => <Navigate to="/" />,
|
notFoundComponent: () => <Navigate to="/" />,
|
||||||
beforeLoad: async ({ context, location }) => {
|
beforeLoad: async ({ context, location }) => {
|
||||||
// Skip auth check for refresh-session route to avoid infinite loops
|
const publicRoutes = ['/login', '/logout', '/refresh-session'];
|
||||||
if (location.pathname === '/refresh-session') {
|
if (publicRoutes.some(route => location.pathname.startsWith(route))) {
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (location.pathname === '/login' || location.pathname === '/logout') {
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// https://github.com/TanStack/router/discussions/3531
|
|
||||||
const auth = await ensureServerQueryData(
|
const auth = await ensureServerQueryData(
|
||||||
context.queryClient,
|
context.queryClient,
|
||||||
playerQueries.auth()
|
playerQueries.auth()
|
||||||
);
|
);
|
||||||
return { auth };
|
return { auth };
|
||||||
} catch (error) {
|
} catch (error: any) {
|
||||||
|
if (isRedirect(error) || error instanceof Response) throw error;
|
||||||
|
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
const { doesSessionExist, attemptRefreshingSession } = await import('supertokens-web-js/recipe/session');
|
||||||
|
|
||||||
|
const sessionExists = await doesSessionExist();
|
||||||
|
if (sessionExists) {
|
||||||
|
try {
|
||||||
|
await attemptRefreshingSession();
|
||||||
|
const auth = await ensureServerQueryData(
|
||||||
|
context.queryClient,
|
||||||
|
playerQueries.auth()
|
||||||
|
);
|
||||||
|
return { auth };
|
||||||
|
} catch {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -121,11 +153,16 @@ export const Route = createRootRouteWithContext<{
|
|||||||
function RootComponent() {
|
function RootComponent() {
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
ensureSuperTokensFrontend();
|
ensureSuperTokensFrontend();
|
||||||
|
if (import.meta.env.PROD && 'serviceWorker' in navigator) {
|
||||||
|
navigator.serviceWorker.register('/sw.js').catch(() => {});
|
||||||
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RootDocument>
|
<RootDocument>
|
||||||
<Providers>
|
<Providers>
|
||||||
|
<SessionMonitor />
|
||||||
|
<IOSInstallPrompt />
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</Providers>
|
</Providers>
|
||||||
</RootDocument>
|
</RootDocument>
|
||||||
@@ -145,6 +182,16 @@ function RootDocument({ children }: { children: React.ReactNode }) {
|
|||||||
>
|
>
|
||||||
<head>
|
<head>
|
||||||
<HeadContent />
|
<HeadContent />
|
||||||
|
<meta
|
||||||
|
name="theme-color"
|
||||||
|
media="(prefers-color-scheme: light)"
|
||||||
|
content={CHROME_COLORS.light.base}
|
||||||
|
/>
|
||||||
|
<meta
|
||||||
|
name="theme-color"
|
||||||
|
media="(prefers-color-scheme: dark)"
|
||||||
|
content={CHROME_COLORS.dark.base}
|
||||||
|
/>
|
||||||
<ColorSchemeScript />
|
<ColorSchemeScript />
|
||||||
<link rel="stylesheet" href="/styles.css" />
|
<link rel="stylesheet" href="/styles.css" />
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { redirect, createFileRoute, Outlet } from "@tanstack/react-router";
|
import { redirect, createFileRoute, Outlet } from "@tanstack/react-router";
|
||||||
import Layout from "@/features/core/components/layout";
|
import Layout from "@/features/core/components/layout";
|
||||||
import { useServerEvents } from "@/hooks/use-server-events";
|
import { useServerEvents } from "@/hooks/use-server-events";
|
||||||
import { Flex, Loader } from "@mantine/core";
|
import { Group, Skeleton, Stack } from "@mantine/core";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_authed")({
|
export const Route = createFileRoute("/_authed")({
|
||||||
beforeLoad: ({ context }) => {
|
beforeLoad: ({ context }) => {
|
||||||
@@ -26,9 +26,21 @@ export const Route = createFileRoute("/_authed")({
|
|||||||
},
|
},
|
||||||
pendingComponent: () => (
|
pendingComponent: () => (
|
||||||
<Layout>
|
<Layout>
|
||||||
<Flex w='100%' h="40dvh" justify="center" align="flex-end">
|
<Stack gap="md" p="md" w="100%">
|
||||||
<Loader size='xl' />
|
<Group gap="sm">
|
||||||
</Flex>
|
<Skeleton height={40} width={40} radius="sm" />
|
||||||
|
<Skeleton height={24} width="45%" radius="sm" />
|
||||||
|
</Group>
|
||||||
|
{Array.from({ length: 4 }).map((_, index) => (
|
||||||
|
<Skeleton
|
||||||
|
key={`authed-pending-${index}`}
|
||||||
|
height={96}
|
||||||
|
w="100%"
|
||||||
|
radius="md"
|
||||||
|
style={{ opacity: Math.max(1 - index * 0.18, 0.3) }}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
</Layout>
|
</Layout>
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import { createFileRoute } from "@tanstack/react-router";
|
|||||||
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||||
import { ActivitiesTable, activityQueries } from "@/features/activities";
|
import { ActivitiesTable, activityQueries } from "@/features/activities";
|
||||||
import { PlayersActivityTable, playerQueries } from "@/features/players";
|
import { PlayersActivityTable, playerQueries } from "@/features/players";
|
||||||
import { Tabs } from "@mantine/core";
|
import { Box, Divider, Group, Skeleton, Stack, Tabs } from "@mantine/core";
|
||||||
import { useState } from "react";
|
import { Suspense, useState } from "react";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_authed/admin/activities")({
|
export const Route = createFileRoute("/_authed/admin/activities")({
|
||||||
component: Stats,
|
component: Stats,
|
||||||
@@ -23,6 +23,30 @@ export const Route = createFileRoute("/_authed/admin/activities")({
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function ActivityRowsSkeleton({ withSearch = false }: { withSearch?: boolean }) {
|
||||||
|
return (
|
||||||
|
<Stack gap={0}>
|
||||||
|
{withSearch && (
|
||||||
|
<Box px="md" pb="sm">
|
||||||
|
<Skeleton height={42} radius="sm" />
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
{Array.from({ length: 8 }).map((_, index) => (
|
||||||
|
<div key={`activity-skeleton-${index}`} style={{ opacity: Math.max(1 - index * 0.1, 0.35) }}>
|
||||||
|
<Group p="md" wrap="nowrap" w="100%" justify="space-between">
|
||||||
|
<Stack gap={6}>
|
||||||
|
<Skeleton height={14} width={160} radius="sm" />
|
||||||
|
<Skeleton height={10} width={100} radius="sm" />
|
||||||
|
</Stack>
|
||||||
|
<Skeleton height={10} width={60} radius="sm" />
|
||||||
|
</Group>
|
||||||
|
<Divider />
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function Stats() {
|
function Stats() {
|
||||||
const [activeTab, setActiveTab] = useState<string | null>("server-functions");
|
const [activeTab, setActiveTab] = useState<string | null>("server-functions");
|
||||||
|
|
||||||
@@ -34,11 +58,15 @@ function Stats() {
|
|||||||
</Tabs.List>
|
</Tabs.List>
|
||||||
|
|
||||||
<Tabs.Panel value="server-functions">
|
<Tabs.Panel value="server-functions">
|
||||||
|
<Suspense fallback={<ActivityRowsSkeleton withSearch />}>
|
||||||
<ActivitiesTable />
|
<ActivitiesTable />
|
||||||
|
</Suspense>
|
||||||
</Tabs.Panel>
|
</Tabs.Panel>
|
||||||
|
|
||||||
<Tabs.Panel value="player-activity">
|
<Tabs.Panel value="player-activity">
|
||||||
|
<Suspense fallback={<ActivityRowsSkeleton />}>
|
||||||
<PlayersActivityTable />
|
<PlayersActivityTable />
|
||||||
|
</Suspense>
|
||||||
</Tabs.Panel>
|
</Tabs.Panel>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,182 @@
|
|||||||
|
import { createFileRoute, redirect, useNavigate } from "@tanstack/react-router";
|
||||||
|
import { tournamentQueries, useFreeAgents, useTournament } from "@/features/tournaments/queries";
|
||||||
|
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||||
|
import { Stack, Text, Button, Alert, LoadingOverlay, Group, Skeleton } from "@mantine/core";
|
||||||
|
import { useState } from "react";
|
||||||
|
import useGenerateRandomTeams from "@/features/tournaments/hooks/use-generate-random-teams";
|
||||||
|
import useConfirmTeamAssignments from "@/features/tournaments/hooks/use-confirm-team-assignments";
|
||||||
|
import TeamAssignmentPreview from "@/features/tournaments/components/team-assignment-preview";
|
||||||
|
import { WarningCircleIcon, ShuffleIcon, CheckCircleIcon } from "@phosphor-icons/react";
|
||||||
|
import { PlayerInfo } from "@/features/players/types";
|
||||||
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
|
|
||||||
|
export const Route = createFileRoute("/_authed/admin/tournaments/$id/assign-partners")({
|
||||||
|
beforeLoad: async ({ context, params }) => {
|
||||||
|
const { queryClient } = context;
|
||||||
|
const tournament = await ensureServerQueryData(
|
||||||
|
queryClient,
|
||||||
|
tournamentQueries.details(params.id)
|
||||||
|
);
|
||||||
|
if (!tournament) throw redirect({ to: "/admin/tournaments" });
|
||||||
|
return { tournament };
|
||||||
|
},
|
||||||
|
loader: ({ context }) => ({
|
||||||
|
header: {
|
||||||
|
withBackButton: true,
|
||||||
|
title: `Manage ${context.tournament.name}`,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
component: RouteComponent,
|
||||||
|
pendingComponent: AssignPartnersPending,
|
||||||
|
});
|
||||||
|
|
||||||
|
function AssignPartnersPending() {
|
||||||
|
return (
|
||||||
|
<Stack gap="lg">
|
||||||
|
<Stack gap="xs">
|
||||||
|
<Group gap="xs" align="baseline">
|
||||||
|
<Skeleton height={28} width={36} radius="sm" />
|
||||||
|
<Skeleton height={14} width={110} radius="sm" />
|
||||||
|
</Group>
|
||||||
|
<Skeleton height={36} w="100%" radius="sm" style={{ opacity: 0.7 }} />
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TeamAssignment {
|
||||||
|
player1: PlayerInfo;
|
||||||
|
player2: PlayerInfo;
|
||||||
|
teamName: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
function RouteComponent() {
|
||||||
|
const { id } = Route.useParams();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const { data: freeAgents } = useFreeAgents(id);
|
||||||
|
const [assignments, setAssignments] = useState<TeamAssignment[] | null>(null);
|
||||||
|
const [currentSeed, setCurrentSeed] = useState<number | undefined>(undefined);
|
||||||
|
|
||||||
|
const generateMutation = useGenerateRandomTeams();
|
||||||
|
const confirmMutation = useConfirmTeamAssignments();
|
||||||
|
|
||||||
|
const hasOddPlayers = freeAgents.length % 2 !== 0;
|
||||||
|
const hasEnoughPlayers = freeAgents.length >= 2;
|
||||||
|
|
||||||
|
const handleGenerate = () => {
|
||||||
|
generateMutation.mutate(
|
||||||
|
{ data: { tournamentId: id, seed: currentSeed } },
|
||||||
|
{
|
||||||
|
onSuccess: (result) => {
|
||||||
|
setAssignments(result.assignments);
|
||||||
|
setCurrentSeed(result.seed);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleReroll = () => {
|
||||||
|
if (currentSeed === undefined) return;
|
||||||
|
generateMutation.mutate(
|
||||||
|
{ data: { tournamentId: id, seed: currentSeed + 1 } },
|
||||||
|
{
|
||||||
|
onSuccess: (result) => {
|
||||||
|
setAssignments(result.assignments);
|
||||||
|
setCurrentSeed(result.seed);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleConfirm = () => {
|
||||||
|
if (!assignments) return;
|
||||||
|
|
||||||
|
const formattedAssignments = assignments.map((a) => ({
|
||||||
|
player1Id: a.player1.id,
|
||||||
|
player2Id: a.player2.id,
|
||||||
|
teamName: a.teamName,
|
||||||
|
}));
|
||||||
|
|
||||||
|
confirmMutation.mutate(
|
||||||
|
{ data: { tournamentId: id, assignments: formattedAssignments } },
|
||||||
|
{
|
||||||
|
onSuccess: () => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: tournamentQueries.details(id).queryKey });
|
||||||
|
queryClient.invalidateQueries({ queryKey: tournamentQueries.free_agents(id).queryKey });
|
||||||
|
navigate({ to: "/admin/tournaments/$id", params: { id } });
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack gap="lg" pos="relative">
|
||||||
|
<LoadingOverlay visible={confirmMutation.isPending} />
|
||||||
|
|
||||||
|
<Stack gap="xs">
|
||||||
|
<Group gap="xs" align="baseline">
|
||||||
|
<Text size="xl" fw={700}>
|
||||||
|
{freeAgents.length}
|
||||||
|
</Text>
|
||||||
|
<Text size="sm" c="dimmed">
|
||||||
|
{freeAgents.length === 1 ? "player enrolled" : "players enrolled"}
|
||||||
|
</Text>
|
||||||
|
</Group>
|
||||||
|
|
||||||
|
{!hasEnoughPlayers && (
|
||||||
|
<Alert color="yellow" icon={<WarningCircleIcon size={16} />}>
|
||||||
|
Need at least 2 players to create teams
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{hasOddPlayers && (
|
||||||
|
<Alert color="red" icon={<WarningCircleIcon size={16} />}>
|
||||||
|
Cannot create teams with an odd number of players. Please have one player unenroll.
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{!assignments && hasEnoughPlayers && !hasOddPlayers && (
|
||||||
|
<Button
|
||||||
|
leftSection={<ShuffleIcon size={18} />}
|
||||||
|
onClick={handleGenerate}
|
||||||
|
loading={generateMutation.isPending}
|
||||||
|
>
|
||||||
|
Generate Random Pairings
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
{assignments && (
|
||||||
|
<Stack gap="md">
|
||||||
|
<Group justify="space-between" align="center">
|
||||||
|
<Text size="lg" fw={600}>
|
||||||
|
Partner Assignments
|
||||||
|
</Text>
|
||||||
|
<Group gap="sm">
|
||||||
|
<Button
|
||||||
|
variant="subtle"
|
||||||
|
leftSection={<ShuffleIcon size={16} />}
|
||||||
|
onClick={handleReroll}
|
||||||
|
loading={generateMutation.isPending}
|
||||||
|
size="sm"
|
||||||
|
>
|
||||||
|
Re-roll
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
leftSection={<CheckCircleIcon size={18} />}
|
||||||
|
onClick={handleConfirm}
|
||||||
|
loading={confirmMutation.isPending}
|
||||||
|
size="sm"
|
||||||
|
>
|
||||||
|
Confirm & Create Teams
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
|
||||||
|
<TeamAssignmentPreview assignments={assignments} />
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ import { createFileRoute, redirect } from "@tanstack/react-router";
|
|||||||
import { tournamentQueries } from "@/features/tournaments/queries";
|
import { tournamentQueries } from "@/features/tournaments/queries";
|
||||||
import ManageTournament from "@/features/tournaments/components/manage-tournament";
|
import ManageTournament from "@/features/tournaments/components/manage-tournament";
|
||||||
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||||
|
import { Divider, Group, Skeleton, Stack } from "@mantine/core";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_authed/admin/tournaments/$id/")({
|
export const Route = createFileRoute("/_authed/admin/tournaments/$id/")({
|
||||||
beforeLoad: async ({ context, params }) => {
|
beforeLoad: async ({ context, params }) => {
|
||||||
@@ -23,8 +24,26 @@ export const Route = createFileRoute("/_authed/admin/tournaments/$id/")({
|
|||||||
withPadding: false,
|
withPadding: false,
|
||||||
}),
|
}),
|
||||||
component: RouteComponent,
|
component: RouteComponent,
|
||||||
|
pendingComponent: ManageTournamentPending,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function ManageTournamentPending() {
|
||||||
|
return (
|
||||||
|
<Stack gap={0}>
|
||||||
|
{Array.from({ length: 5 }).map((_, index) => (
|
||||||
|
<div key={`manage-tournament-skeleton-${index}`} style={{ opacity: Math.max(1 - index * 0.14, 0.4) }}>
|
||||||
|
<Group p="md" wrap="nowrap" w="100%">
|
||||||
|
<Skeleton height={20} width={20} radius="sm" />
|
||||||
|
<Skeleton height={16} width="45%" radius="sm" />
|
||||||
|
<Skeleton ml="auto" height={20} width={20} radius="sm" />
|
||||||
|
</Group>
|
||||||
|
<Divider />
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function RouteComponent() {
|
function RouteComponent() {
|
||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
return <ManageTournament tournamentId={id} />;
|
return <ManageTournament tournamentId={id} />;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { createFileRoute, redirect } from "@tanstack/react-router";
|
|||||||
import { tournamentQueries } from "@/features/tournaments/queries";
|
import { tournamentQueries } from "@/features/tournaments/queries";
|
||||||
import ManageTeams from "@/features/teams/components/manage-teams";
|
import ManageTeams from "@/features/teams/components/manage-teams";
|
||||||
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||||
|
import { Box, Divider, Group, Skeleton, Stack } from "@mantine/core";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_authed/admin/tournaments/$id/teams")({
|
export const Route = createFileRoute("/_authed/admin/tournaments/$id/teams")({
|
||||||
beforeLoad: async ({ context, params }) => {
|
beforeLoad: async ({ context, params }) => {
|
||||||
@@ -23,8 +24,37 @@ export const Route = createFileRoute("/_authed/admin/tournaments/$id/teams")({
|
|||||||
withPadding: false,
|
withPadding: false,
|
||||||
}),
|
}),
|
||||||
component: RouteComponent,
|
component: RouteComponent,
|
||||||
|
pendingComponent: ManageTeamsPending,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function ManageTeamsPending() {
|
||||||
|
return (
|
||||||
|
<Stack gap="xs">
|
||||||
|
<Box px="md">
|
||||||
|
<Skeleton height={42} radius="sm" />
|
||||||
|
</Box>
|
||||||
|
<Box px="md">
|
||||||
|
<Skeleton height={12} width={90} radius="sm" />
|
||||||
|
</Box>
|
||||||
|
<Stack gap={0}>
|
||||||
|
{Array.from({ length: 8 }).map((_, index) => (
|
||||||
|
<div key={`manage-teams-skeleton-${index}`} style={{ opacity: Math.max(1 - index * 0.1, 0.35) }}>
|
||||||
|
<Group p="xs" wrap="nowrap" w="100%">
|
||||||
|
<Skeleton height={40} width={40} radius="sm" />
|
||||||
|
<Skeleton height={16} width="45%" radius="sm" />
|
||||||
|
<Stack ml="auto" gap={6} align="flex-end">
|
||||||
|
<Skeleton height={10} width={90} radius="sm" />
|
||||||
|
<Skeleton height={10} width={70} radius="sm" />
|
||||||
|
</Stack>
|
||||||
|
</Group>
|
||||||
|
<Divider />
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function RouteComponent() {
|
function RouteComponent() {
|
||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
const { tournament } = Route.useRouteContext();
|
const { tournament } = Route.useRouteContext();
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
import ManageTournaments from "@/features/admin/components/manage-tournaments";
|
import ManageTournaments from "@/features/admin/components/manage-tournaments";
|
||||||
import { tournamentQueries } from "@/features/tournaments/queries";
|
import { tournamentQueries } from "@/features/tournaments/queries";
|
||||||
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||||
|
import { Divider, Group, Skeleton, Stack } from "@mantine/core";
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
|
import { Suspense } from "react";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_authed/admin/tournaments/")({
|
export const Route = createFileRoute("/_authed/admin/tournaments/")({
|
||||||
beforeLoad: async ({ context }) => {
|
beforeLoad: ({ context }) => {
|
||||||
const { queryClient } = context;
|
const { queryClient } = context;
|
||||||
await prefetchServerQuery(queryClient, tournamentQueries.list());
|
prefetchServerQuery(queryClient, tournamentQueries.list());
|
||||||
},
|
},
|
||||||
loader: () => ({
|
loader: () => ({
|
||||||
header: {
|
header: {
|
||||||
@@ -19,6 +21,26 @@ export const Route = createFileRoute("/_authed/admin/tournaments/")({
|
|||||||
component: RouteComponent,
|
component: RouteComponent,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function TournamentListSkeleton() {
|
||||||
|
return (
|
||||||
|
<Stack gap={0}>
|
||||||
|
{Array.from({ length: 6 }).map((_, index) => (
|
||||||
|
<div key={`manage-tournaments-skeleton-${index}`} style={{ opacity: Math.max(1 - index * 0.12, 0.4) }}>
|
||||||
|
<Group p="md" wrap="nowrap" w="100%">
|
||||||
|
<Skeleton height={16} width="55%" radius="sm" />
|
||||||
|
<Skeleton ml="auto" height={20} width={20} radius="sm" />
|
||||||
|
</Group>
|
||||||
|
<Divider />
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function RouteComponent() {
|
function RouteComponent() {
|
||||||
return <ManageTournaments />;
|
return (
|
||||||
|
<Suspense fallback={<TournamentListSkeleton />}>
|
||||||
|
<ManageTournaments />
|
||||||
|
</Suspense>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import {
|
|||||||
} from "@/features/tournaments/queries";
|
} from "@/features/tournaments/queries";
|
||||||
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||||
import SeedTournament from "@/features/tournaments/components/seed-tournament";
|
import SeedTournament from "@/features/tournaments/components/seed-tournament";
|
||||||
import { Container } from "@mantine/core";
|
import SetupGroupStage from "@/features/tournaments/components/setup-group-stage";
|
||||||
|
import GroupStageView from "@/features/tournaments/components/group-stage-view";
|
||||||
|
import { Container, Stack, Divider, Title, Box, Card, Group, Skeleton, SimpleGrid } from "@mantine/core";
|
||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { BracketData } from "@/features/bracket/types";
|
import { BracketData } from "@/features/bracket/types";
|
||||||
import { Match } from "@/features/matches/types";
|
import { Match } from "@/features/matches/types";
|
||||||
@@ -35,14 +37,66 @@ export const Route = createFileRoute("/_authed/admin/tournaments/run/$id")({
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
component: RouteComponent,
|
component: RouteComponent,
|
||||||
|
pendingComponent: RunTournamentPending,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function RunTournamentPending() {
|
||||||
|
return (
|
||||||
|
<Container size="md" px={0}>
|
||||||
|
<Box p="md">
|
||||||
|
<Stack gap="md">
|
||||||
|
<Group gap={0} grow mb="md">
|
||||||
|
{Array.from({ length: 4 }).map((_, index) => (
|
||||||
|
<Skeleton
|
||||||
|
key={`run-pending-tab-${index}`}
|
||||||
|
height={44}
|
||||||
|
radius="sm"
|
||||||
|
style={{ opacity: 0.85 - index * 0.1 }}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Group>
|
||||||
|
<Card withBorder radius="md" p={0}>
|
||||||
|
<Group justify="space-between" p="sm">
|
||||||
|
<Skeleton height={16} width={120} radius="sm" />
|
||||||
|
<Skeleton height={22} width={22} radius="xl" />
|
||||||
|
</Group>
|
||||||
|
</Card>
|
||||||
|
<SimpleGrid cols={{ base: 1, sm: 2, lg: 3 }} spacing="md">
|
||||||
|
{Array.from({ length: 6 }).map((_, index) => (
|
||||||
|
<Skeleton
|
||||||
|
key={`run-pending-match-${index}`}
|
||||||
|
height={100}
|
||||||
|
radius="md"
|
||||||
|
style={{ opacity: Math.max(1 - index * 0.12, 0.4) }}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</SimpleGrid>
|
||||||
|
</Stack>
|
||||||
|
</Box>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function RouteComponent() {
|
function RouteComponent() {
|
||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
const { data: tournament } = useTournament(id);
|
const { data: tournament } = useTournament(id);
|
||||||
const { roles } = useAuth();
|
const { roles } = useAuth();
|
||||||
const isAdmin = roles?.includes('Admin') || false;
|
const isAdmin = roles?.includes('Admin') || false;
|
||||||
|
|
||||||
|
const hasGroupStage = useMemo(() => {
|
||||||
|
return tournament.matches?.some((match) => match.round === -1) || false;
|
||||||
|
}, [tournament.matches]);
|
||||||
|
|
||||||
|
const hasKnockout = useMemo(() => {
|
||||||
|
return tournament.matches?.some((match) => match.round !== -1) || false;
|
||||||
|
}, [tournament.matches]);
|
||||||
|
|
||||||
|
const knockoutBracketPopulated = useMemo(() => {
|
||||||
|
return tournament.matches?.some((match) =>
|
||||||
|
match.round === 0 && match.lid >= 0 && (match.home || match.away)
|
||||||
|
) || false;
|
||||||
|
}, [tournament.matches]);
|
||||||
|
|
||||||
const bracket: BracketData = useMemo(() => {
|
const bracket: BracketData = useMemo(() => {
|
||||||
if (!tournament.matches || tournament.matches.length === 0) {
|
if (!tournament.matches || tournament.matches.length === 0) {
|
||||||
return { winners: [], losers: [] };
|
return { winners: [], losers: [] };
|
||||||
@@ -52,6 +106,7 @@ function RouteComponent() {
|
|||||||
const losersMap = new Map<number, Match[]>();
|
const losersMap = new Map<number, Match[]>();
|
||||||
|
|
||||||
tournament.matches
|
tournament.matches
|
||||||
|
.filter((match) => match.round !== -1)
|
||||||
.sort((a, b) => a.lid - b.lid)
|
.sort((a, b) => a.lid - b.lid)
|
||||||
.forEach((match) => {
|
.forEach((match) => {
|
||||||
if (!match.is_losers_bracket) {
|
if (!match.is_losers_bracket) {
|
||||||
@@ -79,14 +134,51 @@ function RouteComponent() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Container size="md" px={0}>
|
<Container size="md" px={0}>
|
||||||
{ isAdmin && <SpotifyControlsBar />}
|
{ isAdmin && !tournament.regional && <SpotifyControlsBar />}
|
||||||
{tournament.matches?.length ? (
|
{tournament.matches?.length ? (
|
||||||
<BracketView bracket={bracket} showControls />
|
hasGroupStage && hasKnockout ? (
|
||||||
|
<Stack gap="xl">
|
||||||
|
<GroupStageView
|
||||||
|
groups={tournament.groups || []}
|
||||||
|
matches={tournament.matches}
|
||||||
|
showControls
|
||||||
|
tournamentId={tournament.id}
|
||||||
|
hasKnockoutBracket={knockoutBracketPopulated}
|
||||||
|
isRegional={tournament.regional}
|
||||||
|
groupConfig={tournament.group_config}
|
||||||
|
/>
|
||||||
|
<Divider />
|
||||||
|
<div>
|
||||||
|
<Title order={3} ta="center" mb="md">Knockout Bracket</Title>
|
||||||
|
<BracketView bracket={bracket} showControls groupConfig={tournament.group_config} />
|
||||||
|
</div>
|
||||||
|
</Stack>
|
||||||
|
) : hasGroupStage ? (
|
||||||
|
<GroupStageView
|
||||||
|
groups={tournament.groups || []}
|
||||||
|
matches={tournament.matches}
|
||||||
|
showControls
|
||||||
|
tournamentId={tournament.id}
|
||||||
|
hasKnockoutBracket={knockoutBracketPopulated}
|
||||||
|
isRegional={tournament.regional}
|
||||||
|
groupConfig={tournament.group_config}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<BracketView bracket={bracket} showControls groupConfig={tournament.group_config} />
|
||||||
|
)
|
||||||
|
) : (
|
||||||
|
tournament.regional === true ? (
|
||||||
|
<SetupGroupStage
|
||||||
|
tournamentId={tournament.id}
|
||||||
|
teams={tournament.teams || []}
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
<SeedTournament
|
<SeedTournament
|
||||||
tournamentId={tournament.id}
|
tournamentId={tournament.id}
|
||||||
teams={tournament.teams || []}
|
teams={tournament.teams || []}
|
||||||
|
isRegional={tournament.regional}
|
||||||
/>
|
/>
|
||||||
|
)
|
||||||
)}
|
)}
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ function Stats() {
|
|||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</Group>
|
||||||
<Box style={{ opacity: isStale ? 0.6 : 1, transition: 'opacity 150ms' }}>
|
<Box style={{ opacity: isStale ? 0.6 : 1, transition: 'opacity 150ms' }}>
|
||||||
<Suspense key={deferredViewType} fallback={<PlayerStatsTableSkeleton hideFilters />}>
|
<Suspense fallback={<PlayerStatsTableSkeleton hideFilters />}>
|
||||||
<PlayerStatsTable viewType={deferredViewType} />
|
<PlayerStatsTable viewType={deferredViewType} />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ import {
|
|||||||
useTournament,
|
useTournament,
|
||||||
} from "@/features/tournaments/queries";
|
} from "@/features/tournaments/queries";
|
||||||
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||||
import SeedTournament from "@/features/tournaments/components/seed-tournament";
|
|
||||||
import { Container } from "@mantine/core";
|
import { Container } from "@mantine/core";
|
||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { BracketData } from "@/features/bracket/types";
|
import { BracketData } from "@/features/bracket/types";
|
||||||
import { Match } from "@/features/matches/types";
|
import { groupMatchesIntoBracket } from "@/features/bracket/utils/group";
|
||||||
import BracketView from "@/features/bracket/components/bracket-view";
|
import BracketView from "@/features/bracket/components/bracket-view";
|
||||||
|
import { BracketPending } from "@/features/bracket/components/bracket-pending";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_authed/tournaments/$id/bracket")({
|
export const Route = createFileRoute("/_authed/tournaments/$id/bracket")({
|
||||||
beforeLoad: async ({ context, params }) => {
|
beforeLoad: async ({ context, params }) => {
|
||||||
@@ -18,7 +18,7 @@ export const Route = createFileRoute("/_authed/tournaments/$id/bracket")({
|
|||||||
queryClient,
|
queryClient,
|
||||||
tournamentQueries.details(params.id)
|
tournamentQueries.details(params.id)
|
||||||
);
|
);
|
||||||
if (!tournament) throw redirect({ to: "/admin/tournaments" });
|
if (!tournament) throw redirect({ to: "/tournaments" });
|
||||||
return {
|
return {
|
||||||
tournament,
|
tournament,
|
||||||
};
|
};
|
||||||
@@ -26,56 +26,27 @@ export const Route = createFileRoute("/_authed/tournaments/$id/bracket")({
|
|||||||
loader: ({ context }) => ({
|
loader: ({ context }) => ({
|
||||||
fullWidth: true,
|
fullWidth: true,
|
||||||
withPadding: false,
|
withPadding: false,
|
||||||
showSpotifyPanel: true,
|
|
||||||
header: {
|
header: {
|
||||||
withBackButton: true,
|
withBackButton: true,
|
||||||
title: `${context.tournament.name}`,
|
title: `${context.tournament.name}`,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
component: RouteComponent,
|
component: RouteComponent,
|
||||||
|
pendingComponent: BracketPending,
|
||||||
});
|
});
|
||||||
|
|
||||||
function RouteComponent() {
|
function RouteComponent() {
|
||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
const { data: tournament } = useTournament(id);
|
const { data: tournament } = useTournament(id);
|
||||||
|
|
||||||
const bracket: BracketData = useMemo(() => {
|
const bracket: BracketData = useMemo(
|
||||||
if (!tournament.matches || tournament.matches.length === 0) {
|
() => groupMatchesIntoBracket(tournament.matches),
|
||||||
return { winners: [], losers: [] };
|
[tournament.matches]
|
||||||
}
|
);
|
||||||
|
|
||||||
const winnersMap = new Map<number, Match[]>();
|
|
||||||
const losersMap = new Map<number, Match[]>();
|
|
||||||
|
|
||||||
tournament.matches
|
|
||||||
.sort((a, b) => a.lid - b.lid)
|
|
||||||
.forEach((match) => {
|
|
||||||
if (!match.is_losers_bracket) {
|
|
||||||
if (!winnersMap.has(match.round)) {
|
|
||||||
winnersMap.set(match.round, []);
|
|
||||||
}
|
|
||||||
winnersMap.get(match.round)!.push(match);
|
|
||||||
} else {
|
|
||||||
if (!losersMap.has(match.round)) {
|
|
||||||
losersMap.set(match.round, []);
|
|
||||||
}
|
|
||||||
losersMap.get(match.round)!.push(match);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const winners = Array.from(winnersMap.entries())
|
|
||||||
.sort(([a], [b]) => a - b)
|
|
||||||
.map(([, matches]) => matches);
|
|
||||||
|
|
||||||
const losers = Array.from(losersMap.entries())
|
|
||||||
.sort(([a], [b]) => a - b)
|
|
||||||
.map(([, matches]) => matches);
|
|
||||||
return { winners, losers };
|
|
||||||
}, [tournament.matches]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container size="md" px={0}>
|
<Container size="md" px={0}>
|
||||||
<BracketView bracket={bracket} />
|
<BracketView bracket={bracket} groupConfig={tournament.group_config} />
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
import { createFileRoute, redirect } from "@tanstack/react-router";
|
||||||
|
import {
|
||||||
|
tournamentQueries,
|
||||||
|
useTournament,
|
||||||
|
} from "@/features/tournaments/queries";
|
||||||
|
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||||
|
import GroupStageView from "@/features/tournaments/components/group-stage-view";
|
||||||
|
import { Box, Card, Container, Group, Skeleton, SimpleGrid, Stack } from "@mantine/core";
|
||||||
|
|
||||||
|
export const Route = createFileRoute("/_authed/tournaments/$id/groups")({
|
||||||
|
beforeLoad: async ({ context, params }) => {
|
||||||
|
const { queryClient } = context;
|
||||||
|
const tournament = await ensureServerQueryData(
|
||||||
|
queryClient,
|
||||||
|
tournamentQueries.details(params.id)
|
||||||
|
);
|
||||||
|
if (!tournament) throw redirect({ to: "/tournaments" });
|
||||||
|
return {
|
||||||
|
tournament,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
loader: ({ context }) => ({
|
||||||
|
fullWidth: true,
|
||||||
|
withPadding: false,
|
||||||
|
header: {
|
||||||
|
withBackButton: true,
|
||||||
|
title: `${context.tournament.name}`,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
component: RouteComponent,
|
||||||
|
pendingComponent: GroupsPending,
|
||||||
|
});
|
||||||
|
|
||||||
|
function GroupsPending() {
|
||||||
|
return (
|
||||||
|
<Container size="md" px={0}>
|
||||||
|
<Box p="md">
|
||||||
|
<Stack gap="md">
|
||||||
|
<Group gap={0} grow mb="md">
|
||||||
|
{Array.from({ length: 4 }).map((_, index) => (
|
||||||
|
<Skeleton
|
||||||
|
key={`groups-pending-tab-${index}`}
|
||||||
|
height={44}
|
||||||
|
radius="sm"
|
||||||
|
style={{ opacity: 0.85 - index * 0.1 }}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Group>
|
||||||
|
<Card withBorder radius="md" p={0}>
|
||||||
|
<Group justify="space-between" p="sm">
|
||||||
|
<Skeleton height={16} width={120} radius="sm" />
|
||||||
|
<Skeleton height={22} width={22} radius="xl" />
|
||||||
|
</Group>
|
||||||
|
</Card>
|
||||||
|
<SimpleGrid cols={{ base: 1, sm: 2, lg: 3 }} spacing="md">
|
||||||
|
{Array.from({ length: 6 }).map((_, index) => (
|
||||||
|
<Skeleton
|
||||||
|
key={`groups-pending-match-${index}`}
|
||||||
|
height={100}
|
||||||
|
radius="md"
|
||||||
|
style={{ opacity: Math.max(1 - index * 0.12, 0.4) }}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</SimpleGrid>
|
||||||
|
</Stack>
|
||||||
|
</Box>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function RouteComponent() {
|
||||||
|
const { id } = Route.useParams();
|
||||||
|
const { data: tournament } = useTournament(id);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container size="md" px={0}>
|
||||||
|
<GroupStageView
|
||||||
|
groups={tournament.groups || []}
|
||||||
|
matches={tournament.matches || []}
|
||||||
|
isRegional={tournament.regional}
|
||||||
|
groupConfig={tournament.group_config}
|
||||||
|
/>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import { createFileRoute, redirect } from "@tanstack/react-router";
|
||||||
|
import { tournamentQueries, useTournament } from "@/features/tournaments/queries";
|
||||||
|
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||||
|
import { Container } from "@mantine/core";
|
||||||
|
import { PredictionLeaderboard } from "@/features/predictions/components/prediction-leaderboard";
|
||||||
|
|
||||||
|
export const Route = createFileRoute("/_authed/tournaments/$id/predictions")({
|
||||||
|
beforeLoad: async ({ context, params }) => {
|
||||||
|
const { queryClient } = context;
|
||||||
|
const tournament = await ensureServerQueryData(
|
||||||
|
queryClient,
|
||||||
|
tournamentQueries.details(params.id)
|
||||||
|
);
|
||||||
|
if (!tournament) throw redirect({ to: "/tournaments" });
|
||||||
|
return {
|
||||||
|
tournament,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
loader: () => ({
|
||||||
|
header: {
|
||||||
|
withBackButton: true,
|
||||||
|
title: "Predictions",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
component: RouteComponent,
|
||||||
|
});
|
||||||
|
|
||||||
|
function RouteComponent() {
|
||||||
|
const { id } = Route.useParams();
|
||||||
|
const { data: tournament } = useTournament(id);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container size="md" px={0}>
|
||||||
|
<PredictionLeaderboard tournament={tournament} />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
import { createFileRoute, redirect } from "@tanstack/react-router";
|
||||||
|
import { useMemo } from "react";
|
||||||
|
import { Box, Container, Group, Paper, Stack, Text } from "@mantine/core";
|
||||||
|
import { tournamentQueries, useTournament } from "@/features/tournaments/queries";
|
||||||
|
import { predictionQueries, usePlayerPrediction } from "@/features/predictions/queries";
|
||||||
|
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||||
|
import { BracketPending } from "@/features/bracket/components/bracket-pending";
|
||||||
|
import { PredictionBracket } from "@/features/predictions/components/prediction-bracket";
|
||||||
|
import { computePredictionScore } from "@/features/predictions/utils";
|
||||||
|
import PlayerAvatar from "@/components/player-avatar";
|
||||||
|
|
||||||
|
export const Route = createFileRoute(
|
||||||
|
"/_authed/tournaments/$id/predictions_/$playerId"
|
||||||
|
)({
|
||||||
|
beforeLoad: async ({ context, params }) => {
|
||||||
|
const { queryClient } = context;
|
||||||
|
const tournament = await ensureServerQueryData(
|
||||||
|
queryClient,
|
||||||
|
tournamentQueries.details(params.id)
|
||||||
|
);
|
||||||
|
if (!tournament) throw redirect({ to: "/tournaments" });
|
||||||
|
|
||||||
|
const prediction = await ensureServerQueryData(
|
||||||
|
queryClient,
|
||||||
|
predictionQueries.player(params.id, params.playerId)
|
||||||
|
);
|
||||||
|
if (!prediction) {
|
||||||
|
throw redirect({
|
||||||
|
to: "/tournaments/$id/predictions",
|
||||||
|
params: { id: params.id },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
tournament,
|
||||||
|
prediction,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
loader: ({ context }) => ({
|
||||||
|
fullWidth: true,
|
||||||
|
withPadding: false,
|
||||||
|
header: {
|
||||||
|
withBackButton: true,
|
||||||
|
title: `${context.prediction.player.first_name}'s Bracket`,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
component: RouteComponent,
|
||||||
|
pendingComponent: BracketPending,
|
||||||
|
});
|
||||||
|
|
||||||
|
function RouteComponent() {
|
||||||
|
const { id, playerId } = Route.useParams();
|
||||||
|
const { data: tournament } = useTournament(id);
|
||||||
|
const { data: prediction } = usePlayerPrediction(id, playerId);
|
||||||
|
|
||||||
|
const matches = tournament.matches || [];
|
||||||
|
const picks = prediction?.picks ?? {};
|
||||||
|
|
||||||
|
const score = useMemo(
|
||||||
|
() => computePredictionScore(matches, picks),
|
||||||
|
[matches, picks]
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container size="md" px={0}>
|
||||||
|
<Box pos="relative">
|
||||||
|
<PredictionBracket
|
||||||
|
matches={matches}
|
||||||
|
picks={picks}
|
||||||
|
mode="view"
|
||||||
|
perMatch={score.perMatch}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Box
|
||||||
|
pos="absolute"
|
||||||
|
left={0}
|
||||||
|
right={0}
|
||||||
|
bottom={0}
|
||||||
|
p="md"
|
||||||
|
style={{ zIndex: 2, pointerEvents: "none" }}
|
||||||
|
>
|
||||||
|
<Paper
|
||||||
|
withBorder
|
||||||
|
shadow="md"
|
||||||
|
radius="lg"
|
||||||
|
p="sm"
|
||||||
|
style={{ pointerEvents: "auto" }}
|
||||||
|
>
|
||||||
|
<Group justify="space-between" align="center" wrap="nowrap">
|
||||||
|
<Group gap="sm" align="center" wrap="nowrap">
|
||||||
|
<PlayerAvatar
|
||||||
|
name={`${prediction?.player.first_name} ${prediction?.player.last_name}`}
|
||||||
|
size={32}
|
||||||
|
disableFullscreen
|
||||||
|
/>
|
||||||
|
<Text size="sm" fw={600} lineClamp={1}>
|
||||||
|
{prediction?.player.first_name} {prediction?.player.last_name}
|
||||||
|
</Text>
|
||||||
|
</Group>
|
||||||
|
<Group gap="md" wrap="nowrap">
|
||||||
|
<Stack gap={0} ta="center">
|
||||||
|
<Text size="xs" c="dimmed" fw={700}>
|
||||||
|
PTS
|
||||||
|
</Text>
|
||||||
|
<Text size="sm" fw={700}>
|
||||||
|
{score.points}
|
||||||
|
</Text>
|
||||||
|
</Stack>
|
||||||
|
<Stack gap={0} ta="center">
|
||||||
|
<Text size="xs" c="dimmed" fw={700}>
|
||||||
|
PICKS
|
||||||
|
</Text>
|
||||||
|
<Text size="xs" c="dimmed">
|
||||||
|
{score.correct}/{score.total}
|
||||||
|
</Text>
|
||||||
|
</Stack>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</Paper>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import { createFileRoute, redirect } from "@tanstack/react-router";
|
||||||
|
import { tournamentQueries, useTournament } from "@/features/tournaments/queries";
|
||||||
|
import { predictionQueries, useMyPrediction } from "@/features/predictions/queries";
|
||||||
|
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||||
|
import { Container } from "@mantine/core";
|
||||||
|
import { BracketPending } from "@/features/bracket/components/bracket-pending";
|
||||||
|
import { PredictionEditor } from "@/features/predictions/components/prediction-editor";
|
||||||
|
|
||||||
|
export const Route = createFileRoute(
|
||||||
|
"/_authed/tournaments/$id/predictions_/make"
|
||||||
|
)({
|
||||||
|
beforeLoad: async ({ context, params }) => {
|
||||||
|
const { queryClient } = context;
|
||||||
|
const tournament = await ensureServerQueryData(
|
||||||
|
queryClient,
|
||||||
|
tournamentQueries.details(params.id)
|
||||||
|
);
|
||||||
|
if (!tournament) throw redirect({ to: "/tournaments" });
|
||||||
|
|
||||||
|
const myPrediction = await ensureServerQueryData(
|
||||||
|
queryClient,
|
||||||
|
predictionQueries.mine(params.id)
|
||||||
|
);
|
||||||
|
if (!myPrediction.eligible || myPrediction.locked) {
|
||||||
|
throw redirect({
|
||||||
|
to: "/tournaments/$id/predictions",
|
||||||
|
params: { id: params.id },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
tournament,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
loader: ({ context }) => ({
|
||||||
|
fullWidth: true,
|
||||||
|
withPadding: false,
|
||||||
|
header: {
|
||||||
|
withBackButton: true,
|
||||||
|
title: `${context.tournament.name}`,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
component: RouteComponent,
|
||||||
|
pendingComponent: BracketPending,
|
||||||
|
});
|
||||||
|
|
||||||
|
function RouteComponent() {
|
||||||
|
const { id } = Route.useParams();
|
||||||
|
const { data: tournament } = useTournament(id);
|
||||||
|
const { data: myPrediction } = useMyPrediction(id);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container size="md" px={0}>
|
||||||
|
<PredictionEditor
|
||||||
|
tournament={tournament}
|
||||||
|
initialPicks={myPrediction.prediction?.picks ?? {}}
|
||||||
|
/>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -23,7 +23,13 @@ export const Route = createFileRoute('/_authed/tournaments/')({
|
|||||||
function RouteComponent() {
|
function RouteComponent() {
|
||||||
return <Suspense fallback={<Stack gap="md">
|
return <Suspense fallback={<Stack gap="md">
|
||||||
{Array(10).fill(null).map((_, index) => (
|
{Array(10).fill(null).map((_, index) => (
|
||||||
<Skeleton height="120px" w="100%" />
|
<Skeleton
|
||||||
|
key={`tournament-card-skeleton-${index}`}
|
||||||
|
height="120px"
|
||||||
|
w="100%"
|
||||||
|
radius="md"
|
||||||
|
style={{ opacity: Math.max(1 - index * 0.08, 0.35) }}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</Stack>}>
|
</Stack>}>
|
||||||
<TournamentCardList />
|
<TournamentCardList />
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
import { serverEvents, type ServerEvent } from "@/lib/events/emitter";
|
import { serverEvents, EVENT_TYPES, type ServerEvent } from "@/lib/events/emitter";
|
||||||
import { logger } from "@/lib/logger";
|
import { logger } from "@/lib/logger";
|
||||||
import { superTokensRequestMiddleware } from "@/utils/supertokens";
|
import { superTokensRequestMiddleware } from "@/utils/supertokens";
|
||||||
|
|
||||||
let activeConnections = 0;
|
let activeConnections = 0;
|
||||||
|
const encoder = new TextEncoder();
|
||||||
|
|
||||||
export const Route = createFileRoute("/api/events/$")({
|
export const Route = createFileRoute("/api/events/$")({
|
||||||
server: {
|
server: {
|
||||||
@@ -13,63 +14,47 @@ export const Route = createFileRoute("/api/events/$")({
|
|||||||
activeConnections++;
|
activeConnections++;
|
||||||
const connectionId = `conn_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
|
const connectionId = `conn_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
|
||||||
logger.info(`ServerEvents | New connection ${connectionId}. Active: ${activeConnections}`);
|
logger.info(`ServerEvents | New connection ${connectionId}. Active: ${activeConnections}`);
|
||||||
|
|
||||||
|
let cleanedUp = false;
|
||||||
|
let cleanup = () => {};
|
||||||
|
|
||||||
const stream = new ReadableStream({
|
const stream = new ReadableStream({
|
||||||
start(controller) {
|
start(controller) {
|
||||||
const connectMessage = `data: ${JSON.stringify({ type: "connected" })}\n\n`;
|
const send = (payload: unknown) => {
|
||||||
controller.enqueue(new TextEncoder().encode(connectMessage));
|
|
||||||
|
|
||||||
const handleEvent = (event: ServerEvent) => {
|
|
||||||
logger.info("ServerEvents | Event received", event);
|
|
||||||
const message = `data: ${JSON.stringify(event)}\n\n`;
|
|
||||||
try {
|
try {
|
||||||
if (!controller.desiredSize || controller.desiredSize <= 0) {
|
controller.enqueue(encoder.encode(`data: ${JSON.stringify(payload)}\n\n`));
|
||||||
logger.warn("ServerEvents | Stream closed, skipping event");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
controller.enqueue(new TextEncoder().encode(message));
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error("ServerEvents | Error sending SSE message", error);
|
logger.error("ServerEvents | Error sending SSE message", error);
|
||||||
|
cleanup();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
serverEvents.on("test", handleEvent);
|
const handleEvent = (event: ServerEvent) => send(event);
|
||||||
serverEvents.on("match", handleEvent);
|
for (const type of EVENT_TYPES) {
|
||||||
serverEvents.on("reaction", handleEvent);
|
serverEvents.on(type, handleEvent);
|
||||||
|
}
|
||||||
|
|
||||||
const pingInterval = setInterval(() => {
|
const pingInterval = setInterval(() => {
|
||||||
try {
|
send({ type: "ping", timestamp: Date.now() });
|
||||||
if (!controller.desiredSize || controller.desiredSize <= 0) {
|
|
||||||
clearInterval(pingInterval);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const pingMessage = `data: ${JSON.stringify({ type: "ping", timestamp: Date.now() })}\n\n`;
|
|
||||||
controller.enqueue(new TextEncoder().encode(pingMessage));
|
|
||||||
} catch (e) {
|
|
||||||
logger.error("ServerEvents | Ping interval error", e);
|
|
||||||
clearInterval(pingInterval);
|
|
||||||
}
|
|
||||||
}, 15000);
|
}, 15000);
|
||||||
|
|
||||||
setTimeout(() => {
|
cleanup = () => {
|
||||||
try {
|
if (cleanedUp) return;
|
||||||
const heartbeatMessage = `data: ${JSON.stringify({ type: "heartbeat", timestamp: Date.now() })}\n\n`;
|
cleanedUp = true;
|
||||||
controller.enqueue(new TextEncoder().encode(heartbeatMessage));
|
|
||||||
} catch (e) {
|
|
||||||
logger.error("ServerEvents | Heartbeat error", e);
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
const cleanup = () => {
|
|
||||||
activeConnections--;
|
activeConnections--;
|
||||||
serverEvents.off("test", handleEvent);
|
for (const type of EVENT_TYPES) {
|
||||||
serverEvents.off("match", handleEvent);
|
serverEvents.off(type, handleEvent);
|
||||||
serverEvents.off("reaction", handleEvent);
|
}
|
||||||
clearInterval(pingInterval);
|
clearInterval(pingInterval);
|
||||||
logger.info(`ServerEvents | Connection ${connectionId} cleanup completed. Active: ${activeConnections}`);
|
logger.info(`ServerEvents | Connection ${connectionId} cleanup completed. Active: ${activeConnections}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
request.signal?.addEventListener("abort", cleanup);
|
request.signal?.addEventListener("abort", cleanup);
|
||||||
return cleanup;
|
|
||||||
|
send({ type: "connected" });
|
||||||
|
},
|
||||||
|
cancel() {
|
||||||
|
cleanup();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -77,13 +62,7 @@ export const Route = createFileRoute("/api/events/$")({
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "text/event-stream",
|
"Content-Type": "text/event-stream",
|
||||||
"Cache-Control": "no-cache, no-store, must-revalidate",
|
"Cache-Control": "no-cache, no-store, must-revalidate",
|
||||||
"Connection": "keep-alive",
|
|
||||||
"Access-Control-Allow-Origin": "*",
|
|
||||||
"Access-Control-Allow-Headers": "Cache-Control",
|
|
||||||
"X-Accel-Buffering": "no",
|
"X-Accel-Buffering": "no",
|
||||||
"X-Proxy-Buffering": "no",
|
|
||||||
"Proxy-Buffering": "off",
|
|
||||||
"Transfer-Encoding": "chunked",
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
|
|
||||||
|
export const Route = createFileRoute("/api/health")({
|
||||||
|
server: {
|
||||||
|
handlers: {
|
||||||
|
GET: () => {
|
||||||
|
return new Response(
|
||||||
|
JSON.stringify({
|
||||||
|
status: "ok",
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
status: 200,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||