@mr.dj2u/knowledge 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/content/checklists/ship-test-loop.md +16 -0
  2. package/dist/content/checklists/unified-agent-bundle-validation.md +8 -0
  3. package/dist/content/examples/ship-test-loop.md +13 -0
  4. package/dist/content/examples/unified-agent-bundle-bootstrap.md +8 -0
  5. package/dist/content/guides/animation-performance.md +30 -0
  6. package/dist/content/guides/post-create-onboarding.md +113 -0
  7. package/dist/content/patterns/api/api-routes.md +314 -0
  8. package/dist/content/patterns/api/error-handling.md +311 -0
  9. package/dist/content/patterns/database/drizzle-schema.md +280 -0
  10. package/dist/content/patterns/database/migrations.md +365 -0
  11. package/dist/content/patterns/database/query-organization.md +537 -0
  12. package/dist/content/patterns/database/relations.md +450 -0
  13. package/dist/content/patterns/deployment/build-configuration.md +452 -0
  14. package/dist/content/patterns/deployment/ci-cd-patterns.md +448 -0
  15. package/dist/content/patterns/deployment/environment-config.md +380 -0
  16. package/dist/content/patterns/deployment/hosting-setup.md +425 -0
  17. package/dist/content/patterns/project/configuration-patterns.md +459 -0
  18. package/dist/content/patterns/project/documentation-org.md +506 -0
  19. package/dist/content/patterns/project/folder-structure.md +398 -0
  20. package/dist/content/patterns/project/library-exports.md +465 -0
  21. package/dist/content/patterns/project/monorepo-structure.md +500 -0
  22. package/dist/content/patterns/routing/dynamic-routes.md +221 -0
  23. package/dist/content/patterns/routing/file-based-routing.md +186 -0
  24. package/dist/content/patterns/routing/route-groups.md +429 -0
  25. package/dist/content/patterns/state/persistence-middleware.md +521 -0
  26. package/dist/content/patterns/state/selector-hooks.md +538 -0
  27. package/dist/content/patterns/state/store-organization.md +539 -0
  28. package/dist/content/patterns/state/zustand-patterns.md +348 -0
  29. package/dist/content/patterns/styling/component-styling.md +468 -0
  30. package/dist/content/patterns/styling/responsive-patterns.md +398 -0
  31. package/dist/content/patterns/styling/theme-configuration.md +426 -0
  32. package/dist/content/patterns/styling/uniwind-setup.md +412 -0
  33. package/dist/content/prompts/continue-development.md +27 -0
  34. package/dist/content/prompts/create-expo-super-stack.md +29 -0
  35. package/dist/content/prompts/fix-seo.md +29 -0
  36. package/dist/content/prompts/onboard-new-expo-app.md +11 -0
  37. package/dist/content/prompts/prepare-deploy.md +29 -0
  38. package/dist/content/prompts/project-research-plan.md +29 -0
  39. package/dist/content/prompts/review-expo-project.md +29 -0
  40. package/dist/content/prompts/run-doctor.md +30 -0
  41. package/dist/content/prompts/ship-test-loop.md +24 -0
  42. package/dist/content/reference/create-expo-stack-uniwind.md +29 -0
  43. package/dist/content/reference/doctor-dogfood.md +42 -0
  44. package/dist/content/reference/mcp-sdk-transport.md +30 -0
  45. package/dist/content/reference/package-ci-patterns.md +24 -0
  46. package/dist/content/reference/reference-repo-evacuation.md +31 -0
  47. package/dist/content/resource-index.json +67 -0
  48. package/dist/content/rules/app-folder-architecture.md +13 -0
  49. package/dist/content/rules/env-hygiene.md +9 -0
  50. package/dist/content/rules/seo-metadata.md +7 -0
  51. package/dist/content/rules/ssr-safety.md +9 -0
  52. package/dist/content/skills/api-routes.md +33 -0
  53. package/dist/content/skills/continue-development.md +31 -0
  54. package/dist/content/skills/debugging.md +31 -0
  55. package/dist/content/skills/deployment.md +32 -0
  56. package/dist/content/skills/dev-server-management.md +31 -0
  57. package/dist/content/skills/env-vars.md +32 -0
  58. package/dist/content/skills/expo-router-architecture.md +33 -0
  59. package/dist/content/skills/expo-ssr-safety.md +32 -0
  60. package/dist/content/skills/plugin-creation.md +41 -0
  61. package/dist/content/skills/production-server-patterns.md +31 -0
  62. package/dist/content/skills/project-onboarding.md +31 -0
  63. package/dist/content/skills/research-plan-intake.md +31 -0
  64. package/dist/content/skills/seo-metadata.md +31 -0
  65. package/dist/content/skills/super-stack-startup.md +31 -0
  66. package/dist/content/skills/uniwind-theming.md +32 -0
  67. package/dist/index.d.ts +46 -0
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +369 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/patterns/index.d.ts +78 -0
  72. package/dist/patterns/index.d.ts.map +1 -0
  73. package/dist/patterns/index.js +264 -0
  74. package/dist/patterns/index.js.map +1 -0
  75. package/dist/prompts/index.d.ts +35 -0
  76. package/dist/prompts/index.d.ts.map +1 -0
  77. package/dist/prompts/index.js +270 -0
  78. package/dist/prompts/index.js.map +1 -0
  79. package/dist/skills/index.d.ts +3 -0
  80. package/dist/skills/index.d.ts.map +1 -0
  81. package/dist/skills/index.js +2 -0
  82. package/dist/skills/index.js.map +1 -0
  83. package/package.json +50 -0
@@ -0,0 +1,425 @@
1
+ # Hosting Setup Pattern
2
+
3
+ ## Description
4
+
5
+ Hosting setup involves configuring servers, reverse proxies, SSL/TLS certificates, environment variables, and service management to deploy and run applications in production. This covers static hosting, server-side applications, API deployment, and monitoring.
6
+
7
+ ## When to Use
8
+
9
+ **Configure hosting when:**
10
+ - ✅ Deploying web apps to production
11
+ - ✅ Setting up Node.js servers
12
+ - ✅ Configuring reverse proxies (nginx, Apache)
13
+ - ✅ Managing SSL/TLS certificates
14
+ - ✅ Deploying API servers
15
+ - ✅ Setting up domain and DNS
16
+ - ✅ Configuring service management (systemd, PM2)
17
+ - ✅ Monitoring and logging
18
+
19
+ ## Core Concepts
20
+
21
+ **Hosting Stack Layers:**
22
+ ```
23
+ 1. Domain & DNS → Domain registration, DNS records
24
+ 2. Reverse Proxy → nginx/Apache routing to backend
25
+ 3. SSL/TLS → Certificate generation and renewal
26
+ 4. Application Runtime → Node.js, Python, etc.
27
+ 5. Service Manager → systemd, PM2, Docker
28
+ 6. Logging & Monitoring→ Syslog, application logs
29
+ ```
30
+
31
+ **Key Hosting Decisions:**
32
+ 1. Static hosting vs. server-side
33
+ 2. Single server vs. distributed
34
+ 3. Docker containers vs. native
35
+ 4. SSL certificate strategy
36
+ 5. Service restart strategy
37
+
38
+ ## Code Examples
39
+
40
+ ### Static Hosting (Web Apps)
41
+
42
+ ```yaml
43
+ # File: hosting-config.yml - Static web deployment
44
+ server:
45
+ type: static
46
+ files: ./dist/
47
+
48
+ domain:
49
+ primary: example.com
50
+ aliases:
51
+ - www.example.com
52
+
53
+ ssl:
54
+ provider: letsencrypt
55
+ autoRenew: true
56
+
57
+ cache:
58
+ staticAssets: 1y
59
+ html: 1h
60
+
61
+ gzip: true
62
+ ```
63
+
64
+ ### Nginx Configuration
65
+
66
+ ```nginx
67
+ # File: /etc/nginx/sites-available/app
68
+
69
+ upstream api_backend {
70
+ server 127.0.0.1:3000;
71
+ server 127.0.0.1:3001;
72
+ keepalive 32;
73
+ }
74
+
75
+ server {
76
+ listen 80;
77
+ server_name example.com www.example.com;
78
+
79
+ # Redirect HTTP to HTTPS
80
+ return 301 https://$server_name$request_uri;
81
+ }
82
+
83
+ server {
84
+ listen 443 ssl http2;
85
+ server_name example.com www.example.com;
86
+
87
+ # SSL configuration
88
+ ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
89
+ ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
90
+
91
+ ssl_protocols TLSv1.2 TLSv1.3;
92
+ ssl_ciphers HIGH:!aNULL:!MD5;
93
+ ssl_prefer_server_ciphers on;
94
+
95
+ # Compression
96
+ gzip on;
97
+ gzip_types text/plain text/css text/javascript application/json;
98
+ gzip_min_length 256;
99
+
100
+ # Static files
101
+ location /assets/ {
102
+ alias /var/www/app/dist/assets/;
103
+ expires 1y;
104
+ add_header Cache-Control "public, immutable";
105
+ }
106
+
107
+ # Service worker and manifest
108
+ location ~ ^/(sw\.js|manifest\.json)$ {
109
+ alias /var/www/app/dist/$uri;
110
+ expires 24h;
111
+ add_header Cache-Control "public, max-age=86400";
112
+ }
113
+
114
+ # HTML files
115
+ location ~ \.html?$ {
116
+ alias /var/www/app/dist/;
117
+ expires 1h;
118
+ add_header Cache-Control "public, max-age=3600";
119
+ }
120
+
121
+ # API proxy
122
+ location /api/ {
123
+ proxy_pass http://api_backend/;
124
+ proxy_http_version 1.1;
125
+
126
+ # Headers
127
+ proxy_set_header Connection "";
128
+ proxy_set_header Host $host;
129
+ proxy_set_header X-Real-IP $remote_addr;
130
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
131
+ proxy_set_header X-Forwarded-Proto $scheme;
132
+
133
+ # Timeouts
134
+ proxy_connect_timeout 60s;
135
+ proxy_send_timeout 60s;
136
+ proxy_read_timeout 60s;
137
+
138
+ # Buffering
139
+ proxy_buffering on;
140
+ proxy_buffer_size 4k;
141
+ proxy_buffers 8 4k;
142
+ }
143
+
144
+ # Default location
145
+ location / {
146
+ alias /var/www/app/dist/;
147
+ try_files $uri $uri/ /index.html;
148
+ expires 1h;
149
+ }
150
+ }
151
+ ```
152
+
153
+ ### Service Configuration (Systemd)
154
+
155
+ ```ini
156
+ # File: /etc/systemd/system/app.service
157
+ [Unit]
158
+ Description=Node.js API Server
159
+ After=network.target
160
+
161
+ [Service]
162
+ Type=simple
163
+ User=app
164
+ WorkingDirectory=/home/app/api-server
165
+ ExecStart=/usr/bin/node server.js
166
+ Restart=always
167
+ RestartSec=10
168
+
169
+ # Environment
170
+ Environment="NODE_ENV=production"
171
+ Environment="PORT=3000"
172
+ EnvironmentFile=/home/app/api-server/.env
173
+
174
+ # Resource limits
175
+ MemoryLimit=512M
176
+ CPUQuota=100%
177
+ LimitNOFILE=65536
178
+
179
+ # Logging
180
+ StandardOutput=journal
181
+ StandardError=journal
182
+ SyslogIdentifier=app
183
+
184
+ [Install]
185
+ WantedBy=multi-user.target
186
+ ```
187
+
188
+ ### Environment Configuration File
189
+
190
+ ```bash
191
+ # File: /home/app/api-server/.env
192
+ NODE_ENV=production
193
+ PORT=3000
194
+ HOST=127.0.0.1
195
+
196
+ # Database
197
+ DATABASE_URL=postgresql://user:password@db.example.com:5432/appdb
198
+ DATABASE_SSL=true
199
+ DATABASE_POOL_MAX=10
200
+
201
+ # API Keys
202
+ JWT_SECRET=your-secret-key-here
203
+ API_KEY=your-api-key-here
204
+
205
+ # Service URLs
206
+ CORS_ORIGIN=https://example.com
207
+ APP_URL=https://example.com
208
+ ```
209
+
210
+ ### PM2 Configuration
211
+
212
+ ```javascript
213
+ // File: ecosystem.config.js
214
+ module.exports = {
215
+ apps: [
216
+ {
217
+ name: 'api-server',
218
+ script: './server.js',
219
+ instances: 'max',
220
+ exec_mode: 'cluster',
221
+
222
+ env: {
223
+ NODE_ENV: 'production',
224
+ PORT: 3000,
225
+ },
226
+
227
+ error_file: './logs/error.log',
228
+ out_file: './logs/out.log',
229
+ log_file: './logs/combined.log',
230
+ time_format: 'YYYY-MM-DD HH:mm:ss Z',
231
+
232
+ // Auto restart on crash
233
+ autorestart: true,
234
+ max_memory_restart: '500M',
235
+
236
+ // Watch for changes (development)
237
+ watch: process.env.NODE_ENV === 'development' ? ['.'] : false,
238
+ ignore_watch: ['node_modules', 'logs'],
239
+
240
+ // Graceful shutdown
241
+ kill_timeout: 5000,
242
+ listen_timeout: 3000,
243
+
244
+ // Health check
245
+ max_restarts: 10,
246
+ min_uptime: '10s',
247
+ }
248
+ ],
249
+ };
250
+ ```
251
+
252
+ ### SSL Certificate Setup (Let's Encrypt)
253
+
254
+ ```bash
255
+ #!/bin/bash
256
+ # File: setup-ssl.sh
257
+
258
+ DOMAIN="example.com"
259
+ EMAIL="admin@example.com"
260
+
261
+ # Install certbot
262
+ sudo apt-get install certbot python3-certbot-nginx
263
+
264
+ # Get certificate
265
+ sudo certbot certonly --nginx \
266
+ --non-interactive \
267
+ --agree-tos \
268
+ --email $EMAIL \
269
+ -d $DOMAIN \
270
+ -d www.$DOMAIN
271
+
272
+ # Auto-renewal setup
273
+ sudo systemctl enable certbot.timer
274
+ sudo systemctl start certbot.timer
275
+
276
+ # Verify renewal
277
+ sudo certbot renew --dry-run
278
+ ```
279
+
280
+ ### Docker Deployment
281
+
282
+ ```dockerfile
283
+ # File: Dockerfile
284
+ FROM node:20-alpine
285
+
286
+ WORKDIR /app
287
+
288
+ # Install dependencies
289
+ COPY package*.json ./
290
+ RUN npm ci --only=production
291
+
292
+ # Copy code
293
+ COPY . .
294
+
295
+ # Health check
296
+ HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
297
+ CMD node -e "require('http').get('http://localhost:3000/health', (r) => {if (r.statusCode !== 200) throw new Error(r.statusCode)})"
298
+
299
+ # Expose port
300
+ EXPOSE 3000
301
+
302
+ # Run app
303
+ CMD ["node", "server.js"]
304
+ ```
305
+
306
+ ```yaml
307
+ # File: docker-compose.yml
308
+ version: '3.8'
309
+
310
+ services:
311
+ app:
312
+ build: .
313
+ ports:
314
+ - "3000:3000"
315
+ environment:
316
+ NODE_ENV: production
317
+ DATABASE_URL: postgresql://user:pass@db:5432/app
318
+ depends_on:
319
+ - db
320
+ restart: always
321
+
322
+ db:
323
+ image: postgres:16-alpine
324
+ environment:
325
+ POSTGRES_USER: user
326
+ POSTGRES_PASSWORD: pass
327
+ POSTGRES_DB: app
328
+ volumes:
329
+ - db_data:/var/lib/postgresql/data
330
+ restart: always
331
+
332
+ volumes:
333
+ db_data:
334
+ ```
335
+
336
+ ### Monitoring Setup
337
+
338
+ ```bash
339
+ # File: monitoring.sh
340
+
341
+ # Monitor CPU and memory
342
+ watch -n 1 'ps aux | grep node'
343
+
344
+ # Monitor logs
345
+ tail -f /var/log/app.log
346
+
347
+ # Monitor open connections
348
+ netstat -an | grep ESTABLISHED | wc -l
349
+
350
+ # Monitor disk usage
351
+ df -h
352
+ ```
353
+
354
+ ## Hosting Best Practices
355
+
356
+ ### ✅ DO
357
+
358
+ 1. **Use reverse proxy (nginx/Apache)**
359
+ ```nginx
360
+ upstream backend {
361
+ server 127.0.0.1:3000;
362
+ server 127.0.0.1:3001;
363
+ }
364
+ ```
365
+
366
+ 2. **Enable SSL/TLS**
367
+ ```nginx
368
+ ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
369
+ ssl_protocols TLSv1.2 TLSv1.3;
370
+ ```
371
+
372
+ 3. **Set security headers**
373
+ ```nginx
374
+ add_header X-Frame-Options "DENY";
375
+ add_header X-Content-Type-Options "nosniff";
376
+ add_header X-XSS-Protection "1; mode=block";
377
+ ```
378
+
379
+ 4. **Monitor health and logs**
380
+ ```bash
381
+ systemctl status app
382
+ tail -f /var/log/app.log
383
+ ```
384
+
385
+ ### ❌ DON'T
386
+
387
+ 1. **Don't run app as root**
388
+ ```ini
389
+ # ❌ WRONG
390
+ User=root
391
+
392
+ # ✅ RIGHT
393
+ User=app
394
+ ```
395
+
396
+ 2. **Don't expose secrets in logs**
397
+ ```bash
398
+ # ❌ WRONG - Logs secrets
399
+ console.log('API_KEY:', process.env.API_KEY);
400
+
401
+ # ✅ RIGHT - Don't log sensitive data
402
+ console.log('API configured');
403
+ ```
404
+
405
+ 3. **Don't skip SSL/TLS**
406
+ ```nginx
407
+ # ❌ WRONG - No HTTPS
408
+ listen 80;
409
+
410
+ # ✅ RIGHT - HTTPS + redirect
411
+ listen 443 ssl;
412
+ listen 80;
413
+ return 301 https://...;
414
+ ```
415
+
416
+ ## Related Patterns
417
+
418
+ - [Build Configuration](./build-configuration.md) — Build setup
419
+ - [CI/CD Patterns](./ci-cd-patterns.md) — Automated deployment
420
+ - [Environment Configuration](./environment-config.md) — Environment variables
421
+
422
+ ---
423
+
424
+ *Pattern extracted from production repositories: time2pay, PokePages, DJsPortfolio*
425
+ *Files: nginx.conf, systemd services, environment setup scripts*