@cloudgrid-io/mcp 0.13.0 → 0.14.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.
- package/package.json +1 -1
- package/src/corpus/capability-map.md +68 -7
- package/src/corpus/templates/_cloudgrid.yaml.reference +228 -0
- package/src/corpus/templates/admin-dashboard/cloudgrid.yaml +226 -8
- package/src/corpus/templates/admin-dashboard/index.md +3 -0
- package/src/corpus/templates/ai-app/cloudgrid.yaml +225 -11
- package/src/corpus/templates/ai-app/index.md +3 -11
- package/src/corpus/templates/ai-knowledge-base/AGENTS.md +254 -0
- package/src/corpus/templates/ai-knowledge-base/README.md +28 -0
- package/src/corpus/templates/ai-knowledge-base/cloudgrid.yaml +238 -0
- package/src/corpus/templates/ai-knowledge-base/index.md +81 -0
- package/src/corpus/templates/analytics-dashboard/README.md +85 -0
- package/src/corpus/templates/analytics-dashboard/cloudgrid.yaml +232 -0
- package/src/corpus/templates/analytics-dashboard/index.md +316 -0
- package/src/corpus/templates/analytics-dashboard/services/web/app/api/events/route.js +60 -0
- package/src/corpus/templates/analytics-dashboard/services/web/app/event-form.js +100 -0
- package/src/corpus/templates/analytics-dashboard/services/web/app/layout.js +41 -0
- package/src/corpus/templates/analytics-dashboard/services/web/app/page.js +54 -0
- package/src/corpus/templates/analytics-dashboard/services/web/lib/db.js +32 -0
- package/src/corpus/templates/analytics-dashboard/services/web/package.json +16 -0
- package/src/corpus/templates/api-dashboard/README.md +84 -0
- package/src/corpus/templates/api-dashboard/cloudgrid.yaml +233 -0
- package/src/corpus/templates/api-dashboard/index.md +310 -0
- package/src/corpus/templates/api-dashboard/services/web/app/api/requests/route.js +62 -0
- package/src/corpus/templates/api-dashboard/services/web/app/dashboard.js +156 -0
- package/src/corpus/templates/api-dashboard/services/web/app/layout.js +42 -0
- package/src/corpus/templates/api-dashboard/services/web/app/page.js +39 -0
- package/src/corpus/templates/api-dashboard/services/web/lib/db.js +32 -0
- package/src/corpus/templates/api-dashboard/services/web/package.json +16 -0
- package/src/corpus/templates/api-docs/cloudgrid.yaml +222 -4
- package/src/corpus/templates/api-docs/index.md +3 -5
- package/src/corpus/templates/api-service/cloudgrid.yaml +224 -9
- package/src/corpus/templates/api-service/index.md +3 -11
- package/src/corpus/templates/app-with-data/cloudgrid.yaml +226 -8
- package/src/corpus/templates/app-with-data/index.md +3 -8
- package/src/corpus/templates/appointment-booking/AGENTS.md +223 -0
- package/src/corpus/templates/appointment-booking/README.md +16 -0
- package/src/corpus/templates/appointment-booking/cloudgrid.yaml +250 -0
- package/src/corpus/templates/appointment-booking/index.md +72 -0
- package/src/corpus/templates/approval-workflow/AGENTS.md +170 -0
- package/src/corpus/templates/approval-workflow/README.md +12 -0
- package/src/corpus/templates/approval-workflow/cloudgrid.yaml +237 -0
- package/src/corpus/templates/approval-workflow/index.md +58 -0
- package/src/corpus/templates/billing-dashboard/AGENTS.md +199 -0
- package/src/corpus/templates/billing-dashboard/README.md +18 -0
- package/src/corpus/templates/billing-dashboard/cloudgrid.yaml +235 -0
- package/src/corpus/templates/billing-dashboard/index.md +87 -0
- package/src/corpus/templates/blog-cms/README.md +94 -0
- package/src/corpus/templates/blog-cms/cloudgrid.yaml +233 -0
- package/src/corpus/templates/blog-cms/index.md +358 -0
- package/src/corpus/templates/blog-cms/services/web/app/admin/admin-editor.js +133 -0
- package/src/corpus/templates/blog-cms/services/web/app/admin/page.js +33 -0
- package/src/corpus/templates/blog-cms/services/web/app/api/posts/route.js +84 -0
- package/src/corpus/templates/blog-cms/services/web/app/layout.js +47 -0
- package/src/corpus/templates/blog-cms/services/web/app/page.js +56 -0
- package/src/corpus/templates/blog-cms/services/web/app/posts/[slug]/page.js +45 -0
- package/src/corpus/templates/blog-cms/services/web/lib/db.js +32 -0
- package/src/corpus/templates/blog-cms/services/web/package.json +16 -0
- package/src/corpus/templates/booking-system/AGENTS.md +189 -0
- package/src/corpus/templates/booking-system/README.md +17 -0
- package/src/corpus/templates/booking-system/cloudgrid.yaml +248 -0
- package/src/corpus/templates/booking-system/index.md +86 -0
- package/src/corpus/templates/calendar-scheduler/AGENTS.md +226 -0
- package/src/corpus/templates/calendar-scheduler/README.md +25 -0
- package/src/corpus/templates/calendar-scheduler/cloudgrid.yaml +259 -0
- package/src/corpus/templates/calendar-scheduler/index.md +85 -0
- package/src/corpus/templates/changelog/cloudgrid.yaml +222 -4
- package/src/corpus/templates/changelog/index.md +3 -5
- package/src/corpus/templates/company-website/README.md +54 -0
- package/src/corpus/templates/company-website/cloudgrid.yaml +233 -0
- package/src/corpus/templates/company-website/index.html +309 -0
- package/src/corpus/templates/company-website/index.md +29 -0
- package/src/corpus/templates/course-platform/AGENTS.md +161 -0
- package/src/corpus/templates/course-platform/README.md +26 -0
- package/src/corpus/templates/course-platform/cloudgrid.yaml +237 -0
- package/src/corpus/templates/course-platform/index.md +70 -0
- package/src/corpus/templates/crm/cloudgrid.yaml +226 -8
- package/src/corpus/templates/crm/index.md +3 -0
- package/src/corpus/templates/dashboard/cloudgrid.yaml +228 -4
- package/src/corpus/templates/dashboard/index.md +3 -5
- package/src/corpus/templates/deck/cloudgrid.yaml +228 -4
- package/src/corpus/templates/deck/index.md +3 -5
- package/src/corpus/templates/directory/README.md +75 -0
- package/src/corpus/templates/directory/cloudgrid.yaml +233 -0
- package/src/corpus/templates/directory/index.md +334 -0
- package/src/corpus/templates/directory/services/web/app/api/entries/route.js +63 -0
- package/src/corpus/templates/directory/services/web/app/directory-list.js +146 -0
- package/src/corpus/templates/directory/services/web/app/layout.js +44 -0
- package/src/corpus/templates/directory/services/web/app/page.js +38 -0
- package/src/corpus/templates/directory/services/web/lib/db.js +32 -0
- package/src/corpus/templates/directory/services/web/package.json +16 -0
- package/src/corpus/templates/docs-site/cloudgrid.yaml +222 -4
- package/src/corpus/templates/docs-site/index.md +3 -5
- package/src/corpus/templates/erp/AGENTS.md +116 -0
- package/src/corpus/templates/erp/README.md +17 -0
- package/src/corpus/templates/erp/cloudgrid.yaml +235 -0
- package/src/corpus/templates/erp/index.md +81 -0
- package/src/corpus/templates/event-board/README.md +74 -0
- package/src/corpus/templates/event-board/cloudgrid.yaml +233 -0
- package/src/corpus/templates/event-board/index.md +299 -0
- package/src/corpus/templates/event-board/services/web/app/api/events/route.js +61 -0
- package/src/corpus/templates/event-board/services/web/app/event-form.js +118 -0
- package/src/corpus/templates/event-board/services/web/app/layout.js +39 -0
- package/src/corpus/templates/event-board/services/web/app/page.js +34 -0
- package/src/corpus/templates/event-board/services/web/lib/db.js +32 -0
- package/src/corpus/templates/event-board/services/web/package.json +16 -0
- package/src/corpus/templates/expense-tracker/README.md +76 -0
- package/src/corpus/templates/expense-tracker/cloudgrid.yaml +233 -0
- package/src/corpus/templates/expense-tracker/index.md +305 -0
- package/src/corpus/templates/expense-tracker/services/web/app/api/expenses/route.js +61 -0
- package/src/corpus/templates/expense-tracker/services/web/app/expense-form.js +145 -0
- package/src/corpus/templates/expense-tracker/services/web/app/layout.js +42 -0
- package/src/corpus/templates/expense-tracker/services/web/app/page.js +34 -0
- package/src/corpus/templates/expense-tracker/services/web/lib/db.js +32 -0
- package/src/corpus/templates/expense-tracker/services/web/package.json +16 -0
- package/src/corpus/templates/feature-request-board/README.md +87 -0
- package/src/corpus/templates/feature-request-board/cloudgrid.yaml +233 -0
- package/src/corpus/templates/feature-request-board/index.md +317 -0
- package/src/corpus/templates/feature-request-board/services/web/app/api/requests/route.js +92 -0
- package/src/corpus/templates/feature-request-board/services/web/app/board.js +91 -0
- package/src/corpus/templates/feature-request-board/services/web/app/layout.js +43 -0
- package/src/corpus/templates/feature-request-board/services/web/app/page.js +35 -0
- package/src/corpus/templates/feature-request-board/services/web/lib/db.js +32 -0
- package/src/corpus/templates/feature-request-board/services/web/package.json +16 -0
- package/src/corpus/templates/financial-dashboard/README.md +80 -0
- package/src/corpus/templates/financial-dashboard/cloudgrid.yaml +233 -0
- package/src/corpus/templates/financial-dashboard/index.md +326 -0
- package/src/corpus/templates/financial-dashboard/services/web/app/api/entries/route.js +63 -0
- package/src/corpus/templates/financial-dashboard/services/web/app/entry-board.js +130 -0
- package/src/corpus/templates/financial-dashboard/services/web/app/layout.js +46 -0
- package/src/corpus/templates/financial-dashboard/services/web/app/page.js +31 -0
- package/src/corpus/templates/financial-dashboard/services/web/lib/db.js +32 -0
- package/src/corpus/templates/financial-dashboard/services/web/package.json +16 -0
- package/src/corpus/templates/forum/AGENTS.md +196 -0
- package/src/corpus/templates/forum/README.md +12 -0
- package/src/corpus/templates/forum/cloudgrid.yaml +237 -0
- package/src/corpus/templates/forum/index.md +66 -0
- package/src/corpus/templates/hr-portal/AGENTS.md +174 -0
- package/src/corpus/templates/hr-portal/README.md +14 -0
- package/src/corpus/templates/hr-portal/cloudgrid.yaml +237 -0
- package/src/corpus/templates/hr-portal/index.md +56 -0
- package/src/corpus/templates/internal-tools-portal/AGENTS.md +201 -0
- package/src/corpus/templates/internal-tools-portal/README.md +17 -0
- package/src/corpus/templates/internal-tools-portal/cloudgrid.yaml +237 -0
- package/src/corpus/templates/internal-tools-portal/index.md +62 -0
- package/src/corpus/templates/inventory/README.md +71 -0
- package/src/corpus/templates/inventory/cloudgrid.yaml +233 -0
- package/src/corpus/templates/inventory/index.md +68 -0
- package/src/corpus/templates/inventory/services/web/app/api/items/route.js +88 -0
- package/src/corpus/templates/inventory/services/web/app/inventory-manager.js +101 -0
- package/src/corpus/templates/inventory/services/web/app/layout.js +36 -0
- package/src/corpus/templates/inventory/services/web/app/page.js +37 -0
- package/src/corpus/templates/inventory/services/web/lib/db.js +32 -0
- package/src/corpus/templates/inventory/services/web/package.json +16 -0
- package/src/corpus/templates/invoice/README.md +71 -0
- package/src/corpus/templates/invoice/cloudgrid.yaml +233 -0
- package/src/corpus/templates/invoice/index.md +68 -0
- package/src/corpus/templates/invoice/services/web/app/api/invoices/route.js +82 -0
- package/src/corpus/templates/invoice/services/web/app/invoice-manager.js +101 -0
- package/src/corpus/templates/invoice/services/web/app/layout.js +35 -0
- package/src/corpus/templates/invoice/services/web/app/page.js +34 -0
- package/src/corpus/templates/invoice/services/web/lib/db.js +32 -0
- package/src/corpus/templates/invoice/services/web/package.json +16 -0
- package/src/corpus/templates/job-board/README.md +71 -0
- package/src/corpus/templates/job-board/cloudgrid.yaml +233 -0
- package/src/corpus/templates/job-board/index.md +68 -0
- package/src/corpus/templates/job-board/services/web/app/api/jobs/route.js +66 -0
- package/src/corpus/templates/job-board/services/web/app/job-board.js +73 -0
- package/src/corpus/templates/job-board/services/web/app/layout.js +35 -0
- package/src/corpus/templates/job-board/services/web/app/page.js +32 -0
- package/src/corpus/templates/job-board/services/web/lib/db.js +32 -0
- package/src/corpus/templates/job-board/services/web/package.json +16 -0
- package/src/corpus/templates/kanban/cloudgrid.yaml +226 -8
- package/src/corpus/templates/kanban/index.md +3 -0
- package/src/corpus/templates/landing-page/cloudgrid.yaml +228 -4
- package/src/corpus/templates/landing-page/index.md +3 -5
- package/src/corpus/templates/lms/AGENTS.md +193 -0
- package/src/corpus/templates/lms/README.md +27 -0
- package/src/corpus/templates/lms/cloudgrid.yaml +237 -0
- package/src/corpus/templates/lms/index.md +79 -0
- package/src/corpus/templates/marketplace/AGENTS.md +208 -0
- package/src/corpus/templates/marketplace/README.md +22 -0
- package/src/corpus/templates/marketplace/cloudgrid.yaml +233 -0
- package/src/corpus/templates/marketplace/index.md +76 -0
- package/src/corpus/templates/membership-site/AGENTS.md +160 -0
- package/src/corpus/templates/membership-site/README.md +18 -0
- package/src/corpus/templates/membership-site/cloudgrid.yaml +236 -0
- package/src/corpus/templates/membership-site/index.md +66 -0
- package/src/corpus/templates/monitoring-dashboard/README.md +84 -0
- package/src/corpus/templates/monitoring-dashboard/cloudgrid.yaml +233 -0
- package/src/corpus/templates/monitoring-dashboard/index.md +328 -0
- package/src/corpus/templates/monitoring-dashboard/services/web/app/api/checks/route.js +76 -0
- package/src/corpus/templates/monitoring-dashboard/services/web/app/check-form.js +124 -0
- package/src/corpus/templates/monitoring-dashboard/services/web/app/layout.js +44 -0
- package/src/corpus/templates/monitoring-dashboard/services/web/app/page.js +49 -0
- package/src/corpus/templates/monitoring-dashboard/services/web/lib/db.js +32 -0
- package/src/corpus/templates/monitoring-dashboard/services/web/package.json +16 -0
- package/src/corpus/templates/online-store/AGENTS.md +153 -0
- package/src/corpus/templates/online-store/README.md +16 -0
- package/src/corpus/templates/online-store/cloudgrid.yaml +234 -0
- package/src/corpus/templates/online-store/index.md +81 -0
- package/src/corpus/templates/portfolio/cloudgrid.yaml +222 -4
- package/src/corpus/templates/portfolio/index.md +3 -5
- package/src/corpus/templates/product-catalog/README.md +74 -0
- package/src/corpus/templates/product-catalog/cloudgrid.yaml +232 -0
- package/src/corpus/templates/product-catalog/index.md +330 -0
- package/src/corpus/templates/product-catalog/services/web/app/api/products/route.js +69 -0
- package/src/corpus/templates/product-catalog/services/web/app/catalog.js +153 -0
- package/src/corpus/templates/product-catalog/services/web/app/layout.js +49 -0
- package/src/corpus/templates/product-catalog/services/web/app/page.js +36 -0
- package/src/corpus/templates/product-catalog/services/web/lib/db.js +32 -0
- package/src/corpus/templates/product-catalog/services/web/package.json +16 -0
- package/src/corpus/templates/product-launch/README.md +46 -0
- package/src/corpus/templates/product-launch/cloudgrid.yaml +234 -0
- package/src/corpus/templates/product-launch/index.html +320 -0
- package/src/corpus/templates/product-launch/index.md +34 -0
- package/src/corpus/templates/project-management/README.md +83 -0
- package/src/corpus/templates/project-management/cloudgrid.yaml +233 -0
- package/src/corpus/templates/project-management/index.md +346 -0
- package/src/corpus/templates/project-management/services/web/app/api/projects/route.js +48 -0
- package/src/corpus/templates/project-management/services/web/app/api/tasks/route.js +85 -0
- package/src/corpus/templates/project-management/services/web/app/board.js +182 -0
- package/src/corpus/templates/project-management/services/web/app/layout.js +45 -0
- package/src/corpus/templates/project-management/services/web/app/page.js +49 -0
- package/src/corpus/templates/project-management/services/web/lib/db.js +32 -0
- package/src/corpus/templates/project-management/services/web/package.json +16 -0
- package/src/corpus/templates/property-listings/README.md +76 -0
- package/src/corpus/templates/property-listings/cloudgrid.yaml +233 -0
- package/src/corpus/templates/property-listings/index.md +335 -0
- package/src/corpus/templates/property-listings/services/web/app/api/properties/route.js +73 -0
- package/src/corpus/templates/property-listings/services/web/app/layout.js +45 -0
- package/src/corpus/templates/property-listings/services/web/app/listings.js +152 -0
- package/src/corpus/templates/property-listings/services/web/app/page.js +53 -0
- package/src/corpus/templates/property-listings/services/web/lib/db.js +32 -0
- package/src/corpus/templates/property-listings/services/web/package.json +16 -0
- package/src/corpus/templates/quiz-platform/README.md +84 -0
- package/src/corpus/templates/quiz-platform/cloudgrid.yaml +233 -0
- package/src/corpus/templates/quiz-platform/index.md +313 -0
- package/src/corpus/templates/quiz-platform/services/web/app/api/questions/route.js +69 -0
- package/src/corpus/templates/quiz-platform/services/web/app/layout.js +47 -0
- package/src/corpus/templates/quiz-platform/services/web/app/page.js +37 -0
- package/src/corpus/templates/quiz-platform/services/web/app/quiz.js +188 -0
- package/src/corpus/templates/quiz-platform/services/web/lib/db.js +32 -0
- package/src/corpus/templates/quiz-platform/services/web/package.json +16 -0
- package/src/corpus/templates/report/cloudgrid.yaml +228 -4
- package/src/corpus/templates/report/index.md +3 -5
- package/src/corpus/templates/restaurant-reservations/AGENTS.md +258 -0
- package/src/corpus/templates/restaurant-reservations/README.md +17 -0
- package/src/corpus/templates/restaurant-reservations/cloudgrid.yaml +258 -0
- package/src/corpus/templates/restaurant-reservations/index.md +62 -0
- package/src/corpus/templates/revenue-dashboard/README.md +75 -0
- package/src/corpus/templates/revenue-dashboard/cloudgrid.yaml +233 -0
- package/src/corpus/templates/revenue-dashboard/index.md +307 -0
- package/src/corpus/templates/revenue-dashboard/services/web/app/api/sales/route.js +60 -0
- package/src/corpus/templates/revenue-dashboard/services/web/app/layout.js +40 -0
- package/src/corpus/templates/revenue-dashboard/services/web/app/page.js +87 -0
- package/src/corpus/templates/revenue-dashboard/services/web/app/sale-form.js +63 -0
- package/src/corpus/templates/revenue-dashboard/services/web/lib/db.js +32 -0
- package/src/corpus/templates/revenue-dashboard/services/web/package.json +16 -0
- package/src/corpus/templates/saas-marketing/cloudgrid.yaml +222 -4
- package/src/corpus/templates/saas-marketing/index.md +3 -5
- package/src/corpus/templates/status-page/cloudgrid.yaml +222 -4
- package/src/corpus/templates/status-page/index.md +3 -5
- package/src/corpus/templates/subscription-management/AGENTS.md +191 -0
- package/src/corpus/templates/subscription-management/README.md +21 -0
- package/src/corpus/templates/subscription-management/cloudgrid.yaml +236 -0
- package/src/corpus/templates/subscription-management/index.md +73 -0
- package/src/corpus/templates/task-manager/cloudgrid.yaml +226 -8
- package/src/corpus/templates/task-manager/index.md +3 -0
- package/src/corpus/templates/ticket-system/README.md +71 -0
- package/src/corpus/templates/ticket-system/cloudgrid.yaml +233 -0
- package/src/corpus/templates/ticket-system/index.md +68 -0
- package/src/corpus/templates/ticket-system/services/web/app/api/tickets/route.js +81 -0
- package/src/corpus/templates/ticket-system/services/web/app/layout.js +36 -0
- package/src/corpus/templates/ticket-system/services/web/app/page.js +35 -0
- package/src/corpus/templates/ticket-system/services/web/app/ticket-queue.js +112 -0
- package/src/corpus/templates/ticket-system/services/web/lib/db.js +32 -0
- package/src/corpus/templates/ticket-system/services/web/package.json +16 -0
- package/src/corpus/templates/time-tracking/README.md +81 -0
- package/src/corpus/templates/time-tracking/cloudgrid.yaml +233 -0
- package/src/corpus/templates/time-tracking/index.md +298 -0
- package/src/corpus/templates/time-tracking/services/web/app/api/entries/route.js +66 -0
- package/src/corpus/templates/time-tracking/services/web/app/entry-form.js +106 -0
- package/src/corpus/templates/time-tracking/services/web/app/layout.js +39 -0
- package/src/corpus/templates/time-tracking/services/web/app/page.js +30 -0
- package/src/corpus/templates/time-tracking/services/web/lib/db.js +32 -0
- package/src/corpus/templates/time-tracking/services/web/package.json +16 -0
- package/src/corpus/templates/travel-booking/AGENTS.md +207 -0
- package/src/corpus/templates/travel-booking/README.md +17 -0
- package/src/corpus/templates/travel-booking/cloudgrid.yaml +249 -0
- package/src/corpus/templates/travel-booking/index.md +88 -0
- package/src/corpus/templates/waitlist/cloudgrid.yaml +222 -4
- package/src/corpus/templates/waitlist/index.md +3 -5
- package/src/corpus/templates/web-app/cloudgrid.yaml +228 -4
- package/src/corpus/templates/web-app/index.md +3 -5
- package/src/corpus/workflows/ai-knowledge-base.md +137 -0
- package/src/corpus/workflows/analytics-dashboard.md +104 -0
- package/src/corpus/workflows/api-dashboard.md +102 -0
- package/src/corpus/workflows/appointment-booking.md +143 -0
- package/src/corpus/workflows/approval-workflow.md +124 -0
- package/src/corpus/workflows/billing-dashboard.md +120 -0
- package/src/corpus/workflows/blog-cms.md +104 -0
- package/src/corpus/workflows/booking-system.md +116 -0
- package/src/corpus/workflows/calendar-scheduler.md +134 -0
- package/src/corpus/workflows/company-website.md +46 -0
- package/src/corpus/workflows/course-platform.md +126 -0
- package/src/corpus/workflows/directory.md +101 -0
- package/src/corpus/workflows/erp.md +125 -0
- package/src/corpus/workflows/event-board.md +102 -0
- package/src/corpus/workflows/expense-tracker.md +102 -0
- package/src/corpus/workflows/feature-request-board.md +105 -0
- package/src/corpus/workflows/financial-dashboard.md +103 -0
- package/src/corpus/workflows/forum.md +128 -0
- package/src/corpus/workflows/hr-portal.md +115 -0
- package/src/corpus/workflows/internal-tools-portal.md +125 -0
- package/src/corpus/workflows/inventory.md +101 -0
- package/src/corpus/workflows/invoice.md +101 -0
- package/src/corpus/workflows/job-board.md +101 -0
- package/src/corpus/workflows/lms.md +113 -0
- package/src/corpus/workflows/marketplace.md +123 -0
- package/src/corpus/workflows/membership-site.md +128 -0
- package/src/corpus/workflows/monitoring-dashboard.md +104 -0
- package/src/corpus/workflows/online-store.md +114 -0
- package/src/corpus/workflows/product-catalog.md +105 -0
- package/src/corpus/workflows/product-launch.md +43 -0
- package/src/corpus/workflows/project-management.md +106 -0
- package/src/corpus/workflows/property-listings.md +101 -0
- package/src/corpus/workflows/quiz-platform.md +105 -0
- package/src/corpus/workflows/restaurant-reservations.md +123 -0
- package/src/corpus/workflows/revenue-dashboard.md +102 -0
- package/src/corpus/workflows/subscription-management.md +141 -0
- package/src/corpus/workflows/ticket-system.md +101 -0
- package/src/corpus/workflows/time-tracking.md +104 -0
- package/src/corpus/workflows/travel-booking.md +115 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// App Router route handler for the `projects` collection.
|
|
2
|
+
// GET -> list projects, POST -> add a project, DELETE -> remove a project (and its tasks).
|
|
3
|
+
//
|
|
4
|
+
// To adapt this app, rename the collection and change the fields to match your
|
|
5
|
+
// own data.
|
|
6
|
+
import { NextResponse } from "next/server";
|
|
7
|
+
import { ObjectId } from "mongodb";
|
|
8
|
+
import { getDb } from "../../../lib/db.js";
|
|
9
|
+
|
|
10
|
+
// Never cache — always read/write live data.
|
|
11
|
+
export const dynamic = "force-dynamic";
|
|
12
|
+
|
|
13
|
+
async function projects() {
|
|
14
|
+
const db = await getDb();
|
|
15
|
+
return db.collection("projects");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// GET /api/projects — list all projects, newest first.
|
|
19
|
+
export async function GET() {
|
|
20
|
+
const col = await projects();
|
|
21
|
+
const items = await col.find({}).sort({ createdAt: -1 }).toArray();
|
|
22
|
+
return NextResponse.json(items.map((p) => ({ id: p._id.toString(), name: p.name })));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// POST /api/projects — add a project. Body: { name: string }.
|
|
26
|
+
export async function POST(request) {
|
|
27
|
+
const body = await request.json().catch(() => ({}));
|
|
28
|
+
const name = typeof body.name === "string" ? body.name.trim() : "";
|
|
29
|
+
if (!name) {
|
|
30
|
+
return NextResponse.json({ error: "name is required" }, { status: 400 });
|
|
31
|
+
}
|
|
32
|
+
const col = await projects();
|
|
33
|
+
const res = await col.insertOne({ name, createdAt: new Date() });
|
|
34
|
+
return NextResponse.json({ id: res.insertedId.toString(), name }, { status: 201 });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// DELETE /api/projects?id=<id> — remove a project and all of its tasks.
|
|
38
|
+
export async function DELETE(request) {
|
|
39
|
+
const id = new URL(request.url).searchParams.get("id");
|
|
40
|
+
if (!id || !ObjectId.isValid(id)) {
|
|
41
|
+
return NextResponse.json({ error: "valid id is required" }, { status: 400 });
|
|
42
|
+
}
|
|
43
|
+
const db = await getDb();
|
|
44
|
+
await db.collection("projects").deleteOne({ _id: new ObjectId(id) });
|
|
45
|
+
// Cascade: drop the project's tasks too (tasks store projectId as a string).
|
|
46
|
+
await db.collection("tasks").deleteMany({ projectId: id });
|
|
47
|
+
return NextResponse.json({ ok: true });
|
|
48
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// App Router route handler for the `tasks` collection.
|
|
2
|
+
// GET -> list tasks for a project, POST -> add a task,
|
|
3
|
+
// PATCH -> change a task's status, DELETE -> remove a task.
|
|
4
|
+
//
|
|
5
|
+
// A task document: { projectId: string, title: string, status: "todo"|"doing"|"done",
|
|
6
|
+
// assignee: string, createdAt: Date }.
|
|
7
|
+
import { NextResponse } from "next/server";
|
|
8
|
+
import { ObjectId } from "mongodb";
|
|
9
|
+
import { getDb } from "../../../lib/db.js";
|
|
10
|
+
|
|
11
|
+
// Never cache — always read/write live data.
|
|
12
|
+
export const dynamic = "force-dynamic";
|
|
13
|
+
|
|
14
|
+
const STATUSES = ["todo", "doing", "done"];
|
|
15
|
+
|
|
16
|
+
async function tasks() {
|
|
17
|
+
const db = await getDb();
|
|
18
|
+
return db.collection("tasks");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function shape(t) {
|
|
22
|
+
return {
|
|
23
|
+
id: t._id.toString(),
|
|
24
|
+
projectId: t.projectId,
|
|
25
|
+
title: t.title,
|
|
26
|
+
status: t.status,
|
|
27
|
+
assignee: t.assignee || "",
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// GET /api/tasks?projectId=<id> — list a project's tasks, newest first.
|
|
32
|
+
export async function GET(request) {
|
|
33
|
+
const projectId = new URL(request.url).searchParams.get("projectId");
|
|
34
|
+
if (!projectId) {
|
|
35
|
+
return NextResponse.json({ error: "projectId is required" }, { status: 400 });
|
|
36
|
+
}
|
|
37
|
+
const col = await tasks();
|
|
38
|
+
const items = await col.find({ projectId }).sort({ createdAt: -1 }).toArray();
|
|
39
|
+
return NextResponse.json(items.map(shape));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// POST /api/tasks — add a task. Body: { projectId, title, assignee?, status? }.
|
|
43
|
+
export async function POST(request) {
|
|
44
|
+
const body = await request.json().catch(() => ({}));
|
|
45
|
+
const projectId = typeof body.projectId === "string" ? body.projectId : "";
|
|
46
|
+
const title = typeof body.title === "string" ? body.title.trim() : "";
|
|
47
|
+
const assignee = typeof body.assignee === "string" ? body.assignee.trim() : "";
|
|
48
|
+
const status = STATUSES.includes(body.status) ? body.status : "todo";
|
|
49
|
+
if (!projectId || !ObjectId.isValid(projectId)) {
|
|
50
|
+
return NextResponse.json({ error: "valid projectId is required" }, { status: 400 });
|
|
51
|
+
}
|
|
52
|
+
if (!title) {
|
|
53
|
+
return NextResponse.json({ error: "title is required" }, { status: 400 });
|
|
54
|
+
}
|
|
55
|
+
const col = await tasks();
|
|
56
|
+
const doc = { projectId, title, status, assignee, createdAt: new Date() };
|
|
57
|
+
const res = await col.insertOne(doc);
|
|
58
|
+
return NextResponse.json(shape({ ...doc, _id: res.insertedId }), { status: 201 });
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// PATCH /api/tasks?id=<id> — change a task's status. Body: { status }.
|
|
62
|
+
export async function PATCH(request) {
|
|
63
|
+
const id = new URL(request.url).searchParams.get("id");
|
|
64
|
+
if (!id || !ObjectId.isValid(id)) {
|
|
65
|
+
return NextResponse.json({ error: "valid id is required" }, { status: 400 });
|
|
66
|
+
}
|
|
67
|
+
const body = await request.json().catch(() => ({}));
|
|
68
|
+
if (!STATUSES.includes(body.status)) {
|
|
69
|
+
return NextResponse.json({ error: "status must be todo, doing, or done" }, { status: 400 });
|
|
70
|
+
}
|
|
71
|
+
const col = await tasks();
|
|
72
|
+
await col.updateOne({ _id: new ObjectId(id) }, { $set: { status: body.status } });
|
|
73
|
+
return NextResponse.json({ ok: true });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// DELETE /api/tasks?id=<id> — remove a task.
|
|
77
|
+
export async function DELETE(request) {
|
|
78
|
+
const id = new URL(request.url).searchParams.get("id");
|
|
79
|
+
if (!id || !ObjectId.isValid(id)) {
|
|
80
|
+
return NextResponse.json({ error: "valid id is required" }, { status: 400 });
|
|
81
|
+
}
|
|
82
|
+
const col = await tasks();
|
|
83
|
+
await col.deleteOne({ _id: new ObjectId(id) });
|
|
84
|
+
return NextResponse.json({ ok: true });
|
|
85
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// Client component: renders the project list plus a per-project task board with
|
|
4
|
+
// three status columns (todo / doing / done). Talks to /api/projects and
|
|
5
|
+
// /api/tasks. Kept self-contained — no external UI libraries.
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
|
|
8
|
+
const STATUSES = ["todo", "doing", "done"];
|
|
9
|
+
const LABELS = { todo: "To do", doing: "Doing", done: "Done" };
|
|
10
|
+
|
|
11
|
+
export default function Board({ initialProjects, initialSelectedId, initialTasks }) {
|
|
12
|
+
const [projects, setProjects] = useState(initialProjects);
|
|
13
|
+
const [selectedId, setSelectedId] = useState(initialSelectedId);
|
|
14
|
+
const [tasks, setTasks] = useState(initialTasks);
|
|
15
|
+
const [projectName, setProjectName] = useState("");
|
|
16
|
+
const [taskTitle, setTaskTitle] = useState("");
|
|
17
|
+
const [taskAssignee, setTaskAssignee] = useState("");
|
|
18
|
+
const [busy, setBusy] = useState(false);
|
|
19
|
+
|
|
20
|
+
async function loadTasks(projectId) {
|
|
21
|
+
const res = await fetch(`/api/tasks?projectId=${encodeURIComponent(projectId)}`);
|
|
22
|
+
if (res.ok) setTasks(await res.json());
|
|
23
|
+
else setTasks([]);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function selectProject(id) {
|
|
27
|
+
setSelectedId(id);
|
|
28
|
+
await loadTasks(id);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function addProject(e) {
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
const name = projectName.trim();
|
|
34
|
+
if (!name) return;
|
|
35
|
+
setBusy(true);
|
|
36
|
+
const res = await fetch("/api/projects", {
|
|
37
|
+
method: "POST",
|
|
38
|
+
headers: { "content-type": "application/json" },
|
|
39
|
+
body: JSON.stringify({ name }),
|
|
40
|
+
});
|
|
41
|
+
if (res.ok) {
|
|
42
|
+
const project = await res.json();
|
|
43
|
+
setProjects((prev) => [project, ...prev]);
|
|
44
|
+
setProjectName("");
|
|
45
|
+
setSelectedId(project.id);
|
|
46
|
+
setTasks([]);
|
|
47
|
+
}
|
|
48
|
+
setBusy(false);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function removeProject(id) {
|
|
52
|
+
setBusy(true);
|
|
53
|
+
const res = await fetch(`/api/projects?id=${encodeURIComponent(id)}`, { method: "DELETE" });
|
|
54
|
+
if (res.ok) {
|
|
55
|
+
const next = projects.filter((p) => p.id !== id);
|
|
56
|
+
setProjects(next);
|
|
57
|
+
if (selectedId === id) {
|
|
58
|
+
const fallback = next[0] ? next[0].id : null;
|
|
59
|
+
setSelectedId(fallback);
|
|
60
|
+
if (fallback) await loadTasks(fallback);
|
|
61
|
+
else setTasks([]);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
setBusy(false);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function addTask(e) {
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
const title = taskTitle.trim();
|
|
70
|
+
if (!title || !selectedId) return;
|
|
71
|
+
setBusy(true);
|
|
72
|
+
const res = await fetch("/api/tasks", {
|
|
73
|
+
method: "POST",
|
|
74
|
+
headers: { "content-type": "application/json" },
|
|
75
|
+
body: JSON.stringify({ projectId: selectedId, title, assignee: taskAssignee.trim() }),
|
|
76
|
+
});
|
|
77
|
+
if (res.ok) {
|
|
78
|
+
const task = await res.json();
|
|
79
|
+
setTasks((prev) => [task, ...prev]);
|
|
80
|
+
setTaskTitle("");
|
|
81
|
+
setTaskAssignee("");
|
|
82
|
+
}
|
|
83
|
+
setBusy(false);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function moveTask(id, status) {
|
|
87
|
+
setBusy(true);
|
|
88
|
+
const res = await fetch(`/api/tasks?id=${encodeURIComponent(id)}`, {
|
|
89
|
+
method: "PATCH",
|
|
90
|
+
headers: { "content-type": "application/json" },
|
|
91
|
+
body: JSON.stringify({ status }),
|
|
92
|
+
});
|
|
93
|
+
if (res.ok) setTasks((prev) => prev.map((t) => (t.id === id ? { ...t, status } : t)));
|
|
94
|
+
setBusy(false);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function removeTask(id) {
|
|
98
|
+
setBusy(true);
|
|
99
|
+
const res = await fetch(`/api/tasks?id=${encodeURIComponent(id)}`, { method: "DELETE" });
|
|
100
|
+
if (res.ok) setTasks((prev) => prev.filter((t) => t.id !== id));
|
|
101
|
+
setBusy(false);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<div>
|
|
106
|
+
<form onSubmit={addProject} className="row">
|
|
107
|
+
<input
|
|
108
|
+
value={projectName}
|
|
109
|
+
onChange={(e) => setProjectName(e.target.value)}
|
|
110
|
+
placeholder="New project name…"
|
|
111
|
+
aria-label="New project name"
|
|
112
|
+
/>
|
|
113
|
+
<button type="submit" disabled={busy}>Add project</button>
|
|
114
|
+
</form>
|
|
115
|
+
|
|
116
|
+
<ul className="projects">
|
|
117
|
+
{projects.length === 0 && <li className="empty">No projects yet.</li>}
|
|
118
|
+
{projects.map((p) => (
|
|
119
|
+
<li key={p.id} className={p.id === selectedId ? "active" : ""}>
|
|
120
|
+
<span className="name" onClick={() => selectProject(p.id)}>{p.name}</span>
|
|
121
|
+
<button type="button" onClick={() => removeProject(p.id)} disabled={busy}>Delete</button>
|
|
122
|
+
</li>
|
|
123
|
+
))}
|
|
124
|
+
</ul>
|
|
125
|
+
|
|
126
|
+
{selectedId && (
|
|
127
|
+
<>
|
|
128
|
+
<h2>Tasks</h2>
|
|
129
|
+
<form onSubmit={addTask} className="row">
|
|
130
|
+
<input
|
|
131
|
+
value={taskTitle}
|
|
132
|
+
onChange={(e) => setTaskTitle(e.target.value)}
|
|
133
|
+
placeholder="Task title…"
|
|
134
|
+
aria-label="Task title"
|
|
135
|
+
/>
|
|
136
|
+
<input
|
|
137
|
+
value={taskAssignee}
|
|
138
|
+
onChange={(e) => setTaskAssignee(e.target.value)}
|
|
139
|
+
placeholder="Assignee (optional)"
|
|
140
|
+
aria-label="Assignee"
|
|
141
|
+
/>
|
|
142
|
+
<button type="submit" disabled={busy}>Add task</button>
|
|
143
|
+
</form>
|
|
144
|
+
|
|
145
|
+
<div className="board">
|
|
146
|
+
{STATUSES.map((status) => (
|
|
147
|
+
<div className="col" key={status}>
|
|
148
|
+
<h3>{LABELS[status]}</h3>
|
|
149
|
+
{tasks.filter((t) => t.status === status).length === 0 && (
|
|
150
|
+
<p className="hint">Nothing here.</p>
|
|
151
|
+
)}
|
|
152
|
+
{tasks
|
|
153
|
+
.filter((t) => t.status === status)
|
|
154
|
+
.map((t) => (
|
|
155
|
+
<div className="card" key={t.id}>
|
|
156
|
+
<div className="title">{t.title}</div>
|
|
157
|
+
{t.assignee && <div className="assignee">{t.assignee}</div>}
|
|
158
|
+
<div className="actions">
|
|
159
|
+
{STATUSES.filter((s) => s !== status).map((s) => (
|
|
160
|
+
<button
|
|
161
|
+
key={s}
|
|
162
|
+
type="button"
|
|
163
|
+
onClick={() => moveTask(t.id, s)}
|
|
164
|
+
disabled={busy}
|
|
165
|
+
>
|
|
166
|
+
→ {LABELS[s]}
|
|
167
|
+
</button>
|
|
168
|
+
))}
|
|
169
|
+
<button type="button" onClick={() => removeTask(t.id)} disabled={busy}>
|
|
170
|
+
Delete
|
|
171
|
+
</button>
|
|
172
|
+
</div>
|
|
173
|
+
</div>
|
|
174
|
+
))}
|
|
175
|
+
</div>
|
|
176
|
+
))}
|
|
177
|
+
</div>
|
|
178
|
+
</>
|
|
179
|
+
)}
|
|
180
|
+
</div>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Root layout + plain inline CSS (no external CDNs, fonts, or stylesheets).
|
|
2
|
+
export const metadata = {
|
|
3
|
+
title: "Projects",
|
|
4
|
+
description: "A team project & task board on CloudGrid, backed by grid-shared Mongo.",
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const css = `
|
|
8
|
+
:root { color-scheme: light dark; }
|
|
9
|
+
* { box-sizing: border-box; }
|
|
10
|
+
body { margin: 0; font-family: system-ui, -apple-system, sans-serif; line-height: 1.5; }
|
|
11
|
+
main { max-width: 60rem; margin: 3rem auto; padding: 0 1.25rem; }
|
|
12
|
+
h1 { margin: 0 0 .25rem; }
|
|
13
|
+
h2 { margin: 2rem 0 .75rem; font-size: 1.15rem; }
|
|
14
|
+
.hint { margin: 0 0 1.5rem; opacity: .7; font-size: .9rem; }
|
|
15
|
+
.row { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
|
|
16
|
+
input, select { padding: .5rem .75rem; border: 1px solid #8886; border-radius: .5rem; font: inherit; background: transparent; }
|
|
17
|
+
input { flex: 1; min-width: 8rem; }
|
|
18
|
+
button { padding: .5rem .9rem; border: 1px solid #8886; border-radius: .5rem; background: #6663; font: inherit; cursor: pointer; }
|
|
19
|
+
button:disabled { opacity: .5; cursor: default; }
|
|
20
|
+
ul { list-style: none; padding: 0; margin: 0; }
|
|
21
|
+
.projects li { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .6rem 0; border-bottom: 1px solid #8883; }
|
|
22
|
+
.projects li.active { font-weight: 600; }
|
|
23
|
+
.projects .name { cursor: pointer; flex: 1; }
|
|
24
|
+
li.empty { opacity: .6; }
|
|
25
|
+
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
|
|
26
|
+
.col { border: 1px solid #8883; border-radius: .75rem; padding: .75rem; min-height: 6rem; }
|
|
27
|
+
.col h3 { margin: 0 0 .5rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; opacity: .7; }
|
|
28
|
+
.card { border: 1px solid #8884; border-radius: .5rem; padding: .5rem .6rem; margin-bottom: .5rem; }
|
|
29
|
+
.card .title { font-size: .95rem; }
|
|
30
|
+
.card .assignee { font-size: .8rem; opacity: .65; }
|
|
31
|
+
.card .actions { display: flex; gap: .35rem; margin-top: .4rem; flex-wrap: wrap; }
|
|
32
|
+
.card .actions button { padding: .2rem .5rem; font-size: .75rem; }
|
|
33
|
+
@media (max-width: 40rem) { .board { grid-template-columns: 1fr; } }
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
export default function RootLayout({ children }) {
|
|
37
|
+
return (
|
|
38
|
+
<html lang="en">
|
|
39
|
+
<head>
|
|
40
|
+
<style dangerouslySetInnerHTML={{ __html: css }} />
|
|
41
|
+
</head>
|
|
42
|
+
<body>{children}</body>
|
|
43
|
+
</html>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Home page: a server component reads projects (and, for the selected project, its
|
|
2
|
+
// tasks) straight from Mongo. A client component adds/removes projects and manages
|
|
3
|
+
// the task board via the API routes. Data persists across refresh and across users
|
|
4
|
+
// because it lives in the grid-shared Mongo, not in memory.
|
|
5
|
+
import { getDb } from "../lib/db.js";
|
|
6
|
+
import Board from "./board.js";
|
|
7
|
+
|
|
8
|
+
export const dynamic = "force-dynamic";
|
|
9
|
+
|
|
10
|
+
async function listProjects() {
|
|
11
|
+
const db = await getDb();
|
|
12
|
+
const items = await db.collection("projects").find({}).sort({ createdAt: -1 }).toArray();
|
|
13
|
+
return items.map((p) => ({ id: p._id.toString(), name: p.name }));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function listTasks(projectId) {
|
|
17
|
+
const db = await getDb();
|
|
18
|
+
const items = await db
|
|
19
|
+
.collection("tasks")
|
|
20
|
+
.find({ projectId })
|
|
21
|
+
.sort({ createdAt: -1 })
|
|
22
|
+
.toArray();
|
|
23
|
+
return items.map((t) => ({
|
|
24
|
+
id: t._id.toString(),
|
|
25
|
+
projectId: t.projectId,
|
|
26
|
+
title: t.title,
|
|
27
|
+
status: t.status,
|
|
28
|
+
assignee: t.assignee || "",
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default async function Page({ searchParams }) {
|
|
33
|
+
const projects = await listProjects();
|
|
34
|
+
const sp = await searchParams;
|
|
35
|
+
const selectedId =
|
|
36
|
+
(sp && sp.project && projects.some((p) => p.id === sp.project) && sp.project) ||
|
|
37
|
+
(projects[0] && projects[0].id) ||
|
|
38
|
+
null;
|
|
39
|
+
const tasks = selectedId ? await listTasks(selectedId) : [];
|
|
40
|
+
return (
|
|
41
|
+
<main>
|
|
42
|
+
<h1>Projects</h1>
|
|
43
|
+
<p className="hint">
|
|
44
|
+
A team project & task board persisted in the grid-shared Mongo — survives refresh.
|
|
45
|
+
</p>
|
|
46
|
+
<Board initialProjects={projects} initialSelectedId={selectedId} initialTasks={tasks} />
|
|
47
|
+
</main>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Cached MongoDB client for the App Router.
|
|
2
|
+
//
|
|
3
|
+
// The grid injects the connection string as the DATABASE_MONGODB_URL environment
|
|
4
|
+
// variable (plus the legacy MONGODB_URL alias) at dev-time (`grid dev`) and
|
|
5
|
+
// runtime (after `grid plug`). Read the canonical var first, fall back to the
|
|
6
|
+
// legacy alias. Never hardcode a connection string here and never commit a secret.
|
|
7
|
+
//
|
|
8
|
+
// The env var and client are resolved LAZILY (inside getDb), never at module top
|
|
9
|
+
// level — otherwise `next build` throws when it imports this module for route
|
|
10
|
+
// analysis, before the grid injects the var.
|
|
11
|
+
import { MongoClient } from "mongodb";
|
|
12
|
+
|
|
13
|
+
function clientPromise() {
|
|
14
|
+
const uri = process.env.DATABASE_MONGODB_URL || process.env.MONGODB_URL;
|
|
15
|
+
if (!uri) {
|
|
16
|
+
throw new Error(
|
|
17
|
+
"DATABASE_MONGODB_URL is not set. The grid injects it automatically — run " +
|
|
18
|
+
"this app with `grid dev` locally, or deploy it with `grid plug` (the grid " +
|
|
19
|
+
"injects the DB connection string at runtime). Do not set it by hand.",
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
if (!globalThis.__mongoClientPromise) {
|
|
23
|
+
globalThis.__mongoClientPromise = new MongoClient(uri).connect();
|
|
24
|
+
}
|
|
25
|
+
return globalThis.__mongoClientPromise;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function getDb() {
|
|
29
|
+
const client = await clientPromise();
|
|
30
|
+
// The default DB comes from the connection-string path segment the grid injects.
|
|
31
|
+
return client.db();
|
|
32
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "my-app",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "next dev",
|
|
7
|
+
"build": "next build",
|
|
8
|
+
"start": "next start"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"next": "^15.1.0",
|
|
12
|
+
"react": "^19.0.0",
|
|
13
|
+
"react-dom": "^19.0.0",
|
|
14
|
+
"mongodb": "^6.12.0"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# property-listings template — persistent Next.js + Mongo real-estate site
|
|
2
|
+
|
|
3
|
+
A minimal but real, deployable property listings site. Listings live in the
|
|
4
|
+
grid-shared MongoDB, so they survive refresh and are shared across users/sessions
|
|
5
|
+
— unlike a static page whose state is in memory only.
|
|
6
|
+
|
|
7
|
+
The domain is a `properties` collection with `{ title, price:number, location,
|
|
8
|
+
beds:number, description }`. The UI is a responsive card grid with a
|
|
9
|
+
location/price filter, a per-property detail view, and an admin add form.
|
|
10
|
+
|
|
11
|
+
## How the grid gives you a database
|
|
12
|
+
|
|
13
|
+
You do **not** provision a database or set a connection string. In
|
|
14
|
+
`cloudgrid.yaml` you declare `needs: { database: true }`, and the grid:
|
|
15
|
+
|
|
16
|
+
- provisions shared Mongo for the app, and
|
|
17
|
+
- injects the connection string as the **`DATABASE_MONGODB_URL`** environment
|
|
18
|
+
variable (plus the legacy `MONGODB_URL` alias) — at dev-time (`grid dev`) and
|
|
19
|
+
at runtime (after `grid plug`).
|
|
20
|
+
|
|
21
|
+
The app reads it via `process.env.DATABASE_MONGODB_URL` (with a legacy
|
|
22
|
+
`process.env.MONGODB_URL` fallback) in `services/web/lib/db.js` — **lazily,
|
|
23
|
+
inside the `getDb` getter, never at module top level** (a top-level read fails
|
|
24
|
+
`next build`, which imports the module for route analysis before the grid injects
|
|
25
|
+
the var). Never hardcode a connection string; never commit a secret.
|
|
26
|
+
|
|
27
|
+
> **Declare `needs: { database: true }` (the canonical shape).** The deployer
|
|
28
|
+
> provisions Mongo and injects `DATABASE_MONGODB_URL` (plus the legacy
|
|
29
|
+
> `MONGODB_URL` alias). `requires:` is the deprecated v1 alias — don't author new
|
|
30
|
+
> yaml with it, and never set `needs:` and `requires:` together (the validator
|
|
31
|
+
> rejects the combination).
|
|
32
|
+
|
|
33
|
+
## Service layout
|
|
34
|
+
|
|
35
|
+
App code lives under **`services/web/`**, not the template root. `path:` in
|
|
36
|
+
`cloudgrid.yaml` is the URL mount, not the filesystem path — the service named
|
|
37
|
+
`web` means the CLI looks for `services/web/`. Files at the root fail with
|
|
38
|
+
`Error: Service directory not found: …/services/web`.
|
|
39
|
+
|
|
40
|
+
## Run locally
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm install
|
|
44
|
+
grid dev # runs Next.js with DATABASE_MONGODB_URL injected against dev Mongo
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Deploy
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
grid plug # builds + deploys the folder (async — poll status until live)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
A runtime deploy is asynchronous: `plug` returns `status: building`; poll status
|
|
54
|
+
until the app is live, then use the returned live URL. Re-plug the same entity
|
|
55
|
+
to update the same URL.
|
|
56
|
+
|
|
57
|
+
## File tree
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
cloudgrid.yaml # name + services.web (nextjs) + needs: { database: true }
|
|
61
|
+
services/web/package.json # next, react, react-dom, mongodb driver only
|
|
62
|
+
services/web/lib/db.js # lazy Mongo client from DATABASE_MONGODB_URL (legacy MONGODB_URL fallback)
|
|
63
|
+
services/web/app/layout.js # root layout + inline CSS (grid + card styles)
|
|
64
|
+
services/web/app/page.js # server component: reads/filter properties from Mongo
|
|
65
|
+
services/web/app/listings.js # client: filter controls, card grid, detail view, admin add form
|
|
66
|
+
services/web/app/api/properties/route.js # GET (list + filter) / POST (add) / DELETE (remove)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Adapt it
|
|
70
|
+
|
|
71
|
+
- Rename the `properties` collection in
|
|
72
|
+
`services/web/app/api/properties/route.js` and `services/web/app/page.js`
|
|
73
|
+
(e.g. `rentals`, `homes`).
|
|
74
|
+
- Change the document fields (add photos, sqft, status).
|
|
75
|
+
- Add more filters or routes as the site grows.
|
|
76
|
+
- Add `cache: true` to `needs:` only if you actually need Redis.
|