mirror of
https://github.com/polaroi8d/cactoide.git
synced 2026-03-22 14:15:28 +00:00
Compare commits
35 Commits
feat/invit
...
fix/fix-i1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6155cc44da | ||
|
|
719cd23350 | ||
|
|
87d2275373 | ||
|
|
6e314af82b | ||
|
|
2cb74bccd0 | ||
|
|
0ecaf54227 | ||
|
|
4179bca981 | ||
|
|
406a669a98 | ||
|
|
7d75020cc1 | ||
|
|
73c92b800a | ||
|
|
1faa45e76b | ||
|
|
8a45ad60fb | ||
|
|
258b822a27 | ||
|
|
c3f420df74 | ||
|
|
9f74d58db1 | ||
|
|
efe465d994 | ||
|
|
1b79e6da58 | ||
|
|
5ea620762a | ||
|
|
e5be4b5589 | ||
|
|
8cde1d44eb | ||
|
|
7692f9d503 | ||
|
|
baf3fcd923 | ||
|
|
5468bc7cb2 | ||
|
|
0afe331cab | ||
|
|
fa9a79192c | ||
|
|
7275084ab9 | ||
|
|
02975a0abd | ||
|
|
aebe477f90 | ||
|
|
325237d414 | ||
|
|
24e9d8b626 | ||
|
|
05556eefdb | ||
|
|
2273ae50a4 | ||
|
|
e75c7e40dc | ||
|
|
2a96d3762c | ||
|
|
935042dd06 |
12
.env.example
12
.env.example
@@ -4,10 +4,20 @@ POSTGRES_USER=cactoide
|
||||
POSTGRES_PASSWORD=cactoide_password
|
||||
POSTGRES_PORT=5432
|
||||
|
||||
# Application configuration
|
||||
DATABASE_URL="postgres://cactoide:cactoide_password@localhost:5432/cactoide_database"
|
||||
|
||||
# Application configuration
|
||||
APP_VERSION=latest
|
||||
PORT=5173
|
||||
HOSTNAME=0.0.0.0
|
||||
|
||||
# Logger configuration
|
||||
LOG_PRETTY=true
|
||||
LOG_LEVEL=trace
|
||||
|
||||
# If you don't want to use the default home page you can turn off
|
||||
# in this case the /discovery page remain the home of your site
|
||||
PUBLIC_LANDING_INFO=true
|
||||
|
||||
# Federation config
|
||||
FEDERATION_INSTANCE=true
|
||||
|
||||
3
.github/workflows/build-and-push.yml
vendored
3
.github/workflows/build-and-push.yml
vendored
@@ -61,7 +61,10 @@ jobs:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
build-args: |
|
||||
FEDERATION_INSTANCE=${{ vars.FEDERATION_INSTANCE }}
|
||||
PUBLIC_LANDING_INFO=${{ vars.PUBLIC_LANDING_INFO }}
|
||||
LOG_PRETTY=${{ vars.LOG_PRETTY }}
|
||||
LOG_LEVEL=${{ vars.LOG_LEVEL }}
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64
|
||||
cache-from: type=gha
|
||||
|
||||
3
.github/workflows/test.yml
vendored
3
.github/workflows/test.yml
vendored
@@ -29,7 +29,10 @@ jobs:
|
||||
- name: Build application
|
||||
run: npm run build
|
||||
env:
|
||||
FEDERATION_INSTANCE: ${{ vars.FEDERATION_INSTANCE }}
|
||||
PUBLIC_LANDING_INFO: ${{ vars.PUBLIC_LANDING_INFO }}
|
||||
LOG_PRETTY: ${{ vars.LOG_PRETTY }}
|
||||
LOG_LEVEL: ${{ vars.LOG_LEVEL }}
|
||||
|
||||
- name: Test build output
|
||||
run: |
|
||||
|
||||
11
Dockerfile
11
Dockerfile
@@ -7,6 +7,15 @@ RUN npm ci
|
||||
ARG PUBLIC_LANDING_INFO
|
||||
ENV PUBLIC_LANDING_INFO=$PUBLIC_LANDING_INFO
|
||||
|
||||
ARG FEDERATION_INSTANCE
|
||||
ENV FEDERATION_INSTANCE=$FEDERATION_INSTANCE
|
||||
|
||||
ARG LOG_PRETTY
|
||||
ENV LOG_PRETTY=$LOG_PRETTY
|
||||
|
||||
ARG LOG_LEVEL
|
||||
ENV LOG_LEVEL=$LOG_LEVEL
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN npm run build
|
||||
@@ -23,7 +32,7 @@ ENV PORT 3000
|
||||
ENV HOSTNAME "0.0.0.0"
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
|
||||
CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:3000/healthz || exit 1
|
||||
CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:3000/api/healthz || exit 1
|
||||
|
||||
EXPOSE 3000
|
||||
CMD [ "node", "build" ]
|
||||
|
||||
12
Makefile
12
Makefile
@@ -22,7 +22,7 @@ help:
|
||||
@echo " logs - Show logs from all services"
|
||||
@echo " db-clean - Clean up all Docker resources"
|
||||
@echo " prune - Clean up everything (containers, images, volumes)"
|
||||
@echo " i18n - Validate translation files"
|
||||
@echo " i18n - List missing keys in translation file (use FILE=path/to/file.json)"
|
||||
@echo " lint - Lint the project"
|
||||
@echo " format - Format the project"
|
||||
@echo " migrate-up - Apply invite-only events migration"
|
||||
@@ -94,8 +94,10 @@ format:
|
||||
@echo "Formatting the project..."
|
||||
npm run format
|
||||
|
||||
#TODO: not working yet
|
||||
# List missing keys in a translation file
|
||||
i18n:
|
||||
@echo "Validating translation files..."
|
||||
@if [ -n "$(FILE)" ]; then \
|
||||
./scripts/i18n-check.sh $(FILE); \
|
||||
@if [ -z "$(FILE)" ]; then \
|
||||
echo "Error: FILE variable is required. Example: make i18n FILE=src/lib/i18n/it.json"; \
|
||||
exit 1; \
|
||||
fi
|
||||
@./scripts/i18n-check.sh --missing-only $(FILE)
|
||||
|
||||
74
README.md
74
README.md
@@ -5,7 +5,7 @@ Events that thrive anywhere.
|
||||
Like the cactus, great events bloom under any condition when managed with care. Cactoide(ae) helps you streamline RSVPs, simplify coordination, and keep every detail efficient—so your gatherings are resilient, vibrant, and unforgettable.
|
||||
|
||||
<p align="center">
|
||||
<a href="https://cactoide.dalev.hu/" target="blank">
|
||||
<a href="https://cactoide.org/" target="blank">
|
||||
<picture>
|
||||
<img alt="actoide" src="https://github.com/user-attachments/assets/30b87181-1e3b-49d0-869e-bef6dcf7f777" width="840">
|
||||
</picture>
|
||||
@@ -14,17 +14,25 @@ Like the cactus, great events bloom under any condition when managed with care.
|
||||
|
||||
#### What is it?
|
||||
|
||||
A mobile-first event RSVP platform that lets you create events, share unique URLs, and collect RSVPs without any registration required.
|
||||
A federated mobile-first event RSVP platform that lets you create events, share unique URLs, and collect RSVPs without any registration required. With built-in federation, discover and share events across a decentralized network of instances.
|
||||
|
||||
### ✨ Features
|
||||
|
||||
- **🎯 Instant Event Creation** - Create events in seconds with our streamlined form. No accounts, no waiting, just pure efficiency.
|
||||
- **🔗 One-Click Sharing** - Each event gets a unique, memorable URL. Share instantly via any platform or messaging app.
|
||||
- **🔍 All-in-One Clarity** - No more scrolling through endless chats and reactions. See everyone's availability and responses neatly in one place.
|
||||
- **📅 iCal Integration** - One-tap add-to-calendar via ICS/webcal links. Works with Apple Calendar, Google Calendar, and Outlook, with automatic time zone handling.
|
||||
- **👤 No Hassle, No Sign-Ups** - Skip registrations and endless forms. Unlike other event platforms, you create and share instantly — no accounts, no barriers.
|
||||
- **🛡️ Smart Limits** - Choose between unlimited RSVPs or set a limited capacity. Perfect for any event size.
|
||||
- **✨ Effortless Simplicity** - Designed to be instantly clear and easy. No learning curve — just open, create, and go.
|
||||
**🎯 Instant Event Creation** - Create events in seconds with our streamlined form. No accounts, no waiting, just pure efficiency.
|
||||
|
||||
**🔗 One-Click Sharing** - Each event gets a unique, memorable URL. Share instantly via any platform or messaging app.
|
||||
|
||||
**🌐 Federation** - Connect with other Cactoide instances to discover events across the network. Share your public events and creating a decentralized event discovery network.
|
||||
|
||||
**🔍 All-in-One Clarity** - No more scrolling through endless chats and reactions. See everyone's availability and responses neatly in one place.
|
||||
|
||||
**📅 iCal Integration** - One-tap add-to-calendar via ICS/webcal links. Works with Apple Calendar, Google Calendar, and Outlook, with automatic time zone handling.
|
||||
|
||||
**👤 No Hassle, No Sign-Ups** - Skip registrations and endless forms. Unlike other event platforms, you create and share instantly — no accounts, no barriers.
|
||||
|
||||
**🛡️ Smart Limits** - Choose between unlimited RSVPs or set a limited capacity. Perfect for any event size.
|
||||
|
||||
**✨ Effortless Simplicity** - Designed to be instantly clear and easy. No learning curve — just open, create, and go.
|
||||
|
||||
### Quick Start
|
||||
|
||||
@@ -55,6 +63,53 @@ Your app will be available at `http://localhost:5173`. You can use the Makefile
|
||||
|
||||
Use the `database/seed.sql` if you want to populate your database with dummy data.
|
||||
|
||||
### Federation
|
||||
|
||||
Cactoide supports federation, allowing multiple instances to share and discover public events across the network. This enables users to discover events from other Cactoide instances, creating a decentralized event discovery network.
|
||||
|
||||
<p align="center">
|
||||
<img alt="Federation Example" src="./docs/federation_example.png" width="840">
|
||||
</p>
|
||||
|
||||
#### How it works
|
||||
|
||||
Federation is managed through the `federation.config.js` file, which contains:
|
||||
|
||||
- **Instance name**: The display name for your instance when exposing events to the federation
|
||||
- **Instance list**: An array of federated instance URLs. Add instance URLs here to discover events from other federated instances.
|
||||
|
||||
```javascript
|
||||
const config = {
|
||||
name: 'Cactoide Genesis',
|
||||
instances: [{ url: 'js-meetups.seattle.io' }, { url: 'ai-events.seattle.com' }]
|
||||
};
|
||||
```
|
||||
|
||||
#### Opt-in
|
||||
|
||||
To enable federation on your instance, you need to:
|
||||
|
||||
1. **Set the environment variable**: Add `FEDERATION_INSTANCE=true` to your `.env` file. This enables the federation API endpoints on your instance.
|
||||
|
||||
2. **Configure your instance name**: Update the `name` field in your `federation.config.js` file to set your instance's display name.
|
||||
|
||||
Your instance will automatically expose:
|
||||
|
||||
- `/api/federation/events` - Returns all public events from your instance
|
||||
- `/api/federation/info` - Returns your instance name and public events count
|
||||
|
||||
#### Adding your instance
|
||||
|
||||
To add your instance to the global federation list (so other instances can discover your events):
|
||||
|
||||
1. Fork the [Cactoide repository](https://github.com/polaroi8d/cactoide)
|
||||
2. Add your instance URL to the `instances` array in [`federation.config.js`](https://github.com/polaroi8d/cactoide/blob/main/federation.config.js):
|
||||
3. Open a pull request to the main repository
|
||||
|
||||
Once merged, your instance will appear in the federation network, and other instances will be able to discover and display your public events.
|
||||
|
||||
You can view all registered federated instances in the main repository: [`federation.config.js`](https://github.com/polaroi8d/cactoide/blob/main/federation.config.js) file.
|
||||
|
||||
### Options
|
||||
|
||||
#### 1. Landing page option
|
||||
@@ -90,7 +145,6 @@ It isn’t backed by a big company. Development depends on the support and gener
|
||||
|
||||
You can support in a few ways:
|
||||
|
||||
- Send a one-time donation via [paypal.me/zenoazurben](paypal.me/zenoazurben)
|
||||
- Reach me directly: leventeorb[@]gmail.com
|
||||
|
||||
If you enjoy using Cactoide, or if your business depends on it, please consider sponsoring its development. Your support keeps the project alive, improves it for everyone, and helps create educational content like blog posts and videos for the whole Cactoide community.
|
||||
|
||||
@@ -34,7 +34,7 @@ services:
|
||||
ports:
|
||||
- '${PORT:-5111}:3000'
|
||||
environment:
|
||||
DATABASE_URL: ${DATABASE_URL}
|
||||
DATABASE_URL: ${DATABASE_URL:-postgres://cactoide:cactoide_password@postgres:5432/cactoide_database}
|
||||
PORT: 3000
|
||||
HOSTNAME: ${HOSTNAME:-0.0.0.0}
|
||||
depends_on:
|
||||
|
||||
BIN
docs/federation_example.png
Normal file
BIN
docs/federation_example.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 62 KiB |
19
federation.config.js
Normal file
19
federation.config.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const config = {
|
||||
name: 'Cactoide Genesis',
|
||||
instances: [
|
||||
{
|
||||
url: 'cactoide.org'
|
||||
},
|
||||
{
|
||||
url: 'cactoide.dalev.hu'
|
||||
},
|
||||
{
|
||||
url: 'localhost:5174'
|
||||
},
|
||||
{
|
||||
url: 'localhost:5175'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
export default config;
|
||||
289
package-lock.json
generated
289
package-lock.json
generated
@@ -11,6 +11,8 @@
|
||||
"@sveltejs/adapter-node": "^5.3.1",
|
||||
"drizzle-orm": "^0.44.5",
|
||||
"fuse.js": "^7.1.0",
|
||||
"pino": "^10.1.0",
|
||||
"pino-pretty": "^13.1.2",
|
||||
"postgres": "^3.4.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -23,6 +25,7 @@
|
||||
"@tailwindcss/typography": "^0.5.15",
|
||||
"@tailwindcss/vite": "^4.0.0",
|
||||
"drizzle-kit": "^0.31.5",
|
||||
"@types/node": "^24.9.1",
|
||||
"eslint": "^9.18.0",
|
||||
"eslint-config-prettier": "^10.0.1",
|
||||
"eslint-plugin-svelte": "^3.0.0",
|
||||
@@ -1231,6 +1234,12 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/@pinojs/redact": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@pinojs/redact/-/redact-0.4.0.tgz",
|
||||
"integrity": "sha512-k2ENnmBugE/rzQfEcdWHcCY+/FM3VLzH9cYEsbdsoqrvzAKRhUZeRNhAZvB8OitQJ1TBed3yqWtdjzS6wJKBwg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@polka/url": {
|
||||
"version": "1.0.0-next.29",
|
||||
"resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.29.tgz",
|
||||
@@ -2095,6 +2104,17 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "24.9.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.9.1.tgz",
|
||||
"integrity": "sha512-QoiaXANRkSXK6p0Duvt56W208du4P9Uye9hWLWgGMDTEoKPhuenzNcC4vGUmrNkiOKTlIrBoyNQYNpSwfEZXSg==",
|
||||
"devOptional": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"undici-types": "~7.16.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/resolve": {
|
||||
"version": "1.20.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz",
|
||||
@@ -2432,6 +2452,15 @@
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/atomic-sleep": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz",
|
||||
"integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/axobject-query": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.1.0.tgz",
|
||||
@@ -2561,6 +2590,12 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/colorette": {
|
||||
"version": "2.0.20",
|
||||
"resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz",
|
||||
"integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/commondir": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz",
|
||||
@@ -2611,6 +2646,15 @@
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/dateformat": {
|
||||
"version": "4.6.3",
|
||||
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-4.6.3.tgz",
|
||||
"integrity": "sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz",
|
||||
@@ -2801,6 +2845,15 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/end-of-stream": {
|
||||
"version": "1.4.5",
|
||||
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz",
|
||||
"integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"once": "^1.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/enhanced-resolve": {
|
||||
"version": "5.18.3",
|
||||
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.18.3.tgz",
|
||||
@@ -3110,6 +3163,12 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/fast-copy": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/fast-copy/-/fast-copy-3.0.2.tgz",
|
||||
"integrity": "sha512-dl0O9Vhju8IrcLndv2eU4ldt1ftXMqqfgN4H1cpmGV7P6jeB9FwpN9a2c8DPGE1Ys88rNUJVYDHq73CGAGOPfQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/fast-deep-equal": {
|
||||
"version": "3.1.3",
|
||||
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
|
||||
@@ -3161,6 +3220,12 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/fast-safe-stringify": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz",
|
||||
"integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/fastq": {
|
||||
"version": "1.19.1",
|
||||
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.19.1.tgz",
|
||||
@@ -3359,6 +3424,12 @@
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/help-me": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/help-me/-/help-me-5.0.0.tgz",
|
||||
"integrity": "sha512-7xgomUX6ADmcYzFik0HzAxh/73YlKR9bmFzf51CZwR+b6YtzU2m0u49hQCqV6SvlqIqsaxovfwdvbnsw3b/zpg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/ignore": {
|
||||
"version": "5.3.2",
|
||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",
|
||||
@@ -3476,6 +3547,15 @@
|
||||
"jiti": "lib/jiti-cli.mjs"
|
||||
}
|
||||
},
|
||||
"node_modules/joycon": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz",
|
||||
"integrity": "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/js-yaml": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
|
||||
@@ -3901,6 +3981,15 @@
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/minimist": {
|
||||
"version": "1.2.8",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
|
||||
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/minipass": {
|
||||
"version": "7.1.2",
|
||||
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz",
|
||||
@@ -3989,6 +4078,24 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/on-exit-leak-free": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-2.1.2.tgz",
|
||||
"integrity": "sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"node_modules/optionator": {
|
||||
"version": "0.9.4",
|
||||
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz",
|
||||
@@ -4096,6 +4203,79 @@
|
||||
"url": "https://github.com/sponsors/jonschlinkert"
|
||||
}
|
||||
},
|
||||
"node_modules/pino": {
|
||||
"version": "10.1.0",
|
||||
"resolved": "https://registry.npmjs.org/pino/-/pino-10.1.0.tgz",
|
||||
"integrity": "sha512-0zZC2ygfdqvqK8zJIr1e+wT1T/L+LF6qvqvbzEQ6tiMAoTqEVK9a1K3YRu8HEUvGEvNqZyPJTtb2sNIoTkB83w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@pinojs/redact": "^0.4.0",
|
||||
"atomic-sleep": "^1.0.0",
|
||||
"on-exit-leak-free": "^2.1.0",
|
||||
"pino-abstract-transport": "^2.0.0",
|
||||
"pino-std-serializers": "^7.0.0",
|
||||
"process-warning": "^5.0.0",
|
||||
"quick-format-unescaped": "^4.0.3",
|
||||
"real-require": "^0.2.0",
|
||||
"safe-stable-stringify": "^2.3.1",
|
||||
"sonic-boom": "^4.0.1",
|
||||
"thread-stream": "^3.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"pino": "bin.js"
|
||||
}
|
||||
},
|
||||
"node_modules/pino-abstract-transport": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-2.0.0.tgz",
|
||||
"integrity": "sha512-F63x5tizV6WCh4R6RHyi2Ml+M70DNRXt/+HANowMflpgGFMAym/VKm6G7ZOQRjqN7XbGxK1Lg9t6ZrtzOaivMw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"split2": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pino-pretty": {
|
||||
"version": "13.1.2",
|
||||
"resolved": "https://registry.npmjs.org/pino-pretty/-/pino-pretty-13.1.2.tgz",
|
||||
"integrity": "sha512-3cN0tCakkT4f3zo9RXDIhy6GTvtYD6bK4CRBLN9j3E/ePqN1tugAXD5rGVfoChW6s0hiek+eyYlLNqc/BG7vBQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"colorette": "^2.0.7",
|
||||
"dateformat": "^4.6.3",
|
||||
"fast-copy": "^3.0.2",
|
||||
"fast-safe-stringify": "^2.1.1",
|
||||
"help-me": "^5.0.0",
|
||||
"joycon": "^3.1.1",
|
||||
"minimist": "^1.2.6",
|
||||
"on-exit-leak-free": "^2.1.0",
|
||||
"pino-abstract-transport": "^2.0.0",
|
||||
"pump": "^3.0.0",
|
||||
"secure-json-parse": "^4.0.0",
|
||||
"sonic-boom": "^4.0.1",
|
||||
"strip-json-comments": "^5.0.2"
|
||||
},
|
||||
"bin": {
|
||||
"pino-pretty": "bin.js"
|
||||
}
|
||||
},
|
||||
"node_modules/pino-pretty/node_modules/strip-json-comments": {
|
||||
"version": "5.0.3",
|
||||
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-5.0.3.tgz",
|
||||
"integrity": "sha512-1tB5mhVo7U+ETBKNf92xT4hrQa3pm0MZ0PQvuDnWgAAGHDsfp4lPSpiS6psrSiet87wyGPh9ft6wmhOMQ0hDiw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=14.16"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/pino-std-serializers": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-7.0.0.tgz",
|
||||
"integrity": "sha512-e906FRY0+tV27iq4juKzSYPbUj2do2X2JX4EzSca1631EB2QJQUqGbDuERal7LCtOpxl6x3+nvo9NPZcmjkiFA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/postcss": {
|
||||
"version": "8.5.6",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz",
|
||||
@@ -4373,6 +4553,32 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/process-warning": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/process-warning/-/process-warning-5.0.0.tgz",
|
||||
"integrity": "sha512-a39t9ApHNx2L4+HBnQKqxxHNs1r7KF+Intd8Q/g1bUh6q0WIp9voPXJ/x0j+ZL45KF1pJd9+q2jLIRMfvEshkA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/fastify"
|
||||
},
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/fastify"
|
||||
}
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/pump": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/pump/-/pump-3.0.3.tgz",
|
||||
"integrity": "sha512-todwxLMY7/heScKmntwQG8CXVkWUOdYxIvY2s0VWAAMh/nd8SoYiRaKjlr7+iCs984f2P8zvrfWcDDYVb73NfA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"end-of-stream": "^1.1.0",
|
||||
"once": "^1.3.1"
|
||||
}
|
||||
},
|
||||
"node_modules/punycode": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
|
||||
@@ -4404,6 +4610,12 @@
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/quick-format-unescaped": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz",
|
||||
"integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/readdirp": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",
|
||||
@@ -4418,6 +4630,15 @@
|
||||
"url": "https://paulmillr.com/funding/"
|
||||
}
|
||||
},
|
||||
"node_modules/real-require": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/real-require/-/real-require-0.2.0.tgz",
|
||||
"integrity": "sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 12.13.0"
|
||||
}
|
||||
},
|
||||
"node_modules/resolve": {
|
||||
"version": "1.22.10",
|
||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz",
|
||||
@@ -4545,6 +4766,31 @@
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/safe-stable-stringify": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz",
|
||||
"integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/secure-json-parse": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/secure-json-parse/-/secure-json-parse-4.1.0.tgz",
|
||||
"integrity": "sha512-l4KnYfEyqYJxDwlNVyRfO2E4NTHfMKAWdUuA8J0yve2Dz/E/PdBepY03RvyJpssIpRFwJoCD55wA+mEDs6ByWA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/fastify"
|
||||
},
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/fastify"
|
||||
}
|
||||
],
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/semver": {
|
||||
"version": "7.7.2",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz",
|
||||
@@ -4601,6 +4847,15 @@
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/sonic-boom": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-4.2.0.tgz",
|
||||
"integrity": "sha512-INb7TM37/mAcsGmc9hyyI6+QR3rR1zVRu36B0NeGXKnOOLiZOfER5SA+N7X7k3yUYRzLWafduTDvJAfDswwEww==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"atomic-sleep": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
@@ -4631,6 +4886,15 @@
|
||||
"source-map": "^0.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/split2": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz",
|
||||
"integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">= 10.x"
|
||||
}
|
||||
},
|
||||
"node_modules/strip-json-comments": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
|
||||
@@ -4798,6 +5062,15 @@
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/thread-stream": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-3.1.0.tgz",
|
||||
"integrity": "sha512-OqyPZ9u96VohAyMfJykzmivOrY2wfMSf3C5TtFJVgN+Hm6aj+voFhlK+kZEIv2FBh1X6Xp3DlnCOfEQ3B2J86A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"real-require": "^0.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/tinyglobby": {
|
||||
"version": "0.2.15",
|
||||
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz",
|
||||
@@ -4902,11 +5175,11 @@
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "7.10.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.10.0.tgz",
|
||||
"integrity": "sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag==",
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
"version": "7.16.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz",
|
||||
"integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==",
|
||||
"devOptional": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/uri-js": {
|
||||
"version": "4.4.1",
|
||||
@@ -5045,6 +5318,12 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/yallist": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz",
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
"@tailwindcss/forms": "^0.5.9",
|
||||
"@tailwindcss/typography": "^0.5.15",
|
||||
"@tailwindcss/vite": "^4.0.0",
|
||||
"drizzle-kit": "^0.31.5",
|
||||
"@types/node": "^24.9.1",
|
||||
"drizzle-kit": "^0.31.4",
|
||||
"eslint": "^9.18.0",
|
||||
"eslint-config-prettier": "^10.0.1",
|
||||
"eslint-plugin-svelte": "^3.0.0",
|
||||
@@ -41,6 +42,8 @@
|
||||
"@sveltejs/adapter-node": "^5.3.1",
|
||||
"drizzle-orm": "^0.44.5",
|
||||
"fuse.js": "^7.1.0",
|
||||
"pino": "^10.1.0",
|
||||
"pino-pretty": "^13.1.2",
|
||||
"postgres": "^3.4.7"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,191 +1,89 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
# Find keys present in messages.json but missing in a translation file.
|
||||
|
||||
# Translation validation script
|
||||
# Compares a translation file against the source messages.json to find missing keys
|
||||
set -euo pipefail
|
||||
|
||||
set -e
|
||||
SOURCE_DEFAULT="src/lib/i18n/messages.json"
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Default paths
|
||||
SOURCE_FILE="src/lib/i18n/messages.json"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
# Function to show usage
|
||||
show_usage() {
|
||||
echo "Usage: $0 [LANGUAGE_FILE]"
|
||||
echo ""
|
||||
echo "Validates a translation file against the source messages.json"
|
||||
echo ""
|
||||
echo "Arguments:"
|
||||
echo " LANGUAGE_FILE Path to the translation file to validate (e.g., src/lib/i18n/it.json)"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " $0 src/lib/i18n/it.json"
|
||||
echo " $0 src/lib/i18n/fr.json"
|
||||
echo ""
|
||||
echo "If no file is provided, it will check all .json files in src/lib/i18n/ except messages.json"
|
||||
}
|
||||
|
||||
# Function to get all keys from a JSON file recursively
|
||||
get_keys() {
|
||||
local file="$1"
|
||||
local prefix="$2"
|
||||
|
||||
# Use jq to extract all keys recursively
|
||||
jq -r 'paths(scalars) as $p | $p | join(".")' "$file" | while read -r key; do
|
||||
if [ -n "$prefix" ]; then
|
||||
echo "${prefix}.${key}"
|
||||
else
|
||||
echo "$key"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Function to validate a single translation file
|
||||
validate_file() {
|
||||
local translation_file="$1"
|
||||
local source_file="$2"
|
||||
|
||||
echo -e "${YELLOW}Validating: $translation_file${NC}"
|
||||
echo "----------------------------------------"
|
||||
|
||||
# Check if files exist
|
||||
if [ ! -f "$source_file" ]; then
|
||||
echo -e "${RED}Error: Source file $source_file not found${NC}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$translation_file" ]; then
|
||||
echo -e "${RED}Error: Translation file $translation_file not found${NC}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Get all keys from source file
|
||||
local source_keys
|
||||
source_keys=$(get_keys "$source_file")
|
||||
|
||||
# Get all keys from translation file
|
||||
local translation_keys
|
||||
translation_keys=$(get_keys "$translation_file")
|
||||
|
||||
# Find missing keys
|
||||
local missing_keys
|
||||
missing_keys=$(comm -23 <(echo "$source_keys" | sort) <(echo "$translation_keys" | sort))
|
||||
|
||||
# Find extra keys (in translation but not in source)
|
||||
local extra_keys
|
||||
extra_keys=$(comm -13 <(echo "$source_keys" | sort) <(echo "$translation_keys" | sort))
|
||||
|
||||
# Count missing and extra keys
|
||||
local missing_count
|
||||
if [ -z "$missing_keys" ]; then
|
||||
missing_count=0
|
||||
else
|
||||
missing_count=$(echo "$missing_keys" | wc -l | tr -d ' ')
|
||||
fi
|
||||
|
||||
local extra_count
|
||||
if [ -z "$extra_keys" ]; then
|
||||
extra_count=0
|
||||
else
|
||||
extra_count=$(echo "$extra_keys" | wc -l | tr -d ' ')
|
||||
fi
|
||||
|
||||
# Report results
|
||||
if [ "$missing_count" -eq 0 ] && [ "$extra_count" -eq 0 ]; then
|
||||
echo -e "${GREEN} Perfect! All keys match.${NC}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "$missing_count" -gt 0 ]; then
|
||||
echo -e "${RED} Missing $missing_count key(s) in translation:${NC}"
|
||||
echo "$missing_keys" | while read -r key; do
|
||||
echo -e " ${RED}• $key${NC}"
|
||||
done
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [ "$extra_count" -gt 0 ]; then
|
||||
echo -e "${YELLOW} Extra $extra_count key(s) in translation (not in source):${NC}"
|
||||
echo "$extra_keys" | while read -r key; do
|
||||
echo -e " ${YELLOW}• $key${NC}"
|
||||
done
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Return error code if there are missing keys
|
||||
if [ "$missing_count" -gt 0 ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Main function
|
||||
main() {
|
||||
local translation_file="$1"
|
||||
local source_file="$PROJECT_ROOT/$SOURCE_FILE"
|
||||
local exit_code=0
|
||||
|
||||
# Change to project root directory
|
||||
cd "$PROJECT_ROOT"
|
||||
|
||||
# If no file specified, check all translation files
|
||||
if [ -z "$translation_file" ]; then
|
||||
echo -e "${YELLOW}No file specified. Checking all translation files...${NC}"
|
||||
echo ""
|
||||
|
||||
# Find all .json files in i18n directory except messages.json
|
||||
local files
|
||||
files=$(find src/lib/i18n -name "*.json" -not -name "messages.json" 2>/dev/null || true)
|
||||
|
||||
if [ -z "$files" ]; then
|
||||
echo -e "${YELLOW}No translation files found in src/lib/i18n/${NC}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Validate each file
|
||||
echo "$files" | while read -r file; do
|
||||
if [ -n "$file" ]; then
|
||||
if ! validate_file "$file" "$source_file"; then
|
||||
exit_code=1
|
||||
fi
|
||||
echo ""
|
||||
fi
|
||||
done
|
||||
|
||||
return $exit_code
|
||||
fi
|
||||
|
||||
# Validate the specified file
|
||||
if ! validate_file "$translation_file" "$source_file"; then
|
||||
exit_code=1
|
||||
fi
|
||||
|
||||
return $exit_code
|
||||
usage() {
|
||||
echo "Usage: $0 [--missing-only] <translation.json> [source_messages.json]"
|
||||
echo "Compares <translation.json> against messages.json and prints missing keys."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check if jq is installed
|
||||
if ! command -v jq &> /dev/null; then
|
||||
echo -e "${RED}Error: jq is required but not installed.${NC}"
|
||||
echo "Please install jq:"
|
||||
echo " macOS: brew install jq"
|
||||
echo " Ubuntu/Debian: sudo apt-get install jq"
|
||||
echo " CentOS/RHEL: sudo yum install jq"
|
||||
exit 1
|
||||
command -v jq >/dev/null 2>&1 || {
|
||||
echo "Error: jq is required but not installed." >&2
|
||||
echo "Please install jq:" >&2
|
||||
echo " macOS: brew install jq" >&2
|
||||
echo " Ubuntu/Debian: sudo apt-get install jq" >&2
|
||||
echo " CentOS/RHEL: sudo yum install jq" >&2
|
||||
exit 127
|
||||
}
|
||||
|
||||
# Parse arguments (handle --missing-only flag for Makefile compatibility)
|
||||
TRANSLATION=""
|
||||
SOURCE="$SOURCE_DEFAULT"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--missing-only|-m)
|
||||
# Flag is accepted but ignored (this script only does missing keys)
|
||||
shift
|
||||
;;
|
||||
--help|-h)
|
||||
usage
|
||||
;;
|
||||
-*)
|
||||
echo "Error: Unknown option: $1" >&2
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
if [[ -z "$TRANSLATION" ]]; then
|
||||
TRANSLATION="$1"
|
||||
elif [[ "$SOURCE" == "$SOURCE_DEFAULT" ]]; then
|
||||
SOURCE="$1"
|
||||
else
|
||||
echo "Error: Too many arguments" >&2
|
||||
usage
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Validate arguments
|
||||
[[ -z "$TRANSLATION" ]] && {
|
||||
echo "Error: Translation file is required" >&2
|
||||
usage
|
||||
}
|
||||
|
||||
# Validate files exist
|
||||
[[ -f "$SOURCE" ]] || {
|
||||
echo "Error: Source file not found: $SOURCE" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
[[ -f "$TRANSLATION" ]] || {
|
||||
echo "Error: Translation file not found: $TRANSLATION" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Extract all keys from a JSON file (dot-joined paths to scalar values)
|
||||
keys() {
|
||||
jq -r 'paths(scalars) | join(".")' "$1" | sort -u
|
||||
}
|
||||
|
||||
# Find missing keys: in SOURCE but not in TRANSLATION
|
||||
missing=$(comm -23 <(keys "$SOURCE") <(keys "$TRANSLATION"))
|
||||
|
||||
if [[ -z "$missing" ]]; then
|
||||
echo "No missing keys found."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Handle help flag
|
||||
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
||||
show_usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Run main function
|
||||
main "$1"
|
||||
echo "Missing keys in $(basename "$TRANSLATION"):"
|
||||
echo "$missing" | sed 's/^/ - /'
|
||||
echo
|
||||
echo "Total missing keys: $(echo "$missing" | wc -l | tr -d ' ')"
|
||||
exit 1
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import type { Handle } from '@sveltejs/kit';
|
||||
import { generateUserId } from '$lib/generateUserId.js';
|
||||
import { ensureDatabaseConnection } from '$lib/database/healthCheck';
|
||||
import { logger } from '$lib/logger';
|
||||
|
||||
// Global flag to track if database health check has been performed
|
||||
let dbHealthCheckPerformed = false;
|
||||
@@ -18,7 +19,7 @@ export const handle: Handle = async ({ event, resolve }) => {
|
||||
});
|
||||
dbHealthCheckPerformed = true;
|
||||
} catch (error) {
|
||||
console.error('Database health check failed:', error);
|
||||
logger.error({ error }, 'Database health check failed');
|
||||
// The ensureDatabaseConnection function will exit the process
|
||||
// if the database is unavailable, so this catch is just for safety
|
||||
process.exit(1);
|
||||
@@ -33,11 +34,10 @@ export const handle: Handle = async ({ event, resolve }) => {
|
||||
const PATH = '/';
|
||||
|
||||
if (!cactoideUserId) {
|
||||
console.debug(`There is no cactoideUserId cookie, generating new one...`);
|
||||
logger.debug({ userId }, 'No cactoideUserId cookie found, generating new one');
|
||||
event.cookies.set('cactoideUserId', userId, { path: PATH, maxAge: MAX_AGE });
|
||||
} else {
|
||||
console.debug(`cactoideUserId: ${cactoideUserId}`);
|
||||
console.debug(`cactoideUserId cookie found, using existing one...`);
|
||||
logger.debug({ cactoideUserId }, 'cactoideUserId cookie found, using existing one');
|
||||
}
|
||||
|
||||
return resolve(event);
|
||||
|
||||
@@ -48,6 +48,13 @@
|
||||
{t('navigation.create')}
|
||||
</button>
|
||||
|
||||
<button
|
||||
on:click={() => goto('/instance')}
|
||||
class={isActive('/instance') ? 'text-violet-400' : 'cursor-pointer'}
|
||||
>
|
||||
{t('navigation.instance')}
|
||||
</button>
|
||||
|
||||
<button
|
||||
on:click={() => goto('/event')}
|
||||
class={isActive('/event') ? 'text-violet-400' : 'cursor-pointer'}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import postgres from 'postgres';
|
||||
import { env } from '$env/dynamic/private';
|
||||
import { logger } from '$lib/logger';
|
||||
|
||||
interface HealthCheckOptions {
|
||||
maxRetries?: number;
|
||||
@@ -29,7 +30,7 @@ export async function checkDatabaseHealth(
|
||||
} = options;
|
||||
|
||||
if (!env.DATABASE_URL) {
|
||||
console.error('DATABASE_URL environment variable is not set');
|
||||
logger.error('DATABASE_URL environment variable is not set');
|
||||
return {
|
||||
success: false,
|
||||
error: 'DATABASE_URL environment variable is not set',
|
||||
@@ -39,10 +40,10 @@ export async function checkDatabaseHealth(
|
||||
|
||||
let lastError: Error | null = null;
|
||||
|
||||
console.log(`Starting database health check (max retries: ${maxRetries})`);
|
||||
logger.info({ maxRetries }, 'Starting database health check');
|
||||
|
||||
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
||||
console.log(`Attempt ${attempt}/${maxRetries} - Testing database connection`);
|
||||
logger.debug({ attempt, maxRetries }, 'Testing database connection');
|
||||
|
||||
try {
|
||||
// Create a new connection for the health check
|
||||
@@ -57,7 +58,7 @@ export async function checkDatabaseHealth(
|
||||
await client`SELECT 1 as health_check`;
|
||||
await client.end();
|
||||
|
||||
console.log(`Database connection successful on attempt ${attempt}.`);
|
||||
logger.info({ attempt }, 'Database connection successful');
|
||||
|
||||
return {
|
||||
success: true,
|
||||
@@ -66,12 +67,12 @@ export async function checkDatabaseHealth(
|
||||
} catch (error) {
|
||||
lastError = error as Error;
|
||||
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
||||
console.error(`Connection failed on attempt ${attempt}: ${errorMessage}`);
|
||||
logger.warn({ attempt, error: errorMessage }, 'Database connection failed');
|
||||
|
||||
// Don't wait after the last attempt
|
||||
if (attempt < maxRetries) {
|
||||
const delay = Math.min(baseDelay * Math.pow(2, attempt - 1), maxDelay);
|
||||
console.log(`Waiting ${delay}ms before retry...`);
|
||||
logger.debug({ delay }, 'Waiting before retry');
|
||||
await new Promise((resolve) => setTimeout(resolve, delay));
|
||||
}
|
||||
}
|
||||
@@ -79,7 +80,10 @@ export async function checkDatabaseHealth(
|
||||
|
||||
const finalError = lastError?.message || 'Unknown database connection error';
|
||||
|
||||
console.error(`All ${maxRetries} attempts failed. Final error: ${finalError}`);
|
||||
logger.error(
|
||||
{ attempts: maxRetries, error: finalError },
|
||||
'All database connection attempts failed'
|
||||
);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
@@ -95,10 +99,10 @@ export async function ensureDatabaseConnection(options?: HealthCheckOptions): Pr
|
||||
const result = await checkDatabaseHealth(options);
|
||||
|
||||
if (!result.success) {
|
||||
console.error('Database connection failed after all retry attempts');
|
||||
console.error(`Error: ${result.error}`);
|
||||
console.error(`Attempts made: ${result.attempts}`);
|
||||
console.error('Exiting application...');
|
||||
logger.fatal(
|
||||
{ error: result.error, attempts: result.attempts },
|
||||
'Database connection failed after all retry attempts. Exiting application'
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
146
src/lib/fetchFederatedEvents.ts
Normal file
146
src/lib/fetchFederatedEvents.ts
Normal file
@@ -0,0 +1,146 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import { logger } from '$lib/logger';
|
||||
import type { Event } from '$lib/types';
|
||||
|
||||
import config from '../../federation.config.js';
|
||||
|
||||
console.log(config.instances);
|
||||
|
||||
interface FederationConfig {
|
||||
name: string;
|
||||
instances: Array<{ url: string }>;
|
||||
}
|
||||
|
||||
interface FederationEventsResponse {
|
||||
events: Array<Event & { federation?: boolean }>;
|
||||
count?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the federation config file
|
||||
*/
|
||||
async function readFederationConfig(): Promise<FederationConfig | null> {
|
||||
try {
|
||||
const configPath = join(process.cwd(), 'federation.config.js');
|
||||
|
||||
// Use dynamic import to load the config file as a module
|
||||
// This is safer than eval and works with ES modules
|
||||
const configModule = await import(configPath + '?t=' + Date.now());
|
||||
const config = (configModule.default || configModule.config) as FederationConfig;
|
||||
|
||||
if (config && config.instances && Array.isArray(config.instances)) {
|
||||
return config;
|
||||
}
|
||||
|
||||
logger.warn('Invalid federation config structure');
|
||||
return null;
|
||||
} catch (error) {
|
||||
// If dynamic import fails, try reading as text and parsing
|
||||
try {
|
||||
const configPath = join(process.cwd(), 'federation.config.js');
|
||||
const configContent = readFileSync(configPath, 'utf-8');
|
||||
|
||||
// Try to extract JSON-like structure
|
||||
const configMatch = configContent.match(/instances:\s*\[([\s\S]*?)\]/);
|
||||
if (configMatch) {
|
||||
// Simple parsing - extract URLs
|
||||
const urlMatches = configContent.matchAll(/url:\s*['"]([^'"]+)['"]/g);
|
||||
const instances = Array.from(urlMatches, (match) => ({ url: match[1] }));
|
||||
|
||||
if (instances.length > 0) {
|
||||
return {
|
||||
name: 'Federated Instances',
|
||||
instances
|
||||
};
|
||||
}
|
||||
}
|
||||
} catch (fallbackError) {
|
||||
logger.error({ error: fallbackError }, 'Error parsing federation.config.js as fallback');
|
||||
}
|
||||
|
||||
logger.error({ error }, 'Error reading federation.config.js');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches events from a single federated instance
|
||||
*/
|
||||
async function fetchEventsFromInstance(instanceUrl: string): Promise<Event[]> {
|
||||
try {
|
||||
// Ensure URL has protocol and append /api/federation/events
|
||||
|
||||
const apiUrl = `http://${instanceUrl}/api/federation/events`;
|
||||
|
||||
logger.debug({ apiUrl }, 'Fetching events from federated instance');
|
||||
|
||||
const response = await fetch(apiUrl, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/json'
|
||||
},
|
||||
signal: AbortSignal.timeout(10000) // 10 second timeout
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
logger.warn({ apiUrl, status: response.status }, 'Failed to fetch events from instance');
|
||||
return [];
|
||||
}
|
||||
|
||||
const data = (await response.json()) as FederationEventsResponse;
|
||||
|
||||
if (!data.events || !Array.isArray(data.events)) {
|
||||
logger.warn({ apiUrl }, 'Invalid events response structure');
|
||||
return [];
|
||||
}
|
||||
|
||||
// Mark events as federated and add source URL
|
||||
const federatedEvents: Event[] = data.events.map((event) => ({
|
||||
...event,
|
||||
federation: true,
|
||||
federation_url: `http://${instanceUrl}`
|
||||
}));
|
||||
|
||||
logger.info(
|
||||
{ apiUrl, eventCount: federatedEvents.length },
|
||||
'Successfully fetched federated events'
|
||||
);
|
||||
return federatedEvents;
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
{ instanceUrl, error: error instanceof Error ? error.message : 'Unknown error' },
|
||||
'Error fetching events from instance'
|
||||
);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches events from all configured federated instances
|
||||
*/
|
||||
export async function fetchAllFederatedEvents(): Promise<Event[]> {
|
||||
const config = await readFederationConfig();
|
||||
|
||||
if (!config || !config.instances || config.instances.length === 0) {
|
||||
logger.debug('No federation config or instances found');
|
||||
return [];
|
||||
}
|
||||
|
||||
logger.info(
|
||||
{ instanceCount: config.instances.length },
|
||||
'Fetching events from federated instances'
|
||||
);
|
||||
|
||||
// Fetch from all instances in parallel
|
||||
const fetchPromises = config.instances.map((instance) => fetchEventsFromInstance(instance.url));
|
||||
|
||||
const results = await Promise.all(fetchPromises);
|
||||
|
||||
// Flatten all events into a single array
|
||||
const allFederatedEvents = results.flat();
|
||||
|
||||
logger.info({ totalEvents: allFederatedEvents.length }, 'Completed fetching federated events');
|
||||
|
||||
return allFederatedEvents;
|
||||
}
|
||||
@@ -94,7 +94,8 @@
|
||||
"home": "Home",
|
||||
"discover": "Scopri",
|
||||
"create": "Crea",
|
||||
"myEvents": "I Miei Eventi"
|
||||
"myEvents": "I Miei Eventi",
|
||||
"instance": "Istanza"
|
||||
},
|
||||
"home": {
|
||||
"title": "Cactoide - Il sito per gli RSVP",
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
"public": "Public",
|
||||
"private": "Private",
|
||||
"inviteOnly": "Invite Only",
|
||||
"invite-only": "Invite Only",
|
||||
"limited": "Limited",
|
||||
"unlimited": "Unlimited",
|
||||
"capacity": "Capacity",
|
||||
@@ -98,7 +99,8 @@
|
||||
"home": "Home",
|
||||
"discover": "Discover",
|
||||
"create": "Create",
|
||||
"myEvents": "My Events"
|
||||
"myEvents": "My Events",
|
||||
"instance": "Instance"
|
||||
},
|
||||
"home": {
|
||||
"title": "Cactoide - The RSVP site",
|
||||
@@ -249,6 +251,21 @@
|
||||
"noEventsFoundTitle": "No events found",
|
||||
"noEventsFoundDescription": "Try adjusting your search terms or browse all events"
|
||||
},
|
||||
"instance": {
|
||||
"name": "Name",
|
||||
"url": "URL",
|
||||
"events": "Events",
|
||||
"healthStatus": "Health Status",
|
||||
"responseTime": "Response Time",
|
||||
"notAvailable": "N/A",
|
||||
"healthStatusHealthy": "healthy",
|
||||
"healthStatusUnhealthy": "unhealthy",
|
||||
"healthStatusUnknown": "unknown",
|
||||
"description": "These are the instances that are part of the github original federation list, if you want to add your instance to the list, please open a pull request to the",
|
||||
"configFile": "federation.config.js",
|
||||
"file": "file.",
|
||||
"noInstances": "No federation instances configured."
|
||||
},
|
||||
"calendar": {
|
||||
"addToCalendarTitle": "Add to Calendar",
|
||||
"googleCalendarTitle": "Google Calendar",
|
||||
@@ -267,7 +284,7 @@
|
||||
"layout": {
|
||||
"defaultTitle": "Cactoide -",
|
||||
"defaultDescription": "Create and manage event RSVPs",
|
||||
"userIdCookieText": "Your UserID storated as a cookie:",
|
||||
"userIdCookieText": "Your UserID stored as a cookie:",
|
||||
"firstTimeVisiting": "First time visiting. Generating new UserID...",
|
||||
"copyright": "© 2025 Cactoide"
|
||||
}
|
||||
|
||||
40
src/lib/logger.ts
Normal file
40
src/lib/logger.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import pino from 'pino';
|
||||
import { LOG_PRETTY, LOG_LEVEL } from '$env/static/private';
|
||||
|
||||
try {
|
||||
if (LOG_PRETTY && LOG_LEVEL) {
|
||||
console.debug(
|
||||
`Initializing logger with pretty logs: LOG_PRETTY: ${LOG_PRETTY} and LOG_LEVEL: ${LOG_LEVEL}`
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error initializing logger', error);
|
||||
}
|
||||
|
||||
const USE_PRETTY_LOGS = LOG_PRETTY === 'true';
|
||||
|
||||
const transport = USE_PRETTY_LOGS
|
||||
? {
|
||||
target: 'pino-pretty',
|
||||
options: {
|
||||
colorize: true,
|
||||
translateTime: 'SYS:standard',
|
||||
ignore: 'pid,hostname'
|
||||
},
|
||||
customLevels: {
|
||||
trace: 10,
|
||||
debug: 20,
|
||||
info: 30,
|
||||
warn: 40,
|
||||
error: 50,
|
||||
fatal: 60
|
||||
}
|
||||
}
|
||||
: undefined;
|
||||
|
||||
export const logger = pino({
|
||||
level: LOG_LEVEL,
|
||||
transport
|
||||
});
|
||||
|
||||
export type Logger = typeof logger;
|
||||
@@ -17,6 +17,8 @@ export interface Event {
|
||||
user_id: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
federation?: boolean; // Optional: true if event is from a federated instance
|
||||
federation_url?: string; // Optional: URL of the federated instance this event came from
|
||||
}
|
||||
|
||||
export interface RSVP {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<!-- Error Content -->
|
||||
<div class="container mx-auto flex-1 px-4 py-8">
|
||||
<div class="mx-auto max-w-md text-center">
|
||||
<div class="rounded-sm border border-red-500/30 bg-red-900/20 p-8">
|
||||
<div class="rounded-sm border border-red-500/30 bg-red-900 p-8">
|
||||
<div class="mb-4 text-6xl text-red-400">🚨</div>
|
||||
<h2 class="mb-4 text-2xl font-bold text-red-400">{t('errors.errorTitle')}</h2>
|
||||
|
||||
|
||||
55
src/routes/api/federation/events/+server.ts
Normal file
55
src/routes/api/federation/events/+server.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { database } from '$lib/database/db';
|
||||
import { events } from '$lib/database/schema';
|
||||
import { desc, eq } from 'drizzle-orm';
|
||||
import { logger } from '$lib/logger';
|
||||
|
||||
import { FEDERATION_INSTANCE } from '$env/static/private';
|
||||
|
||||
export const GET: RequestHandler = async () => {
|
||||
try {
|
||||
if (!FEDERATION_INSTANCE) {
|
||||
return json({ error: 'Federation API is not enabled on this instance' }, { status: 403 });
|
||||
}
|
||||
|
||||
// Fetch all public and invite-only events ordered by creation date (newest first)
|
||||
const publicEvents = await database
|
||||
.select()
|
||||
.from(events)
|
||||
.where(eq(events.visibility, 'public'))
|
||||
.orderBy(desc(events.createdAt));
|
||||
|
||||
// Transform events to include federation_event type
|
||||
const transformedEvents = publicEvents.map((event) => ({
|
||||
id: event.id,
|
||||
name: event.name,
|
||||
date: event.date,
|
||||
time: event.time,
|
||||
location: event.location,
|
||||
location_type: event.locationType,
|
||||
location_url: event.locationUrl,
|
||||
type: event.type,
|
||||
federation: true,
|
||||
attendee_limit: event.attendeeLimit,
|
||||
visibility: event.visibility,
|
||||
user_id: event.userId,
|
||||
created_at: event.createdAt?.toISOString() || '',
|
||||
updated_at: event.updatedAt?.toISOString() || ''
|
||||
}));
|
||||
|
||||
return json({
|
||||
events: transformedEvents,
|
||||
count: transformedEvents.length
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error({ error }, 'Error fetching events from API');
|
||||
return json(
|
||||
{
|
||||
error: 'Failed to fetch events',
|
||||
message: error instanceof Error ? error.message : 'Unknown error'
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
};
|
||||
38
src/routes/api/federation/info/+server.ts
Normal file
38
src/routes/api/federation/info/+server.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { database } from '$lib/database/db';
|
||||
import { events } from '$lib/database/schema';
|
||||
import { eq, count } from 'drizzle-orm';
|
||||
import { logger } from '$lib/logger';
|
||||
import federationConfig from '../../../../../federation.config.js';
|
||||
|
||||
import { FEDERATION_INSTANCE } from '$env/static/private';
|
||||
|
||||
export const GET: RequestHandler = async () => {
|
||||
try {
|
||||
if (!FEDERATION_INSTANCE) {
|
||||
return json({ error: 'Federation API is not enabled on this instance' }, { status: 403 });
|
||||
}
|
||||
// Count public events
|
||||
const publicEventsCount = await database
|
||||
.select({ count: count() })
|
||||
.from(events)
|
||||
.where(eq(events.visibility, 'public'));
|
||||
|
||||
const countValue = publicEventsCount[0]?.count || 0;
|
||||
|
||||
return json({
|
||||
name: federationConfig.name,
|
||||
publicEventsCount: countValue
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error({ error }, 'Error fetching federation info from API');
|
||||
return json(
|
||||
{
|
||||
error: 'Failed to fetch federation info',
|
||||
message: error instanceof Error ? error.message : 'Unknown error'
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
};
|
||||
28
src/routes/api/healthz/+server.ts
Normal file
28
src/routes/api/healthz/+server.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
// src/routes/healthz/+server.ts
|
||||
import { json } from '@sveltejs/kit';
|
||||
import { database } from '$lib/database/db';
|
||||
import { sql } from 'drizzle-orm';
|
||||
|
||||
export async function GET() {
|
||||
const startTime = performance.now();
|
||||
try {
|
||||
await database.execute(sql`select 1`);
|
||||
const responseTime = Math.round(performance.now() - startTime);
|
||||
return json(
|
||||
{ ok: true, responseTime, responseTimeUnit: 'ms' },
|
||||
{ headers: { 'cache-control': 'no-store' } }
|
||||
);
|
||||
} catch (err) {
|
||||
const responseTime = Math.round(performance.now() - startTime);
|
||||
return json(
|
||||
{
|
||||
ok: false,
|
||||
error: (err as Error)?.message,
|
||||
message: 'Database unreachable.',
|
||||
responseTime,
|
||||
responseTimeUnit: 'ms'
|
||||
},
|
||||
{ status: 503, headers: { 'cache-control': 'no-store' } }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { events, inviteTokens } from '$lib/database/schema';
|
||||
import { fail, redirect } from '@sveltejs/kit';
|
||||
import type { Actions } from './$types';
|
||||
import { generateInviteToken, calculateTokenExpiration } from '$lib/inviteTokenHelpers.js';
|
||||
import { logger } from '$lib/logger';
|
||||
|
||||
// Generate a random URL-friendly ID
|
||||
function generateEventId(): string {
|
||||
@@ -116,7 +117,7 @@ export const actions: Actions = {
|
||||
userId: userId!
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Unexpected error', error);
|
||||
logger.error({ error, eventId, userId }, 'Unexpected error creating event');
|
||||
throw error;
|
||||
});
|
||||
|
||||
|
||||
@@ -139,6 +139,11 @@
|
||||
bind:value={eventData.date}
|
||||
min={today}
|
||||
class="border-dark-300 w-full rounded-sm border-2 bg-white px-4 py-3 text-slate-900 shadow-sm transition-all duration-200"
|
||||
on:keydown={(e) => {
|
||||
if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(e.key)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
}}
|
||||
required
|
||||
/>
|
||||
{#if errors.date}
|
||||
|
||||
@@ -2,10 +2,12 @@ import { database } from '$lib/database/db';
|
||||
import { desc, inArray } from 'drizzle-orm';
|
||||
import type { PageServerLoad } from './$types';
|
||||
import { events } from '$lib/database/schema';
|
||||
import { logger } from '$lib/logger';
|
||||
import { fetchAllFederatedEvents } from '$lib/fetchFederatedEvents';
|
||||
|
||||
export const load: PageServerLoad = async () => {
|
||||
try {
|
||||
// Fetch all non-private events (public and invite-only) ordered by creation date (newest first)
|
||||
// Fetch all non-private events ordered by creation date (newest first)
|
||||
const publicEvents = await database
|
||||
.select()
|
||||
.from(events)
|
||||
@@ -16,24 +18,36 @@ export const load: PageServerLoad = async () => {
|
||||
const transformedEvents = publicEvents.map((event) => ({
|
||||
id: event.id,
|
||||
name: event.name,
|
||||
date: event.date, // Already in 'YYYY-MM-DD' format
|
||||
time: event.time, // Already in 'HH:MM:SS' format
|
||||
date: event.date,
|
||||
time: event.time,
|
||||
location: event.location,
|
||||
location_type: event.locationType,
|
||||
location_url: event.locationUrl,
|
||||
type: event.type,
|
||||
attendee_limit: event.attendeeLimit, // Note: schema uses camelCase
|
||||
attendee_limit: event.attendeeLimit,
|
||||
visibility: event.visibility,
|
||||
user_id: event.userId, // Note: schema uses camelCase
|
||||
user_id: event.userId,
|
||||
created_at: event.createdAt?.toISOString(),
|
||||
updated_at: event.updatedAt?.toISOString()
|
||||
updated_at: event.updatedAt?.toISOString(),
|
||||
federation: false // Add false for local events
|
||||
}));
|
||||
|
||||
// Fetch federated events from federation.config.js
|
||||
let federatedEvents: typeof transformedEvents = [];
|
||||
try {
|
||||
federatedEvents = await fetchAllFederatedEvents();
|
||||
} catch (error) {
|
||||
logger.error({ error }, 'Error fetching federated events, continuing with local events only');
|
||||
}
|
||||
|
||||
// Merge local and federated events
|
||||
const allEvents = [...transformedEvents, ...federatedEvents];
|
||||
|
||||
return {
|
||||
events: transformedEvents
|
||||
events: allEvents
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error loading public events:', error);
|
||||
logger.error({ error }, 'Error loading events');
|
||||
|
||||
// Return empty array on error to prevent page crash
|
||||
return {
|
||||
|
||||
@@ -267,9 +267,15 @@
|
||||
|
||||
<div class="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
|
||||
{#each filteredEvents as event, i (i)}
|
||||
<div class="rounded-sm border border-slate-200 p-6 shadow-sm">
|
||||
<div class="mb-4">
|
||||
<h3 class="mb-2 text-xl font-bold text-slate-300">{event.name}</h3>
|
||||
{@const isFederated = event.federation === true}
|
||||
<div
|
||||
class="flex flex-col rounded-sm border border-slate-200 bg-slate-800/50
|
||||
p-6 shadow-sm"
|
||||
>
|
||||
<div class="mb-4 flex-1">
|
||||
<div class="mb-2 flex items-center justify-between">
|
||||
<h3 class="text-xl font-bold text-slate-300">{event.name}</h3>
|
||||
</div>
|
||||
<div class="space-y-2 text-sm text-slate-500">
|
||||
<div class="flex items-center space-x-2">
|
||||
<svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
@@ -314,36 +320,58 @@
|
||||
<span>{event.location}</span>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="flex items-center space-x-2">
|
||||
<span
|
||||
class="rounded-sm border px-2 py-1 text-xs font-medium {event.type ===
|
||||
'limited'
|
||||
? 'border-amber-600 text-amber-600'
|
||||
: 'border-teal-500 text-teal-500'}"
|
||||
>
|
||||
{event.type === 'limited' ? t('common.limited') : t('common.unlimited')}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex items-center space-x-2">
|
||||
<span
|
||||
class="rounded-sm border px-2 py-1 text-xs font-medium {event.visibility ===
|
||||
'public'
|
||||
? 'border-teal-500 text-teal-500'
|
||||
: 'border-amber-600 text-amber-600'}"
|
||||
>
|
||||
{event.visibility === 'public' ? t('common.public') : t('common.inviteOnly')}
|
||||
</span>
|
||||
</div>
|
||||
{#if isFederated && event.federation_url}
|
||||
<div class="flex items-center space-x-2">
|
||||
<span
|
||||
class="rounded-sm border border-blue-500 px-2 py-1 text-xs
|
||||
font-medium text-blue-500"
|
||||
>
|
||||
{event.federation_url}
|
||||
</span>
|
||||
</div>{:else}
|
||||
<div class="flex items-center space-x-2">
|
||||
<span
|
||||
class="rounded-sm border px-2 py-1 text-xs font-medium {event.type ===
|
||||
'limited'
|
||||
? 'border-amber-600 text-amber-600'
|
||||
: 'border-teal-500 text-teal-500'}"
|
||||
>
|
||||
{event.type === 'limited' ? t('common.limited') : t('common.unlimited')}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex items-center space-x-2">
|
||||
<span
|
||||
class="rounded-sm border px-2 py-1 text-xs font-medium {event.visibility ===
|
||||
'public'
|
||||
? 'border-teal-500 text-teal-500'
|
||||
: 'border-amber-600 text-amber-600'}"
|
||||
>
|
||||
{event.visibility === 'public'
|
||||
? t('common.public')
|
||||
: t('common.inviteOnly')}
|
||||
</span>
|
||||
</div>{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex">
|
||||
<button
|
||||
on:click={() => goto(`/event/${event.id}`)}
|
||||
class="flex-1 rounded-sm border-2 border-violet-500 bg-violet-400/20 px-4 py-2 font-semibold duration-200 hover:bg-violet-400/70"
|
||||
>
|
||||
{t('discover.viewButton')}
|
||||
</button>
|
||||
<div class="mt-auto flex">
|
||||
{#if isFederated && event.federation_url}
|
||||
<a
|
||||
href="{event.federation_url}/event/{event.id}"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="flex-1 rounded-sm border-2 border-blue-500 bg-blue-400/20 px-4 py-2 text-center font-semibold duration-200 hover:bg-blue-400/70"
|
||||
>
|
||||
View
|
||||
</a>
|
||||
{:else}
|
||||
<button
|
||||
on:click={() => goto(`/event/${event.id}`)}
|
||||
class="flex-1 rounded-sm border-2 border-violet-500 bg-violet-400/20 px-4 py-2 font-semibold duration-200 hover:bg-violet-400/70"
|
||||
>
|
||||
{t('discover.viewButton')}
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { events } from '$lib/database/schema';
|
||||
import { fail } from '@sveltejs/kit';
|
||||
import { eq, desc } from 'drizzle-orm';
|
||||
import type { Actions } from './$types';
|
||||
import { logger } from '$lib/logger';
|
||||
|
||||
export const load = async ({ cookies }) => {
|
||||
const userId = cookies.get('cactoideUserId');
|
||||
@@ -36,7 +37,7 @@ export const load = async ({ cookies }) => {
|
||||
|
||||
return { events: transformedEvents };
|
||||
} catch (error) {
|
||||
console.error('Error loading user events:', error);
|
||||
logger.error({ error, userId }, 'Error loading user events');
|
||||
return { events: [] };
|
||||
}
|
||||
};
|
||||
@@ -68,7 +69,7 @@ export const actions: Actions = {
|
||||
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error('Error deleting event:', error);
|
||||
logger.error({ error, eventId, userId }, 'Error deleting event');
|
||||
return fail(500, { error: 'Failed to delete event' });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,8 @@
|
||||
? 'border-green-300 text-green-400'
|
||||
: 'border-orange-300 text-orange-400'}"
|
||||
>
|
||||
{event.visibility === 'public' ? t('common.public') : t('common.private')}
|
||||
<!-- TODO(polaroi8d): replace with something better solution; message.json using this, beacuse of common.invite-only works here -->
|
||||
{t(`common.${event.visibility}`)}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex items-center space-x-2"></div>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { events, rsvps } from '$lib/database/schema';
|
||||
import { eq, asc } from 'drizzle-orm';
|
||||
import { error, fail } from '@sveltejs/kit';
|
||||
import type { PageServerLoad, Actions } from './$types';
|
||||
import { logger } from '$lib/logger';
|
||||
|
||||
export const load: PageServerLoad = async ({ params, cookies }) => {
|
||||
const eventId = params.id;
|
||||
@@ -70,7 +71,7 @@ export const load: PageServerLoad = async ({ params, cookies }) => {
|
||||
} catch (err) {
|
||||
if (err instanceof Response) throw err; // This is the 404 error
|
||||
|
||||
console.error('Error loading event:', err);
|
||||
logger.error({ error: err, eventId }, 'Error loading event');
|
||||
throw error(500, 'Failed to load event');
|
||||
}
|
||||
};
|
||||
@@ -103,14 +104,15 @@ export const actions: Actions = {
|
||||
// Get current RSVPs
|
||||
const currentRSVPs = await database.select().from(rsvps).where(eq(rsvps.eventId, eventId));
|
||||
|
||||
// Calculate total attendees (including guests)
|
||||
const totalAttendees = currentRSVPs.length + numberOfGuests;
|
||||
// Calculate remaining spots and ensure main attendee + guests fit
|
||||
const newAttendeesCount = 1 + numberOfGuests;
|
||||
const remainingSpots = (eventData.attendeeLimit ?? 0) - currentRSVPs.length;
|
||||
|
||||
// Check if event is full (for limited type events)
|
||||
if (eventData.type === 'limited' && eventData.attendeeLimit) {
|
||||
if (totalAttendees > eventData.attendeeLimit) {
|
||||
if (newAttendeesCount > remainingSpots) {
|
||||
return fail(400, {
|
||||
error: `Event capacity exceeded. You're trying to add ${numberOfGuests + 1} attendees (including yourself), but only ${eventData.attendeeLimit - currentRSVPs.length} spots remain.`
|
||||
error: `Event capacity exceeded. You're trying to add ${newAttendeesCount} attendee${newAttendeesCount === 1 ? '' : 's'} (including yourself), but only ${remainingSpots} spot${remainingSpots === 1 ? '' : 's'} remain.`
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -145,7 +147,7 @@ export const actions: Actions = {
|
||||
|
||||
return { success: true, type: 'add' };
|
||||
} catch (err) {
|
||||
console.error('Error adding RSVP:', err);
|
||||
logger.error({ error: err, eventId, userId, name }, 'Error adding RSVP');
|
||||
return fail(500, { error: 'Failed to add RSVP' });
|
||||
}
|
||||
},
|
||||
@@ -163,7 +165,7 @@ export const actions: Actions = {
|
||||
await database.delete(rsvps).where(eq(rsvps.id, rsvpId));
|
||||
return { success: true, type: 'remove' };
|
||||
} catch (err) {
|
||||
console.error('Error removing RSVP:', err);
|
||||
logger.error({ error: err, rsvpId }, 'Error removing RSVP');
|
||||
return fail(500, { error: 'Failed to remove RSVP' });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -485,19 +485,19 @@
|
||||
{#if success}
|
||||
{#if typeToShow === 'add'}
|
||||
<div
|
||||
class="fixed right-4 bottom-4 z-40 w-128 rounded-sm border border-green-500/30 bg-green-900/20 p-4 text-green-400"
|
||||
class="fixed right-4 bottom-4 z-40 w-128 rounded-sm border border-green-500/30 bg-green-900 p-4 text-green-400"
|
||||
>
|
||||
{success}
|
||||
</div>
|
||||
{:else if typeToShow === 'remove'}
|
||||
<div
|
||||
class="fixed right-4 bottom-4 z-40 w-128 rounded-sm border border-yellow-500/30 bg-yellow-900/20 p-4 text-yellow-400"
|
||||
class="fixed right-4 bottom-4 z-40 w-128 rounded-sm border border-yellow-500/30 bg-yellow-900 p-4 text-yellow-400"
|
||||
>
|
||||
{t('event.removedRsvpSuccessfully')}
|
||||
</div>
|
||||
{:else if typeToShow === 'copy'}
|
||||
<div
|
||||
class="fixed right-4 bottom-4 z-40 w-128 rounded-sm border border-yellow-500/30 bg-yellow-900/20 p-4 text-yellow-400"
|
||||
class="fixed right-4 bottom-4 z-40 w-128 rounded-sm border border-yellow-500/30 bg-yellow-900 p-4 text-yellow-400"
|
||||
>
|
||||
{t('event.eventLinkCopied')}
|
||||
</div>
|
||||
@@ -508,7 +508,7 @@
|
||||
|
||||
{#if error}
|
||||
<div
|
||||
class="fixed right-4 bottom-4 z-40 w-128 rounded-sm border border-red-500/30 bg-red-900/20 p-4 text-red-400"
|
||||
class="fixed right-4 bottom-4 z-40 w-128 rounded-sm border border-red-500/30 bg-red-900 p-4 text-red-400"
|
||||
>
|
||||
{error}
|
||||
</div>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { events, inviteTokens } from '$lib/database/schema';
|
||||
import { eq, and } from 'drizzle-orm';
|
||||
import { fail, redirect } from '@sveltejs/kit';
|
||||
import type { Actions, PageServerLoad } from './$types';
|
||||
import { logger } from '$lib/logger';
|
||||
|
||||
export const load: PageServerLoad = async ({ params, cookies }) => {
|
||||
const eventId = params.id;
|
||||
@@ -75,7 +76,7 @@ export const actions: Actions = {
|
||||
const date = formData.get('date') as string;
|
||||
const time = formData.get('time') as string;
|
||||
const location = formData.get('location') as string;
|
||||
const locationType = formData.get('location_type') as 'none' | 'text' | 'maps';
|
||||
const locationType = formData.get('locationType') as string;
|
||||
const locationUrl = formData.get('location_url') as string;
|
||||
const type = formData.get('type') as 'limited' | 'unlimited';
|
||||
const attendeeLimit = formData.get('attendee_limit') as string;
|
||||
@@ -108,7 +109,7 @@ export const actions: Actions = {
|
||||
});
|
||||
}
|
||||
|
||||
// Check if date is in the past using local timezone (but allow editing past events for corrections)
|
||||
// Check if date is in the past using local timezone
|
||||
const [year, month, day] = date.split('-').map(Number);
|
||||
const eventDate = new Date(year, month - 1, day);
|
||||
const today = new Date();
|
||||
@@ -147,7 +148,6 @@ export const actions: Actions = {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Update the event
|
||||
await database
|
||||
.update(events)
|
||||
@@ -156,7 +156,7 @@ export const actions: Actions = {
|
||||
date: date,
|
||||
time: time,
|
||||
location: location?.trim() || '',
|
||||
locationType: locationType,
|
||||
locationType: locationType as 'none' | 'text' | 'maps',
|
||||
locationUrl: locationType === 'maps' ? locationUrl?.trim() : null,
|
||||
type: type,
|
||||
attendeeLimit: type === 'limited' ? parseInt(attendeeLimit) : null,
|
||||
@@ -165,7 +165,7 @@ export const actions: Actions = {
|
||||
})
|
||||
.where(and(eq(events.id, eventId), eq(events.userId, userId)))
|
||||
.catch((error) => {
|
||||
console.error('Unexpected error updating event', error);
|
||||
logger.error({ error, eventId, userId }, 'Unexpected error updating event');
|
||||
throw error;
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type { EventType, LocationType } from '$lib/types';
|
||||
import type { CreateEventData, EventType, LocationType } from '$lib/types';
|
||||
import { enhance } from '$app/forms';
|
||||
import { goto } from '$app/navigation';
|
||||
import { t } from '$lib/i18n/i18n.js';
|
||||
@@ -7,7 +7,7 @@
|
||||
export let data;
|
||||
export let form;
|
||||
|
||||
let eventData = {
|
||||
let eventData: CreateEventData = {
|
||||
name: data.event.name,
|
||||
date: data.event.date,
|
||||
time: data.event.time,
|
||||
@@ -15,7 +15,7 @@
|
||||
location_type: data.event.locationType || 'none',
|
||||
location_url: data.event.locationUrl || '',
|
||||
type: data.event.type,
|
||||
attendee_limit: data.event.attendeeLimit,
|
||||
attendee_limit: data.event.attendeeLimit || undefined,
|
||||
visibility: data.event.visibility
|
||||
};
|
||||
|
||||
@@ -44,14 +44,14 @@
|
||||
attendee_limit: (values as any).attendee_limit
|
||||
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
parseInt(String((values as any).attendee_limit))
|
||||
: null
|
||||
: undefined
|
||||
};
|
||||
}
|
||||
|
||||
const handleTypeChange = (type: EventType) => {
|
||||
eventData.type = type;
|
||||
if (type === 'unlimited') {
|
||||
eventData.attendee_limit = null;
|
||||
eventData.attendee_limit = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -162,6 +162,11 @@
|
||||
bind:value={eventData.date}
|
||||
min={today}
|
||||
class="border-dark-300 w-full rounded-sm border-2 bg-white px-4 py-3 text-slate-900 shadow-sm transition-all duration-200"
|
||||
on:keydown={(e) => {
|
||||
if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(e.key)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
}}
|
||||
required
|
||||
/>
|
||||
{#if errors.date}
|
||||
@@ -189,6 +194,9 @@
|
||||
|
||||
<!-- Location Type -->
|
||||
<div>
|
||||
<!-- Hidden input to submit locationType value -->
|
||||
<input type="hidden" name="locationType" bind:value={eventData.location_type} />
|
||||
|
||||
<fieldset>
|
||||
<legend class="text-dark-800 mb-3 block text-sm font-semibold">
|
||||
{t('create.locationTypeLabel')}
|
||||
@@ -279,6 +287,9 @@
|
||||
|
||||
<!-- Event Type -->
|
||||
<div>
|
||||
<!-- Hidden input to submit type value -->
|
||||
<input type="hidden" name="type" bind:value={eventData.type} />
|
||||
|
||||
<fieldset>
|
||||
<legend class="text-dark-800 mb-3 block text-sm font-semibold">
|
||||
{t('common.type')} <span class="text-red-400">{t('common.required')}</span>
|
||||
@@ -333,6 +344,9 @@
|
||||
|
||||
<!-- Event Visibility -->
|
||||
<div>
|
||||
<!-- Hidden input to submit visibility value -->
|
||||
<input type="hidden" name="visibility" bind:value={eventData.visibility} />
|
||||
|
||||
<fieldset>
|
||||
<legend class="text-dark-800 mb-3 block text-sm font-semibold">
|
||||
{t('common.visibility')} <span class="text-red-400">{t('common.required')}</span>
|
||||
@@ -444,7 +458,7 @@
|
||||
<!-- Invite Link Toast -->
|
||||
{#if showInviteLinkToast}
|
||||
<div
|
||||
class="fixed right-4 bottom-4 z-40 w-128 rounded-sm border border-yellow-500/30 bg-yellow-900/20 p-4 text-yellow-400"
|
||||
class="fixed right-4 bottom-4 z-40 w-128 rounded-sm border border-yellow-500/30 bg-yellow-900 p-4 text-yellow-400"
|
||||
>
|
||||
{t('event.inviteLinkCopied')}
|
||||
</div>
|
||||
|
||||
@@ -129,14 +129,15 @@ export const actions: Actions = {
|
||||
// Get current RSVPs
|
||||
const currentRSVPs = await database.select().from(rsvps).where(eq(rsvps.eventId, eventId));
|
||||
|
||||
// Calculate total attendees (including guests)
|
||||
const totalAttendees = currentRSVPs.length + numberOfGuests;
|
||||
// Calculate remaining spots and ensure main attendee + guests fit
|
||||
const newAttendeesCount = 1 + numberOfGuests;
|
||||
const remainingSpots = (eventData.attendeeLimit ?? 0) - currentRSVPs.length;
|
||||
|
||||
// Check if event is full (for limited type events)
|
||||
if (eventData.type === 'limited' && eventData.attendeeLimit) {
|
||||
if (totalAttendees > eventData.attendeeLimit) {
|
||||
if (newAttendeesCount > remainingSpots) {
|
||||
return fail(400, {
|
||||
error: `Event capacity exceeded. You're trying to add ${numberOfGuests + 1} attendees (including yourself), but only ${eventData.attendeeLimit - currentRSVPs.length} spots remain.`
|
||||
error: `Event capacity exceeded. You're trying to add ${newAttendeesCount} attendee${newAttendeesCount === 1 ? '' : 's'} (including yourself), but only ${remainingSpots} spot${remainingSpots === 1 ? '' : 's'} remain.`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,13 +450,13 @@
|
||||
{#if success}
|
||||
{#if form?.type === 'add'}
|
||||
<div
|
||||
class="fixed right-4 bottom-4 z-40 w-128 rounded-sm border border-green-500/30 bg-green-900/20 p-4 text-green-400"
|
||||
class="fixed right-4 bottom-4 z-40 w-128 rounded-sm border border-green-500 bg-green-900 p-4 text-green-400"
|
||||
>
|
||||
{success}
|
||||
</div>
|
||||
{:else if form?.type === 'remove'}
|
||||
<div
|
||||
class="fixed right-4 bottom-4 z-40 w-128 rounded-sm border border-yellow-500/30 bg-yellow-900/20 p-4 text-yellow-400"
|
||||
class="fixed right-4 bottom-4 z-40 w-128 rounded-sm border border-yellow-500 bg-yellow-900 p-4 text-yellow-400"
|
||||
>
|
||||
{t('event.removedRsvpSuccessfully')}
|
||||
</div>
|
||||
@@ -465,7 +465,7 @@
|
||||
|
||||
{#if error}
|
||||
<div
|
||||
class="fixed right-4 bottom-4 z-40 w-128 rounded-sm border border-red-500/30 bg-red-900/20 p-4 text-red-400"
|
||||
class="fixed right-4 bottom-4 z-40 w-128 rounded-sm border border-red-500 bg-red-900 p-4 text-red-400"
|
||||
>
|
||||
{error}
|
||||
</div>
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
// src/routes/healthz/+server.ts
|
||||
import { json } from '@sveltejs/kit';
|
||||
import { database } from '$lib/database/db';
|
||||
import { sql } from 'drizzle-orm';
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
await database.execute(sql`select 1`);
|
||||
return json({ ok: true }, { headers: { 'cache-control': 'no-store' } });
|
||||
} catch (err) {
|
||||
return json(
|
||||
{ ok: false, error: (err as Error)?.message, message: 'Database unreachable.' },
|
||||
{ status: 503, headers: { 'cache-control': 'no-store' } }
|
||||
);
|
||||
}
|
||||
}
|
||||
119
src/routes/instance/+page.server.ts
Normal file
119
src/routes/instance/+page.server.ts
Normal file
@@ -0,0 +1,119 @@
|
||||
import type { PageServerLoad } from './$types';
|
||||
import { logger } from '$lib/logger';
|
||||
import federationConfig from '../../../federation.config.js';
|
||||
|
||||
interface InstanceInfo {
|
||||
name: string;
|
||||
publicEventsCount: number;
|
||||
}
|
||||
|
||||
interface HealthStatus {
|
||||
ok: boolean;
|
||||
responseTime?: number;
|
||||
responseTimeUnit?: string;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
interface InstanceData {
|
||||
url: string;
|
||||
name: string | null;
|
||||
events: number | null;
|
||||
healthStatus: 'healthy' | 'unhealthy' | 'unknown';
|
||||
responseTime: number | null;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
async function fetchInstanceInfo(instanceUrl: string): Promise<InstanceInfo | null> {
|
||||
try {
|
||||
const apiUrl = `http://${instanceUrl}/api/federation/info`;
|
||||
const response = await fetch(apiUrl, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/json'
|
||||
},
|
||||
signal: AbortSignal.timeout(10000) // 10 second timeout
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
logger.warn({ apiUrl, status: response.status }, 'Failed to fetch instance info');
|
||||
return null;
|
||||
}
|
||||
|
||||
const data = (await response.json()) as InstanceInfo;
|
||||
return data;
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
{ instanceUrl, error: error instanceof Error ? error.message : 'Unknown error' },
|
||||
'Error fetching instance info'
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchHealthStatus(instanceUrl: string): Promise<HealthStatus | null> {
|
||||
try {
|
||||
const apiUrl = `http://${instanceUrl}/api/healthz`;
|
||||
const response = await fetch(apiUrl, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/json'
|
||||
},
|
||||
signal: AbortSignal.timeout(10000) // 10 second timeout
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
logger.warn({ apiUrl, status: response.status }, 'Failed to fetch health status');
|
||||
return { ok: false, error: `HTTP ${response.status}` };
|
||||
}
|
||||
|
||||
const data = (await response.json()) as HealthStatus;
|
||||
return data;
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
{ instanceUrl, error: error instanceof Error ? error.message : 'Unknown error' },
|
||||
'Error fetching health status'
|
||||
);
|
||||
return { ok: false, error: error instanceof Error ? error.message : 'Unknown error' };
|
||||
}
|
||||
}
|
||||
|
||||
export const load: PageServerLoad = async () => {
|
||||
try {
|
||||
const instances = federationConfig.instances || [];
|
||||
|
||||
// Fetch data from all instances in parallel
|
||||
const instanceDataPromises = instances.map(async (instance): Promise<InstanceData> => {
|
||||
const [info, health] = await Promise.all([
|
||||
fetchInstanceInfo(instance.url),
|
||||
fetchHealthStatus(instance.url)
|
||||
]);
|
||||
|
||||
const responseTime = health?.responseTime ?? null;
|
||||
const healthStatus: 'healthy' | 'unhealthy' | 'unknown' = health?.ok
|
||||
? 'healthy'
|
||||
: health === null
|
||||
? 'unknown'
|
||||
: 'unhealthy';
|
||||
|
||||
return {
|
||||
url: instance.url,
|
||||
name: info?.name ?? null,
|
||||
events: info?.publicEventsCount ?? null,
|
||||
healthStatus,
|
||||
responseTime,
|
||||
error: health?.error
|
||||
};
|
||||
});
|
||||
|
||||
const instanceData = await Promise.all(instanceDataPromises);
|
||||
|
||||
return {
|
||||
instances: instanceData
|
||||
};
|
||||
} catch (error) {
|
||||
logger.error({ error }, 'Error loading instance data');
|
||||
return {
|
||||
instances: []
|
||||
};
|
||||
}
|
||||
};
|
||||
148
src/routes/instance/+page.svelte
Normal file
148
src/routes/instance/+page.svelte
Normal file
@@ -0,0 +1,148 @@
|
||||
<script lang="ts">
|
||||
import { t } from '$lib/i18n/i18n.js';
|
||||
|
||||
interface InstanceData {
|
||||
url: string;
|
||||
name: string | null;
|
||||
events: number | null;
|
||||
healthStatus: 'healthy' | 'unhealthy' | 'unknown';
|
||||
responseTime: number | null;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
type InstancePageData = {
|
||||
instances: InstanceData[];
|
||||
};
|
||||
|
||||
export let data: InstancePageData;
|
||||
|
||||
function getStatusColor(responseTime: number | null): string {
|
||||
if (responseTime === null) return 'bg-gray-400';
|
||||
if (responseTime < 10) return 'bg-green-500';
|
||||
if (responseTime <= 30) return 'bg-yellow-500';
|
||||
return 'bg-red-500';
|
||||
}
|
||||
|
||||
function formatResponseTime(responseTime: number | null): string {
|
||||
if (responseTime === null) return t('instance.notAvailable');
|
||||
return `${responseTime} ms`;
|
||||
}
|
||||
|
||||
function getHealthStatusText(status: 'healthy' | 'unhealthy' | 'unknown'): string {
|
||||
switch (status) {
|
||||
case 'healthy':
|
||||
return t('instance.healthStatusHealthy');
|
||||
case 'unhealthy':
|
||||
return t('instance.healthStatusUnhealthy');
|
||||
case 'unknown':
|
||||
return t('instance.healthStatusUnknown');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="container mx-auto px-4 py-16 text-white">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full rounded-lg border border-slate-600 bg-slate-800/50 shadow-sm">
|
||||
<thead class="bg-slate-800">
|
||||
<tr>
|
||||
<th
|
||||
class="px-6 py-3 text-left text-xs font-medium tracking-wider text-slate-400 uppercase"
|
||||
>
|
||||
{t('instance.name')}
|
||||
</th>
|
||||
<th
|
||||
class="px-6 py-3 text-left text-xs font-medium tracking-wider text-slate-400 uppercase"
|
||||
>
|
||||
{t('instance.url')}
|
||||
</th>
|
||||
<th
|
||||
class="px-6 py-3 text-left text-xs font-medium tracking-wider text-slate-400 uppercase"
|
||||
>
|
||||
{t('instance.events')}
|
||||
</th>
|
||||
<th
|
||||
class="px-6 py-3 text-left text-xs font-medium tracking-wider text-slate-400 uppercase"
|
||||
>
|
||||
{t('instance.healthStatus')}
|
||||
</th>
|
||||
<th
|
||||
class="px-6 py-3 text-left text-xs font-medium tracking-wider text-slate-400 uppercase"
|
||||
>
|
||||
{t('instance.responseTime')}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-700">
|
||||
{#each data.instances as instance, i (i)}
|
||||
<tr class="hover:bg-slate-700/50">
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<span class="text-sm font-medium text-slate-300">
|
||||
{instance.name || t('instance.notAvailable')}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<a
|
||||
href="http://{instance.url}"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="text-sm text-slate-400 hover:text-violet-300/80"
|
||||
>
|
||||
{instance.url}
|
||||
</a>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<span class="text-sm text-slate-300">
|
||||
{instance.events !== null ? instance.events : t('instance.notAvailable')}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="flex items-center">
|
||||
<span
|
||||
class="mr-2 inline-block h-3 w-3 rounded-full {getStatusColor(
|
||||
instance.responseTime
|
||||
)}"
|
||||
title={getHealthStatusText(instance.healthStatus)}
|
||||
></span>
|
||||
<span class="text-sm text-slate-300 capitalize">
|
||||
{getHealthStatusText(instance.healthStatus)}
|
||||
</span>
|
||||
{#if instance.error}
|
||||
<span class="ml-2 text-xs text-slate-500">({instance.error})</span>
|
||||
{/if}
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="flex items-center">
|
||||
<span
|
||||
class="mr-2 inline-block h-3 w-3 rounded-full {getStatusColor(
|
||||
instance.responseTime
|
||||
)}"
|
||||
></span>
|
||||
<span class="text-sm text-slate-300">
|
||||
{formatResponseTime(instance.responseTime)}
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p class="py-8 text-center text-slate-400">
|
||||
{t('instance.description')}
|
||||
<a
|
||||
href="https://github.com/cactoide/cactoide/blob/main/federation.config.js"
|
||||
class="text-violet-300/80">{t('instance.configFile')}</a
|
||||
>
|
||||
{t('instance.file')}
|
||||
</p>
|
||||
|
||||
{#if data.instances.length === 0}
|
||||
<div class="py-8 text-center text-slate-500">{t('instance.noInstances')}</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
/* Additional styles if needed */
|
||||
</style>
|
||||
151
static/llms.txt
Normal file
151
static/llms.txt
Normal file
@@ -0,0 +1,151 @@
|
||||
# Cactoide
|
||||
|
||||
> A federated mobile-first event RSVP platform built with SvelteKit. Cactoide is an open-source alternative to big tech event platforms like Meetup.com, Eventbrite, and Luma. It allows users to create events, share unique URLs, and collect RSVPs without any registration required. Features include built-in federation for decentralized event discovery across multiple instances, iCal integration, smart capacity limits, and a no-signup approach. The platform uses PostgreSQL with Drizzle ORM, implements federation via configurable instance lists, and supports multiple languages through a simple i18n system.
|
||||
|
||||
Cactoide is an open-source event management platform licensed under AGPL-3.0, designed as a privacy-focused alternative to centralized event platforms. Unlike Meetup.com, Eventbrite, Luma, and other big tech solutions, Cactoide requires no user accounts, collects minimal data, and operates on a federated model that gives users control over their events and data. Events can be public, private, or invite-only. The platform supports both limited and unlimited RSVP capacity.
|
||||
|
||||
## Architecture
|
||||
|
||||
The project is built with:
|
||||
- **Frontend**: SvelteKit 5 with TypeScript, Tailwind CSS
|
||||
- **Backend**: SvelteKit server routes and API endpoints
|
||||
- **Database**: PostgreSQL with Drizzle ORM
|
||||
- **Deployment**: Docker and Docker Compose support
|
||||
|
||||
Key architectural decisions:
|
||||
- File-based routing (SvelteKit conventions)
|
||||
- Server-side rendering for all pages
|
||||
- Cookie-based user identification (no authentication system)
|
||||
- Federation via HTTP API endpoints between instances
|
||||
|
||||
## API Endpoints
|
||||
|
||||
- [Health Check](/api/healthz): Returns instance health status and response time in milliseconds
|
||||
- [Federation Events](/api/federation/events): Returns all public events from the instance (requires FEDERATION_INSTANCE env variable)
|
||||
- [Federation Info](/api/federation/info): Returns instance name and public events count (requires FEDERATION_INSTANCE env variable)
|
||||
|
||||
## Database Schema
|
||||
|
||||
The database uses three main tables:
|
||||
- **events**: Stores event information (id, name, date, time, location, type, visibility, attendee_limit, user_id)
|
||||
- **rsvps**: Stores RSVP responses (id, event_id, name, user_id, created_at)
|
||||
- **invite_tokens**: Stores invite tokens for invite-only events (id, event_id, token, expires_at)
|
||||
|
||||
Event visibility can be: public, private, or invite-only. Event types can be: limited or unlimited.
|
||||
|
||||
## Federation
|
||||
|
||||
Federation allows multiple Cactoide instances to share and discover public events. Configuration is managed through `federation.config.js` which contains:
|
||||
- Instance name (display name for the instance)
|
||||
- Instance list (array of federated instance URLs to discover events from)
|
||||
|
||||
To enable federation on an instance:
|
||||
1. Set `FEDERATION_INSTANCE=true` environment variable
|
||||
2. Configure instance name in `federation.config.js`
|
||||
3. Add other instance URLs to the instances array to discover their events
|
||||
|
||||
Federated instances are displayed at `/instance` with health status, response times, and event counts.
|
||||
|
||||
## Routes
|
||||
|
||||
- `/` - Landing page (can be disabled with PUBLIC_LANDING_INFO=false)
|
||||
- `/create` - Event creation form
|
||||
- `/discover` - Public events discovery page with search and filters
|
||||
- `/event/[id]` - Individual event page with RSVP functionality
|
||||
- `/instance` - Federation instances status page
|
||||
|
||||
## Code Structure
|
||||
|
||||
### src/routes/
|
||||
SvelteKit file-based routing system. Each folder represents a route, with `+page.svelte` for UI and `+page.server.ts` for server-side data loading.
|
||||
|
||||
- [src/routes/](https://github.com/polaroi8d/cactoide/tree/main/src/routes): Main routing directory
|
||||
- `+layout.svelte` / `+layout.server.ts`: Root layout component and server-side data loading for all pages
|
||||
- `+page.svelte` / `+page.server.ts`: Landing/home page
|
||||
- `+error.svelte`: Global error page component
|
||||
- [src/routes/create/](https://github.com/polaroi8d/cactoide/tree/main/src/routes/create): Event creation form page
|
||||
- [src/routes/discover/](https://github.com/polaroi8d/cactoide/tree/main/src/routes/discover): Public events discovery page with search and filtering
|
||||
- [src/routes/event/[id]/](https://github.com/polaroi8d/cactoide/tree/main/src/routes/event/[id]): Dynamic route for individual event pages
|
||||
- `edit/`: Event editing functionality
|
||||
- `invite/[token]/`: Invite-only event access via token
|
||||
- [src/routes/instance/](https://github.com/polaroi8d/cactoide/tree/main/src/routes/instance): Federation instances status monitoring page
|
||||
- [src/routes/api/](https://github.com/polaroi8d/cactoide/tree/main/src/routes/api): API endpoints
|
||||
- `healthz/+server.ts`: Health check endpoint with response time
|
||||
- `federation/events/+server.ts`: Returns public events for federation (requires FEDERATION_INSTANCE)
|
||||
- `federation/info/+server.ts`: Returns instance name and public events count (requires FEDERATION_INSTANCE)
|
||||
|
||||
### src/lib/
|
||||
Shared library code accessible via `$lib` alias throughout the application.
|
||||
|
||||
- [src/lib/](https://github.com/polaroi8d/cactoide/tree/main/src/lib): Core library directory
|
||||
- [src/lib/components/](https://github.com/polaroi8d/cactoide/tree/main/src/lib/components): Reusable Svelte components
|
||||
- `Navbar.svelte`: Main navigation bar component
|
||||
- `CalendarModal.svelte`: Calendar integration modal for iCal downloads
|
||||
- [src/lib/database/](https://github.com/polaroi8d/cactoide/tree/main/src/lib/database): Database layer
|
||||
- `schema.ts`: Drizzle ORM schema definitions (events, rsvps, invite_tokens tables)
|
||||
- `db.ts`: Database connection and Drizzle instance setup
|
||||
- `healthCheck.ts`: Database health check utilities
|
||||
- [src/lib/i18n/](https://github.com/polaroi8d/cactoide/tree/main/src/lib/i18n): Internationalization
|
||||
- `i18n.ts`: i18n initialization and translation function
|
||||
- `messages.json`: Default English translations
|
||||
- `it.json`: Italian translation file (example of additional language)
|
||||
- `types.ts`: TypeScript type definitions (Event, RSVP, EventType, EventVisibility, LocationType, etc.)
|
||||
- `dateHelpers.ts`: Date and time formatting utilities, time range filtering for events
|
||||
- `calendarHelpers.ts`: iCal file generation and calendar service link creation (Google Calendar, Outlook, etc.)
|
||||
- `fetchFederatedEvents.ts`: Federation logic for fetching events from other Cactoide instances
|
||||
- `inviteTokenHelpers.ts`: Invite token generation and expiration calculation utilities
|
||||
- `generateUserId.ts`: User ID generation for cookie-based user identification
|
||||
- `logger.ts`: Pino-based logging configuration
|
||||
- `index.ts`: Library entry point (currently placeholder)
|
||||
|
||||
### src/
|
||||
Root source directory containing application configuration and entry points.
|
||||
|
||||
- `app.html`: HTML template for the application
|
||||
- `app.css`: Global CSS styles and Tailwind imports
|
||||
- `app.d.ts`: TypeScript type declarations
|
||||
- `hooks.server.ts`: SvelteKit server hooks for request handling, user ID cookie management, and error handling
|
||||
|
||||
### Root Level Directories
|
||||
|
||||
- [database/](https://github.com/polaroi8d/cactoide/tree/main/database): Database initialization and migration files
|
||||
- `init.sql`: Database schema initialization script (creates tables, enums, indexes)
|
||||
- `seed.sql`: Sample data for development and testing
|
||||
- [database/migrations/](https://github.com/polaroi8d/cactoide/tree/main/database/migrations): SQL migration files for schema changes
|
||||
- [static/](https://github.com/polaroi8d/cactoide/tree/main/static): Static assets served directly by the web server
|
||||
- `favicon.ico`: Site favicon
|
||||
- `robots.txt`: Search engine crawler directives
|
||||
- `llms.txt`: This file - LLM-friendly project documentation
|
||||
- [scripts/](https://github.com/polaroi8d/cactoide/tree/main/scripts): Utility scripts
|
||||
- `i18n-check.sh`: Translation file validation script
|
||||
- [docs/](https://github.com/polaroi8d/cactoide/tree/main/docs): Documentation assets
|
||||
- `federation_example.png`: Screenshot example for federation documentation
|
||||
|
||||
### Configuration Files
|
||||
|
||||
- `federation.config.js`: Federation configuration (instance name and list of federated instance URLs)
|
||||
- `package.json`: Node.js dependencies and scripts
|
||||
- `svelte.config.js`: SvelteKit configuration (adapter, preprocessors)
|
||||
- `vite.config.ts`: Vite build tool configuration
|
||||
- `tailwind.config.js`: Tailwind CSS configuration
|
||||
- `tsconfig.json`: TypeScript compiler configuration
|
||||
- `eslint.config.js`: ESLint linting rules
|
||||
- `docker-compose.yml`: Docker Compose setup for local development with PostgreSQL
|
||||
- `Dockerfile`: Production Docker image configuration
|
||||
- `Makefile`: Development command shortcuts (db-only, i18n validation, etc.)
|
||||
|
||||
## Configuration
|
||||
|
||||
Key environment variables:
|
||||
- `DATABASE_URL`: PostgreSQL connection string
|
||||
- `FEDERATION_INSTANCE`: Set to `true` to enable federation API endpoints
|
||||
- `PUBLIC_LANDING_INFO`: Set to `false` to disable landing page and redirect to `/discover`
|
||||
|
||||
## Optional
|
||||
|
||||
- [docker-compose.yml](https://github.com/polaroi8d/cactoide/blob/main/docker-compose.yml): Docker Compose configuration for local development
|
||||
- [Dockerfile](https://github.com/polaroi8d/cactoide/blob/main/Dockerfile): Production Docker image configuration
|
||||
- [database/init.sql](https://github.com/polaroi8d/cactoide/blob/main/database/init.sql): Database initialization SQL
|
||||
- [database/migrations/](https://github.com/polaroi8d/cactoide/tree/main/database/migrations): Database migration files
|
||||
- [Makefile](https://github.com/polaroi8d/cactoide/blob/main/Makefile): Development commands and shortcuts
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"skipLibCheck": true,
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"moduleResolution": "bundler"
|
||||
"moduleResolution": "bundler",
|
||||
"types": ["node"]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user