nitrostack 1.0.54 → 1.0.56

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 (220) hide show
  1. package/dist/cli/commands/init.d.ts.map +1 -1
  2. package/dist/cli/commands/init.js +14 -9
  3. package/dist/cli/commands/init.js.map +1 -1
  4. package/dist/widgets/hooks/index.d.ts +7 -0
  5. package/dist/widgets/hooks/index.d.ts.map +1 -0
  6. package/dist/widgets/hooks/index.js +7 -0
  7. package/dist/widgets/hooks/index.js.map +1 -0
  8. package/dist/widgets/hooks/use-display-mode.d.ts +11 -0
  9. package/dist/widgets/hooks/use-display-mode.d.ts.map +1 -0
  10. package/dist/widgets/hooks/use-display-mode.js +13 -0
  11. package/dist/widgets/hooks/use-display-mode.js.map +1 -0
  12. package/dist/widgets/hooks/use-max-height.d.ts +10 -0
  13. package/dist/widgets/hooks/use-max-height.d.ts.map +1 -0
  14. package/dist/widgets/hooks/use-max-height.js +13 -0
  15. package/dist/widgets/hooks/use-max-height.js.map +1 -0
  16. package/dist/widgets/hooks/use-openai-global.d.ts +12 -0
  17. package/dist/widgets/hooks/use-openai-global.d.ts.map +1 -0
  18. package/dist/widgets/hooks/use-openai-global.js +32 -0
  19. package/dist/widgets/hooks/use-openai-global.js.map +1 -0
  20. package/dist/widgets/hooks/use-theme.d.ts +10 -0
  21. package/dist/widgets/hooks/use-theme.d.ts.map +1 -0
  22. package/dist/widgets/hooks/use-theme.js +12 -0
  23. package/dist/widgets/hooks/use-theme.js.map +1 -0
  24. package/dist/widgets/hooks/use-widget-state.d.ts +18 -0
  25. package/dist/widgets/hooks/use-widget-state.d.ts.map +1 -0
  26. package/dist/widgets/hooks/use-widget-state.js +27 -0
  27. package/dist/widgets/hooks/use-widget-state.js.map +1 -0
  28. package/dist/widgets/hooks/useWidgetSDK.d.ts +47 -0
  29. package/dist/widgets/hooks/useWidgetSDK.d.ts.map +1 -0
  30. package/dist/widgets/hooks/useWidgetSDK.js +67 -0
  31. package/dist/widgets/hooks/useWidgetSDK.js.map +1 -0
  32. package/dist/widgets/index.d.ts +7 -1
  33. package/dist/widgets/index.d.ts.map +1 -1
  34. package/dist/widgets/index.js +11 -1
  35. package/dist/widgets/index.js.map +1 -1
  36. package/dist/widgets/runtime/WidgetLayout.d.ts +32 -0
  37. package/dist/widgets/runtime/WidgetLayout.d.ts.map +1 -0
  38. package/dist/widgets/runtime/WidgetLayout.js +143 -0
  39. package/dist/widgets/runtime/WidgetLayout.js.map +1 -0
  40. package/dist/widgets/runtime/widget-polyfill.d.ts +1 -0
  41. package/dist/widgets/runtime/widget-polyfill.d.ts.map +1 -0
  42. package/dist/widgets/runtime/widget-polyfill.js +28 -0
  43. package/dist/widgets/runtime/widget-polyfill.js.map +1 -0
  44. package/dist/widgets/sdk.d.ts +109 -0
  45. package/dist/widgets/sdk.d.ts.map +1 -0
  46. package/dist/widgets/sdk.js +221 -0
  47. package/dist/widgets/sdk.js.map +1 -0
  48. package/dist/widgets/types.d.ts +89 -0
  49. package/dist/widgets/types.d.ts.map +1 -0
  50. package/dist/widgets/types.js +8 -0
  51. package/dist/widgets/types.js.map +1 -0
  52. package/dist/widgets/utils/media-queries.d.ts +34 -0
  53. package/dist/widgets/utils/media-queries.d.ts.map +1 -0
  54. package/dist/widgets/utils/media-queries.js +42 -0
  55. package/dist/widgets/utils/media-queries.js.map +1 -0
  56. package/package.json +2 -2
  57. package/src/studio/app/chat/page.tsx +274 -137
  58. package/src/studio/app/globals.css +140 -64
  59. package/src/studio/branding.md +807 -0
  60. package/src/studio/components/WidgetRenderer.tsx +222 -16
  61. package/src/studio/lib/llm-service.ts +39 -39
  62. package/templates/typescript-oauth/.env.example +27 -0
  63. package/templates/typescript-oauth/README.md +226 -306
  64. package/templates/typescript-oauth/package-lock.json +4253 -0
  65. package/templates/typescript-oauth/package.json +10 -5
  66. package/templates/typescript-oauth/src/app.module.ts +39 -36
  67. package/templates/typescript-oauth/src/guards/oauth.guard.ts +0 -1
  68. package/templates/typescript-oauth/src/index.ts +22 -30
  69. package/templates/typescript-oauth/src/modules/flights/booking.tools.ts +323 -0
  70. package/templates/typescript-oauth/src/modules/flights/flights.module.ts +14 -0
  71. package/templates/typescript-oauth/src/modules/flights/flights.prompts.ts +231 -0
  72. package/templates/typescript-oauth/src/modules/flights/flights.resources.ts +215 -0
  73. package/templates/typescript-oauth/src/modules/flights/flights.tools.ts +457 -0
  74. package/templates/typescript-oauth/src/services/duffel.service.ts +285 -0
  75. package/templates/typescript-oauth/src/widgets/app/airport-search/page.tsx +270 -0
  76. package/templates/typescript-oauth/src/widgets/app/flight-details/page.tsx +261 -0
  77. package/templates/typescript-oauth/src/widgets/app/flight-search-results/page.tsx +378 -0
  78. package/templates/typescript-oauth/src/widgets/app/globals.css +167 -0
  79. package/templates/typescript-oauth/src/widgets/app/layout.tsx +6 -2
  80. package/templates/typescript-oauth/src/widgets/app/order-cancellation/page.tsx +207 -0
  81. package/templates/typescript-oauth/src/widgets/app/order-summary/page.tsx +245 -0
  82. package/templates/typescript-oauth/src/widgets/app/payment-confirmation/page.tsx +152 -0
  83. package/templates/typescript-oauth/src/widgets/app/seat-selection/page.tsx +486 -0
  84. package/templates/typescript-oauth/src/widgets/next-env.d.ts +5 -0
  85. package/templates/typescript-oauth/src/widgets/package-lock.json +155 -126
  86. package/templates/typescript-oauth/src/widgets/widget-manifest.json +374 -27
  87. package/templates/typescript-pizzaz/IMPLEMENTATION.md +98 -0
  88. package/templates/typescript-pizzaz/README.md +233 -0
  89. package/templates/typescript-pizzaz/package.json +31 -0
  90. package/templates/typescript-pizzaz/src/app.module.ts +28 -0
  91. package/templates/typescript-pizzaz/src/index.ts +30 -0
  92. package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.data.ts +106 -0
  93. package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.module.ts +11 -0
  94. package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.service.ts +60 -0
  95. package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.tools.ts +197 -0
  96. package/templates/typescript-pizzaz/src/widgets/app/layout.tsx +18 -0
  97. package/templates/typescript-pizzaz/src/widgets/app/pizza-list/page.tsx +272 -0
  98. package/templates/typescript-pizzaz/src/widgets/app/pizza-map/page.tsx +216 -0
  99. package/templates/typescript-pizzaz/src/widgets/app/pizza-shop/page.tsx +374 -0
  100. package/templates/typescript-pizzaz/src/widgets/components/CompactShopCard.tsx +144 -0
  101. package/templates/typescript-pizzaz/src/widgets/components/PizzaCard.tsx +191 -0
  102. package/templates/typescript-pizzaz/src/widgets/package.json +30 -0
  103. package/templates/typescript-pizzaz/src/widgets/widget-manifest.json +253 -0
  104. package/templates/typescript-pizzaz/tsconfig.json +30 -0
  105. package/templates/typescript-starter/src/modules/calculator/calculator.resources.ts +0 -1
  106. package/templates/typescript-starter/src/widgets/app/calculator-result/page.tsx +102 -56
  107. package/templates/typescript-starter/src/widgets/app/layout.tsx +6 -2
  108. package/templates/typescript-auth/AI_AGENT_CLI_REFERENCE.md +0 -702
  109. package/templates/typescript-auth/AI_AGENT_SDK_REFERENCE.md +0 -1260
  110. package/templates/typescript-auth/README.md +0 -402
  111. package/templates/typescript-auth/package.json +0 -36
  112. package/templates/typescript-auth/src/app.module.ts +0 -103
  113. package/templates/typescript-auth/src/db/database.ts +0 -160
  114. package/templates/typescript-auth/src/db/seed.ts +0 -374
  115. package/templates/typescript-auth/src/db/setup.ts +0 -87
  116. package/templates/typescript-auth/src/events/analytics.service.ts +0 -52
  117. package/templates/typescript-auth/src/events/notification.service.ts +0 -40
  118. package/templates/typescript-auth/src/filters/global-exception.filter.ts +0 -28
  119. package/templates/typescript-auth/src/guards/README.md +0 -75
  120. package/templates/typescript-auth/src/guards/jwt.guard.ts +0 -105
  121. package/templates/typescript-auth/src/health/database.health.ts +0 -41
  122. package/templates/typescript-auth/src/index.ts +0 -29
  123. package/templates/typescript-auth/src/interceptors/transform.interceptor.ts +0 -24
  124. package/templates/typescript-auth/src/middleware/logging.middleware.ts +0 -42
  125. package/templates/typescript-auth/src/modules/addresses/addresses.module.ts +0 -16
  126. package/templates/typescript-auth/src/modules/addresses/addresses.prompts.ts +0 -114
  127. package/templates/typescript-auth/src/modules/addresses/addresses.resources.ts +0 -40
  128. package/templates/typescript-auth/src/modules/addresses/addresses.tools.ts +0 -284
  129. package/templates/typescript-auth/src/modules/auth/auth.module.ts +0 -16
  130. package/templates/typescript-auth/src/modules/auth/auth.prompts.ts +0 -147
  131. package/templates/typescript-auth/src/modules/auth/auth.resources.ts +0 -84
  132. package/templates/typescript-auth/src/modules/auth/auth.tools.ts +0 -139
  133. package/templates/typescript-auth/src/modules/cart/cart.module.ts +0 -16
  134. package/templates/typescript-auth/src/modules/cart/cart.prompts.ts +0 -95
  135. package/templates/typescript-auth/src/modules/cart/cart.resources.ts +0 -44
  136. package/templates/typescript-auth/src/modules/cart/cart.tools.ts +0 -277
  137. package/templates/typescript-auth/src/modules/orders/orders.module.ts +0 -16
  138. package/templates/typescript-auth/src/modules/orders/orders.prompts.ts +0 -88
  139. package/templates/typescript-auth/src/modules/orders/orders.resources.ts +0 -48
  140. package/templates/typescript-auth/src/modules/orders/orders.tools.ts +0 -303
  141. package/templates/typescript-auth/src/modules/products/products.module.ts +0 -16
  142. package/templates/typescript-auth/src/modules/products/products.prompts.ts +0 -146
  143. package/templates/typescript-auth/src/modules/products/products.resources.ts +0 -98
  144. package/templates/typescript-auth/src/modules/products/products.tools.ts +0 -266
  145. package/templates/typescript-auth/src/pipes/validation.pipe.ts +0 -42
  146. package/templates/typescript-auth/src/services/database.service.ts +0 -90
  147. package/templates/typescript-auth/src/widgets/app/add-to-cart/page.tsx +0 -122
  148. package/templates/typescript-auth/src/widgets/app/address-added/page.tsx +0 -116
  149. package/templates/typescript-auth/src/widgets/app/address-deleted/page.tsx +0 -105
  150. package/templates/typescript-auth/src/widgets/app/address-list/page.tsx +0 -139
  151. package/templates/typescript-auth/src/widgets/app/address-updated/page.tsx +0 -153
  152. package/templates/typescript-auth/src/widgets/app/cart-cleared/page.tsx +0 -86
  153. package/templates/typescript-auth/src/widgets/app/cart-updated/page.tsx +0 -116
  154. package/templates/typescript-auth/src/widgets/app/categories/page.tsx +0 -134
  155. package/templates/typescript-auth/src/widgets/app/layout.tsx +0 -21
  156. package/templates/typescript-auth/src/widgets/app/login-result/page.tsx +0 -129
  157. package/templates/typescript-auth/src/widgets/app/order-confirmation/page.tsx +0 -231
  158. package/templates/typescript-auth/src/widgets/app/order-details/page.tsx +0 -225
  159. package/templates/typescript-auth/src/widgets/app/order-history/page.tsx +0 -218
  160. package/templates/typescript-auth/src/widgets/app/product-card/page.tsx +0 -121
  161. package/templates/typescript-auth/src/widgets/app/products-grid/page.tsx +0 -198
  162. package/templates/typescript-auth/src/widgets/app/shopping-cart/page.tsx +0 -187
  163. package/templates/typescript-auth/src/widgets/app/whoami/page.tsx +0 -165
  164. package/templates/typescript-auth/src/widgets/next.config.js +0 -38
  165. package/templates/typescript-auth/src/widgets/package.json +0 -18
  166. package/templates/typescript-auth/src/widgets/styles/ecommerce.ts +0 -169
  167. package/templates/typescript-auth/src/widgets/tsconfig.json +0 -28
  168. package/templates/typescript-auth/src/widgets/types/tool-data.ts +0 -141
  169. package/templates/typescript-auth/src/widgets/widget-manifest.json +0 -464
  170. package/templates/typescript-auth/tsconfig.json +0 -27
  171. package/templates/typescript-auth-api-key/AI_AGENT_CLI_REFERENCE.md +0 -701
  172. package/templates/typescript-auth-api-key/AI_AGENT_SDK_REFERENCE.md +0 -1260
  173. package/templates/typescript-auth-api-key/README.md +0 -485
  174. package/templates/typescript-auth-api-key/package.json +0 -21
  175. package/templates/typescript-auth-api-key/src/app.module.ts +0 -38
  176. package/templates/typescript-auth-api-key/src/guards/apikey.guard.ts +0 -47
  177. package/templates/typescript-auth-api-key/src/guards/multi-auth.guard.ts +0 -157
  178. package/templates/typescript-auth-api-key/src/index.ts +0 -47
  179. package/templates/typescript-auth-api-key/src/modules/calculator/calculator.module.ts +0 -12
  180. package/templates/typescript-auth-api-key/src/modules/calculator/calculator.prompts.ts +0 -73
  181. package/templates/typescript-auth-api-key/src/modules/calculator/calculator.resources.ts +0 -60
  182. package/templates/typescript-auth-api-key/src/modules/calculator/calculator.tools.ts +0 -71
  183. package/templates/typescript-auth-api-key/src/modules/demo/demo.module.ts +0 -18
  184. package/templates/typescript-auth-api-key/src/modules/demo/demo.tools.ts +0 -155
  185. package/templates/typescript-auth-api-key/src/modules/demo/multi-auth.tools.ts +0 -123
  186. package/templates/typescript-auth-api-key/src/widgets/app/calculator-operations/page.tsx +0 -133
  187. package/templates/typescript-auth-api-key/src/widgets/app/calculator-result/page.tsx +0 -134
  188. package/templates/typescript-auth-api-key/src/widgets/app/layout.tsx +0 -14
  189. package/templates/typescript-auth-api-key/src/widgets/package.json +0 -24
  190. package/templates/typescript-auth-api-key/src/widgets/widget-manifest.json +0 -48
  191. package/templates/typescript-auth-api-key/tsconfig.json +0 -23
  192. package/templates/typescript-oauth/OAUTH_SETUP.md +0 -592
  193. package/templates/typescript-oauth/src/modules/demo/demo.module.ts +0 -16
  194. package/templates/typescript-oauth/src/modules/demo/demo.tools.ts +0 -190
  195. package/templates/typescript-oauth/src/widgets/app/calculator-operations/page.tsx +0 -133
  196. package/templates/typescript-oauth/src/widgets/app/calculator-result/page.tsx +0 -134
  197. package/templates/typescript-oauth/src/widgets/out/404.html +0 -1
  198. package/templates/typescript-oauth/src/widgets/out/_next/static/WU9THacVqL52RZbrZOLS1/_buildManifest.js +0 -1
  199. package/templates/typescript-oauth/src/widgets/out/_next/static/WU9THacVqL52RZbrZOLS1/_ssgManifest.js +0 -1
  200. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/117-eb57c7ef86f964a4.js +0 -2
  201. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/app/_not-found/page-dcb83ba3e4d0aafd.js +0 -1
  202. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/app/calculator-operations/page-b8913a740073ea8a.js +0 -1
  203. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/app/calculator-result/page-ddaaab2fce95dea2.js +0 -1
  204. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/app/layout-cbd3ebdc4ecc5247.js +0 -1
  205. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/fd9d1056-749e5812300142af.js +0 -1
  206. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/framework-f66176bb897dc684.js +0 -1
  207. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/main-76df43fcef3db344.js +0 -1
  208. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/main-app-f9c40224d04023c5.js +0 -1
  209. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/pages/_app-72b849fbd24ac258.js +0 -1
  210. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/pages/_error-7ba65e1336b92748.js +0 -1
  211. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/polyfills-42372ed130431b0a.js +0 -1
  212. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/webpack-100b9e646d9c912e.js +0 -1
  213. package/templates/typescript-oauth/src/widgets/out/calculator-operations.html +0 -1
  214. package/templates/typescript-oauth/src/widgets/out/calculator-operations.txt +0 -7
  215. package/templates/typescript-oauth/src/widgets/out/calculator-result.html +0 -1
  216. package/templates/typescript-oauth/src/widgets/out/calculator-result.txt +0 -7
  217. package/templates/typescript-starter/src/widgets/app/calculator-operations/page.tsx +0 -133
  218. /package/templates/{typescript-auth-api-key → typescript-oauth}/src/health/system.health.ts +0 -0
  219. /package/templates/{typescript-auth-api-key → typescript-pizzaz}/src/widgets/next.config.js +0 -0
  220. /package/templates/{typescript-auth-api-key → typescript-pizzaz}/src/widgets/tsconfig.json +0 -0
@@ -1,402 +0,0 @@
1
- # NitroStack E-Commerce Template
2
-
3
- **The official NitroStack starter template** - A full-featured e-commerce MCP server with authentication, products, cart, orders, and beautiful UI widgets.
4
-
5
- ## 🎯 What's Inside
6
-
7
- This template demonstrates NitroStack v3.0 capabilities:
8
-
9
- - **Authentication** - JWT, API Keys, OAuth 2.1 support
10
- - **Products** - Browse, search, view details
11
- - **Shopping Cart** - Add, update, remove items
12
- - **Orders** - Create orders, view history
13
- - **Addresses** - Manage delivery addresses
14
- - **UI Widgets** - Beautiful Next.js components for all tools
15
- - **Database** - SQLite with seed data
16
-
17
- ## 🚀 Quick Start
18
-
19
- ### Prerequisites
20
-
21
- ```bash
22
- # Install NitroStack CLI globally
23
- npm install -g nitrostack
24
-
25
- # Or use npx
26
- npx nitrostack --version
27
- ```
28
-
29
- ### Step 1: Initialize Project
30
-
31
- ```bash
32
- nitrostack init my-ecommerce --template typescript-auth
33
- cd my-ecommerce
34
- ```
35
-
36
- The CLI automatically:
37
- - ✅ Installs all dependencies
38
- - ✅ Installs widget dependencies
39
- - ✅ Builds the widgets
40
- - ✅ Sets up the project structure
41
-
42
- ### Step 2: Setup Database
43
-
44
- ```bash
45
- npm run setup-db
46
- ```
47
-
48
- This creates the SQLite database and seeds it with sample data including:
49
- - Users (Emily Johnson, Michael Chen, Sarah Williams)
50
- - Products (Electronics, Fashion, Home & Garden)
51
- - Sample orders and addresses
52
-
53
- ### Step 3: Start Development Server
54
-
55
- ```bash
56
- npm run dev
57
- ```
58
-
59
- This starts:
60
- - **MCP Server** (dual transport: STDIO + HTTP on port 3002) - Hot reloads on code changes
61
- - **Studio** on http://localhost:3000 - Visual testing environment
62
- - **Widget Dev Server** on http://localhost:3001 - Hot module replacement
63
-
64
- > 💡 **Dual Transport**: Your server exposes tools via both STDIO (for direct connections) and HTTP (for remote access on port 3002). Switch between transports in Studio → Settings.
65
-
66
- The `nitrostack dev` command handles everything automatically:
67
- - ✅ Auto-detects widget directory
68
- - ✅ Installs dependencies (if needed)
69
- - ✅ Builds widgets (on first run)
70
- - ✅ Starts all services concurrently
71
- - ✅ Hot reload for TypeScript and widgets
72
-
73
- ### Step 4: Login
74
-
75
- In Studio, go to **Tools** page and execute the `login` tool:
76
-
77
- ```json
78
- {
79
- "email": "emily.johnson@x.dummyjson.com",
80
- "password": "password123"
81
- }
82
- ```
83
-
84
- **Test Users:**
85
- - Emily Johnson: `emily.johnson@x.dummyjson.com` / `password123`
86
- - Michael Chen: `michael.chen@x.dummyjson.com` / `password123`
87
- - Sarah Williams: `sarah.williams@x.dummyjson.com` / `password123`
88
-
89
- The JWT token will be automatically saved in your browser.
90
-
91
- ### Step 5: Refresh the Page
92
-
93
- After login, refresh the page to load your session.
94
-
95
- ### Step 6: Setup AI Chat
96
-
97
- 1. Go to the **Chat** page
98
- 2. Select **Gemini** as the provider
99
- 3. Enter Gemini API key: `AIzaSyApKc********_65cABcg2U`
100
- 4. The key will be saved in your browser for future sessions
101
-
102
- ### Step 7: Enjoy!
103
-
104
- Now you can:
105
- - Chat with AI to browse products
106
- - Add items to cart
107
- - Create orders
108
- - Manage addresses
109
- - See beautiful UI widgets rendered inline
110
-
111
- **Note:** If you get a token error, just re-login using the `login` tool. Both the Gemini API key and JWT token are saved in your browser.
112
-
113
- ---
114
-
115
- ## 📁 Project Structure
116
-
117
- ```
118
- templates/typescript-auth/
119
- ├── src/
120
- │ ├── modules/ # Feature modules
121
- │ │ ├── auth/ # Authentication (JWT, login, whoami)
122
- │ │ ├── products/ # Product catalog
123
- │ │ ├── cart/ # Shopping cart
124
- │ │ ├── orders/ # Order management
125
- │ │ └── addresses/ # Address management
126
- │ ├── guards/ # Auth guards (JWT)
127
- │ ├── services/ # Business logic
128
- │ ├── db/ # Database setup & seed
129
- │ ├── app.module.ts # Root application module
130
- │ └── index.ts # Application entry point
131
-
132
- ├── widgets/ # Next.js UI components
133
- │ ├── app/ # Widget pages
134
- │ │ ├── whoami/
135
- │ │ ├── products-grid/
136
- │ │ ├── product-card/
137
- │ │ ├── cart/
138
- │ │ ├── order-confirmation/
139
- │ │ └── ... (20+ widgets)
140
- │ └── styles/ # Shared styles
141
-
142
- ├── data/ # SQLite database
143
- ├── .env.example # Environment variables template
144
- └── package.json
145
- ```
146
-
147
- ---
148
-
149
- ## 🔧 Configuration
150
-
151
- ### Environment Variables
152
-
153
- Copy `.env.example` to `.env`:
154
-
155
- ```env
156
- # JWT Configuration
157
- JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
158
-
159
- # Database
160
- DATABASE_PATH=./data/ecommerce.db
161
-
162
- # Server
163
- PORT=3000
164
- NODE_ENV=development
165
- ```
166
-
167
- **Important:** Change `JWT_SECRET` in production!
168
-
169
- ---
170
-
171
- ## 🛠️ Available Commands
172
-
173
- ```bash
174
- # Development
175
- npm run dev # Start dev server with Studio (auto-builds everything)
176
- npm run build # Build TypeScript and widgets for production
177
- npm start # Run production server
178
-
179
- # Database
180
- npm run setup-db # Initialize database with seed data
181
- npm run reset-db # Reset database (WARNING: deletes all data)
182
- npm run seed # Reseed database
183
-
184
- # Widget Management
185
- npm run widget <command> # Run npm command in widgets directory
186
- npm run widget add <pkg> # Add a widget dependency (e.g., @mui/material)
187
- ```
188
-
189
- **Note:** The NitroStack CLI automatically handles building, installing dependencies, and hot reload. You don't need separate commands for widgets anymore!
190
-
191
- ---
192
-
193
- ## 🎨 Features Demonstrated
194
-
195
- ### 1. **Decorator-Based Architecture**
196
-
197
- ```typescript
198
- @Tool({
199
- name: 'browse_products',
200
- description: 'Browse products with filters',
201
- inputSchema: z.object({
202
- category: z.string().optional(),
203
- page: z.number().default(1)
204
- })
205
- })
206
- @Widget('products-grid')
207
- @Cache({ ttl: 300 })
208
- async browseProducts(input: any, ctx: ExecutionContext) {
209
- return await this.productService.browse(input);
210
- }
211
- ```
212
-
213
- ### 2. **Modular Organization**
214
-
215
- ```typescript
216
- @Module({
217
- name: 'products',
218
- controllers: [ProductsTools, ProductsResources, ProductsPrompts],
219
- providers: [ProductService],
220
- exports: [ProductService]
221
- })
222
- export class ProductsModule {}
223
- ```
224
-
225
- ### 3. **Authentication Guards**
226
-
227
- ```typescript
228
- @Tool({ name: 'create_order' })
229
- @UseGuards(JWTGuard) // Requires authentication
230
- async createOrder(input: any, ctx: ExecutionContext) {
231
- const userId = ctx.auth?.subject;
232
- // Create order for authenticated user
233
- }
234
- ```
235
-
236
- ### 4. **UI Widgets**
237
-
238
- Beautiful Next.js components automatically render tool responses:
239
-
240
- - Product grids with images
241
- - Shopping cart with item management
242
- - Order confirmations
243
- - User profile cards
244
- - Address management
245
-
246
- ### 5. **Type Generation**
247
-
248
- ```bash
249
- nitrostack generate types
250
- ```
251
-
252
- Auto-generates TypeScript types for widgets from tool definitions.
253
-
254
- ---
255
-
256
- ## 📚 Learning Resources
257
-
258
- ### Core Concepts
259
-
260
- - **Tools** - Functions AI can call (`@Tool` decorator)
261
- - **Resources** - Data AI can read (`@Resource` decorator)
262
- - **Prompts** - Conversation templates (`@Prompt` decorator)
263
- - **Guards** - Authentication/authorization (`@UseGuards`)
264
- - **Modules** - Logical organization (`@Module`)
265
-
266
- ### Key Files to Study
267
-
268
- 1. **`src/app.module.ts`** - Application bootstrap with `@McpApp`
269
- 2. **`src/modules/auth/auth.tools.ts`** - JWT authentication
270
- 3. **`src/modules/products/products.tools.ts`** - Product tools with caching
271
- 4. **`src/modules/cart/cart.tools.ts`** - Stateful cart management
272
- 5. **`src/guards/jwt.guard.ts`** - Guard implementation
273
-
274
- ---
275
-
276
- ## 🐛 Troubleshooting
277
-
278
- ### Tools not loading
279
-
280
- ```bash
281
- # Check if build is up to date
282
- npm run build
283
-
284
- # Check database exists
285
- ls -la data/ecommerce.db
286
-
287
- # Reset if needed
288
- npm run reset-db
289
- ```
290
-
291
- ### Token expired errors
292
-
293
- Just re-login:
294
- 1. Go to Tools page
295
- 2. Execute `login` tool
296
- 3. Refresh the page
297
-
298
- ### Widgets not rendering
299
-
300
- ```bash
301
- # The CLI handles widgets automatically, but if needed:
302
- npm run widget install # Install widget dependencies
303
- npm run dev # Restart (rebuilds everything)
304
- ```
305
-
306
- ### Database errors
307
-
308
- ```bash
309
- # Reset and reseed
310
- npm run reset-db
311
- ```
312
-
313
- ### Port already in use
314
-
315
- ```bash
316
- # Kill processes on ports 3000 and 3001
317
- lsof -ti:3000 | xargs kill -9
318
- lsof -ti:3001 | xargs kill -9
319
- ```
320
-
321
- ---
322
-
323
- ## 🚀 Extending the Template
324
-
325
- ### Add a New Module
326
-
327
- ```bash
328
- nitrostack generate module payments
329
- ```
330
-
331
- ### Add a New Tool
332
-
333
- ```bash
334
- nitrostack generate tool process-payment --module payments
335
- ```
336
-
337
- ### Add a New Widget
338
-
339
- 1. Create `src/widgets/app/payment-success/page.tsx`
340
- 2. Implement your component
341
- 3. Link to tool with `@Widget('payment-success')`
342
-
343
- ### Generate Types
344
-
345
- ```bash
346
- nitrostack generate types
347
- ```
348
-
349
- ---
350
-
351
- ## 📖 Documentation
352
-
353
- - **NitroStack Docs**: `../../docs/`
354
- - **Quick Start**: `../../docs/getting-started/02-quick-start.md`
355
- - **Tools Guide**: `../../docs/sdk/typescript/04-tools-guide.md`
356
- - **Widgets Guide**: `../../docs/sdk/typescript/16-ui-widgets-guide.md`
357
- - **Authentication**: `../../docs/sdk/typescript/09-authentication-overview.md`
358
-
359
- ---
360
-
361
- ## 🎯 What You Can Build
362
-
363
- This template is a starting point for:
364
-
365
- - **E-commerce platforms** - Already set up!
366
- - **Content management** - Replace products with articles
367
- - **Task management** - Replace products with tasks
368
- - **CRM systems** - Manage customers and contacts
369
- - **Booking systems** - Replace products with services
370
- - **Inventory management** - Track stock and orders
371
-
372
- ---
373
-
374
- ## 💡 Tips
375
-
376
- 1. **Check the seed data** in `src/db/seed.ts` to understand the schema
377
- 2. **Study the widget styles** in `src/widgets/styles/ecommerce.ts`
378
- 3. **Use Studio's chat** to test your tools interactively
379
- 4. **Generate types** after adding new tools
380
- 5. **Keep JWT_SECRET secure** in production
381
-
382
- ---
383
-
384
- ## 🤝 Support
385
-
386
- - **Documentation**: Full docs in `../../docs/`
387
- - **Examples**: This template is a complete example
388
- - **Issues**: Report bugs on GitHub
389
- - **Community**: Join our Discord
390
-
391
- ---
392
-
393
- ## 📄 License
394
-
395
- MIT License - See LICENSE file in repository root
396
-
397
- ---
398
-
399
- **Happy Building! 🎉**
400
-
401
- Create amazing AI-powered applications with NitroStack!
402
-
@@ -1,36 +0,0 @@
1
- {
2
- "name": "typescript-auth",
3
- "version": "1.0.0",
4
- "private": true,
5
- "type": "module",
6
- "scripts": {
7
- "dev": "nitrostack dev",
8
- "build": "nitrostack build",
9
- "start": "npm run build && nitrostack start",
10
- "start:prod": "nitrostack start",
11
- "widget": "npm --prefix src/widgets",
12
- "setup-db": "node --loader ts-node/esm src/db/setup.ts"
13
- },
14
- "dependencies": {
15
- "nitrostack": "^1",
16
- "dotenv": "^16.3.1",
17
- "better-sqlite3": "^9.2.2",
18
- "uuid": "^9.0.1",
19
- "bcryptjs": "^2.4.3",
20
- "jsonwebtoken": "^9.0.2",
21
- "zod": "^3.22.4",
22
- "reflect-metadata": "^0.2.1"
23
- },
24
- "devDependencies": {
25
- "@types/better-sqlite3": "^7.6.8",
26
- "@types/node": "^20.10.5",
27
- "@types/uuid": "^9.0.7",
28
- "@types/bcryptjs": "^2.4.6",
29
- "@types/jsonwebtoken": "^9.0.5",
30
- "typescript": "^5.3.3",
31
- "ts-node": "^10.9.2",
32
- "prettier": "^3.1.1",
33
- "eslint": "^8.56.0"
34
- }
35
- }
36
-
@@ -1,103 +0,0 @@
1
- import { McpApp, Module, ConfigModule, JWTModule } from 'nitrostack';
2
-
3
- // Services
4
- import { DatabaseService } from './services/database.service.js';
5
-
6
- // Modules
7
- import { AuthModule } from './modules/auth/auth.module.js';
8
- import { ProductsModule } from './modules/products/products.module.js';
9
- import { CartModule } from './modules/cart/cart.module.js';
10
- import { OrdersModule } from './modules/orders/orders.module.js';
11
- import { AddressesModule } from './modules/addresses/addresses.module.js';
12
-
13
- // Middleware
14
- import { LoggingMiddleware } from './middleware/logging.middleware.js';
15
-
16
- // Interceptors
17
- import { TransformInterceptor } from './interceptors/transform.interceptor.js';
18
-
19
- // Pipes
20
- import { ValidationPipe } from './pipes/validation.pipe.js';
21
-
22
- // Filters
23
- import { GlobalExceptionFilter } from './filters/global-exception.filter.js';
24
-
25
- // Events
26
- import { AnalyticsService } from './events/analytics.service.js';
27
- import { NotificationService } from './events/notification.service.js';
28
-
29
- // Health
30
- import { DatabaseHealthCheck } from './health/database.health.js';
31
-
32
- /**
33
- * Root Application Module
34
- *
35
- * This is the main module that bootstraps the MCP server.
36
- * It registers all feature modules, services, and global providers.
37
- */
38
- @McpApp({
39
- module: AppModule,
40
- server: {
41
- name: 'E-commerce MCP Server',
42
- version: '3.0.0',
43
- },
44
- logging: {
45
- level: (process.env.LOG_LEVEL as any) || 'info',
46
- },
47
- })
48
- @Module({
49
- name: 'app',
50
- description: 'Root application module',
51
- imports: [
52
- // Configuration
53
- ConfigModule.forRoot({
54
- envFilePath: '.env',
55
- defaults: {
56
- DATABASE_PATH: './data/ecommerce.db',
57
- LOG_LEVEL: 'info',
58
- },
59
- }),
60
-
61
- // JWT Authentication
62
- JWTModule.forRoot({
63
- secret: process.env.JWT_SECRET || 'your-secret-key',
64
- expiresIn: '7d',
65
- issuer: process.env.JWT_ISSUER || 'ecommerce-app',
66
- audience: process.env.JWT_AUDIENCE || 'ecommerce-mcp-server',
67
- }),
68
-
69
- // Feature Modules
70
- AuthModule,
71
- ProductsModule,
72
- CartModule,
73
- OrdersModule,
74
- AddressesModule,
75
- ],
76
- controllers: [],
77
- providers: [
78
- // Global Services
79
- DatabaseService,
80
-
81
- // Global Middleware
82
- LoggingMiddleware,
83
-
84
- // Global Interceptors
85
- TransformInterceptor,
86
-
87
- // Global Pipes
88
- ValidationPipe,
89
-
90
- // Global Filters
91
- GlobalExceptionFilter,
92
-
93
- // Event Handlers
94
- AnalyticsService,
95
- NotificationService,
96
-
97
- // Health Checks
98
- DatabaseHealthCheck,
99
- ],
100
- exports: [DatabaseService],
101
- })
102
- export class AppModule {}
103
-
@@ -1,160 +0,0 @@
1
- import Database from 'better-sqlite3';
2
- import path from 'path';
3
- import fs from 'fs';
4
-
5
- /**
6
- * Database connection and utilities
7
- */
8
-
9
- let db: Database.Database | null = null;
10
-
11
- export function getDatabase(): Database.Database {
12
- if (!db) {
13
- const envPath = process.env.DATABASE_PATH || './data/ecommerce.db';
14
-
15
- // Resolve relative paths from the project root (process.cwd())
16
- // Absolute paths are used as-is
17
- const dbPath = path.isAbsolute(envPath)
18
- ? envPath
19
- : path.resolve(process.cwd(), envPath);
20
-
21
- const dbDir = path.dirname(dbPath);
22
-
23
- // Ensure data directory exists
24
- if (!fs.existsSync(dbDir)) {
25
- fs.mkdirSync(dbDir, { recursive: true });
26
- }
27
-
28
- db = new Database(dbPath);
29
- db.pragma('journal_mode = WAL');
30
- db.pragma('foreign_keys = ON');
31
- }
32
-
33
- return db;
34
- }
35
-
36
- export function closeDatabase(): void {
37
- if (db) {
38
- db.close();
39
- db = null;
40
- }
41
- }
42
-
43
- /**
44
- * Initialize database schema
45
- */
46
- export function initializeSchema(): void {
47
- const db = getDatabase();
48
-
49
- // Users table
50
- db.exec(`
51
- CREATE TABLE IF NOT EXISTS users (
52
- id TEXT PRIMARY KEY,
53
- email TEXT UNIQUE NOT NULL,
54
- password_hash TEXT NOT NULL,
55
- name TEXT NOT NULL,
56
- profile_picture TEXT,
57
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP
58
- )
59
- `);
60
-
61
- // Products table
62
- db.exec(`
63
- CREATE TABLE IF NOT EXISTS products (
64
- id TEXT PRIMARY KEY,
65
- name TEXT NOT NULL,
66
- description TEXT,
67
- price REAL NOT NULL,
68
- category TEXT NOT NULL,
69
- stock INTEGER NOT NULL DEFAULT 0,
70
- image_url TEXT,
71
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP
72
- )
73
- `);
74
-
75
- // Addresses table
76
- db.exec(`
77
- CREATE TABLE IF NOT EXISTS addresses (
78
- id TEXT PRIMARY KEY,
79
- user_id TEXT NOT NULL,
80
- full_name TEXT NOT NULL,
81
- street TEXT NOT NULL,
82
- city TEXT NOT NULL,
83
- state TEXT NOT NULL,
84
- zip_code TEXT NOT NULL,
85
- country TEXT NOT NULL DEFAULT 'USA',
86
- phone TEXT NOT NULL,
87
- is_default INTEGER DEFAULT 0,
88
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
89
- FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
90
- )
91
- `);
92
-
93
- // Carts table
94
- db.exec(`
95
- CREATE TABLE IF NOT EXISTS carts (
96
- id TEXT PRIMARY KEY,
97
- user_id TEXT NOT NULL,
98
- product_id TEXT NOT NULL,
99
- quantity INTEGER NOT NULL DEFAULT 1,
100
- added_at DATETIME DEFAULT CURRENT_TIMESTAMP,
101
- FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
102
- FOREIGN KEY (product_id) REFERENCES products(id) ON DELETE CASCADE,
103
- UNIQUE(user_id, product_id)
104
- )
105
- `);
106
-
107
- // Orders table
108
- db.exec(`
109
- CREATE TABLE IF NOT EXISTS orders (
110
- id TEXT PRIMARY KEY,
111
- user_id TEXT NOT NULL,
112
- shipping_address_id TEXT NOT NULL,
113
- total REAL NOT NULL,
114
- status TEXT NOT NULL DEFAULT 'pending',
115
- payment_method TEXT NOT NULL DEFAULT 'credit_card',
116
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
117
- FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
118
- FOREIGN KEY (shipping_address_id) REFERENCES addresses(id)
119
- )
120
- `);
121
-
122
- // Order items table
123
- db.exec(`
124
- CREATE TABLE IF NOT EXISTS order_items (
125
- id TEXT PRIMARY KEY,
126
- order_id TEXT NOT NULL,
127
- product_id TEXT NOT NULL,
128
- quantity INTEGER NOT NULL,
129
- price REAL NOT NULL,
130
- FOREIGN KEY (order_id) REFERENCES orders(id) ON DELETE CASCADE,
131
- FOREIGN KEY (product_id) REFERENCES products(id)
132
- )
133
- `);
134
-
135
- // Create indexes
136
- db.exec(`
137
- CREATE INDEX IF NOT EXISTS idx_carts_user_id ON carts(user_id);
138
- CREATE INDEX IF NOT EXISTS idx_orders_user_id ON orders(user_id);
139
- CREATE INDEX IF NOT EXISTS idx_order_items_order_id ON order_items(order_id);
140
- CREATE INDEX IF NOT EXISTS idx_addresses_user_id ON addresses(user_id);
141
- `);
142
- }
143
-
144
- /**
145
- * Clear all data (for testing)
146
- */
147
- export function clearAllData(): void {
148
- const db = getDatabase();
149
-
150
- db.exec(`
151
- DELETE FROM order_items;
152
- DELETE FROM orders;
153
- DELETE FROM carts;
154
- DELETE FROM addresses;
155
- DELETE FROM products;
156
- DELETE FROM users;
157
- `);
158
- }
159
-
160
-