nitrostack 1.0.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 (290) hide show
  1. package/CHANGELOG.md +227 -0
  2. package/CONTRIBUTING.md +182 -0
  3. package/LICENSE +201 -0
  4. package/LICENSE_URLS_UPDATE_COMPLETE.md +388 -0
  5. package/NOTICE +153 -0
  6. package/README.md +571 -0
  7. package/dist/auth/api-key.d.ts +118 -0
  8. package/dist/auth/api-key.d.ts.map +1 -0
  9. package/dist/auth/api-key.js +168 -0
  10. package/dist/auth/api-key.js.map +1 -0
  11. package/dist/auth/client.d.ts +151 -0
  12. package/dist/auth/client.d.ts.map +1 -0
  13. package/dist/auth/client.js +330 -0
  14. package/dist/auth/client.js.map +1 -0
  15. package/dist/auth/index.d.ts +30 -0
  16. package/dist/auth/index.d.ts.map +1 -0
  17. package/dist/auth/index.js +43 -0
  18. package/dist/auth/index.js.map +1 -0
  19. package/dist/auth/middleware.d.ts +95 -0
  20. package/dist/auth/middleware.d.ts.map +1 -0
  21. package/dist/auth/middleware.js +260 -0
  22. package/dist/auth/middleware.js.map +1 -0
  23. package/dist/auth/pkce.d.ts +53 -0
  24. package/dist/auth/pkce.d.ts.map +1 -0
  25. package/dist/auth/pkce.js +105 -0
  26. package/dist/auth/pkce.js.map +1 -0
  27. package/dist/auth/quick-setup.d.ts +94 -0
  28. package/dist/auth/quick-setup.d.ts.map +1 -0
  29. package/dist/auth/quick-setup.js +210 -0
  30. package/dist/auth/quick-setup.js.map +1 -0
  31. package/dist/auth/server-integration.d.ts +97 -0
  32. package/dist/auth/server-integration.d.ts.map +1 -0
  33. package/dist/auth/server-integration.js +182 -0
  34. package/dist/auth/server-integration.js.map +1 -0
  35. package/dist/auth/server-metadata.d.ts +51 -0
  36. package/dist/auth/server-metadata.d.ts.map +1 -0
  37. package/dist/auth/server-metadata.js +106 -0
  38. package/dist/auth/server-metadata.js.map +1 -0
  39. package/dist/auth/simple-jwt.d.ts +88 -0
  40. package/dist/auth/simple-jwt.d.ts.map +1 -0
  41. package/dist/auth/simple-jwt.js +152 -0
  42. package/dist/auth/simple-jwt.js.map +1 -0
  43. package/dist/auth/token-store.d.ts +104 -0
  44. package/dist/auth/token-store.d.ts.map +1 -0
  45. package/dist/auth/token-store.js +205 -0
  46. package/dist/auth/token-store.js.map +1 -0
  47. package/dist/auth/token-validation.d.ts +47 -0
  48. package/dist/auth/token-validation.d.ts.map +1 -0
  49. package/dist/auth/token-validation.js +237 -0
  50. package/dist/auth/token-validation.js.map +1 -0
  51. package/dist/auth/types.d.ts +215 -0
  52. package/dist/auth/types.d.ts.map +1 -0
  53. package/dist/auth/types.js +6 -0
  54. package/dist/auth/types.js.map +1 -0
  55. package/dist/cli/commands/build.d.ts +6 -0
  56. package/dist/cli/commands/build.d.ts.map +1 -0
  57. package/dist/cli/commands/build.js +104 -0
  58. package/dist/cli/commands/build.js.map +1 -0
  59. package/dist/cli/commands/dev.d.ts +7 -0
  60. package/dist/cli/commands/dev.d.ts.map +1 -0
  61. package/dist/cli/commands/dev.js +312 -0
  62. package/dist/cli/commands/dev.js.map +1 -0
  63. package/dist/cli/commands/generate-types.d.ts +8 -0
  64. package/dist/cli/commands/generate-types.d.ts.map +1 -0
  65. package/dist/cli/commands/generate-types.js +220 -0
  66. package/dist/cli/commands/generate-types.js.map +1 -0
  67. package/dist/cli/commands/generate.d.ts +5 -0
  68. package/dist/cli/commands/generate.d.ts.map +1 -0
  69. package/dist/cli/commands/generate.js +365 -0
  70. package/dist/cli/commands/generate.js.map +1 -0
  71. package/dist/cli/commands/init.d.ts +7 -0
  72. package/dist/cli/commands/init.d.ts.map +1 -0
  73. package/dist/cli/commands/init.js +365 -0
  74. package/dist/cli/commands/init.js.map +1 -0
  75. package/dist/cli/commands/start.d.ts +6 -0
  76. package/dist/cli/commands/start.d.ts.map +1 -0
  77. package/dist/cli/commands/start.js +61 -0
  78. package/dist/cli/commands/start.js.map +1 -0
  79. package/dist/cli/index.d.ts +3 -0
  80. package/dist/cli/index.d.ts.map +1 -0
  81. package/dist/cli/index.js +47 -0
  82. package/dist/cli/index.js.map +1 -0
  83. package/dist/cli/mcp-dev-wrapper.d.ts +3 -0
  84. package/dist/cli/mcp-dev-wrapper.d.ts.map +1 -0
  85. package/dist/cli/mcp-dev-wrapper.js +116 -0
  86. package/dist/cli/mcp-dev-wrapper.js.map +1 -0
  87. package/dist/core/apikey-module.d.ts +69 -0
  88. package/dist/core/apikey-module.d.ts.map +1 -0
  89. package/dist/core/apikey-module.js +114 -0
  90. package/dist/core/apikey-module.js.map +1 -0
  91. package/dist/core/app-decorator.d.ts +58 -0
  92. package/dist/core/app-decorator.d.ts.map +1 -0
  93. package/dist/core/app-decorator.js +261 -0
  94. package/dist/core/app-decorator.js.map +1 -0
  95. package/dist/core/builders.d.ts +38 -0
  96. package/dist/core/builders.d.ts.map +1 -0
  97. package/dist/core/builders.js +129 -0
  98. package/dist/core/builders.js.map +1 -0
  99. package/dist/core/component.d.ts +105 -0
  100. package/dist/core/component.d.ts.map +1 -0
  101. package/dist/core/component.js +182 -0
  102. package/dist/core/component.js.map +1 -0
  103. package/dist/core/config-module.d.ts +55 -0
  104. package/dist/core/config-module.d.ts.map +1 -0
  105. package/dist/core/config-module.js +94 -0
  106. package/dist/core/config-module.js.map +1 -0
  107. package/dist/core/decorators/cache.decorator.d.ts +61 -0
  108. package/dist/core/decorators/cache.decorator.d.ts.map +1 -0
  109. package/dist/core/decorators/cache.decorator.js +115 -0
  110. package/dist/core/decorators/cache.decorator.js.map +1 -0
  111. package/dist/core/decorators/health-check.decorator.d.ts +80 -0
  112. package/dist/core/decorators/health-check.decorator.d.ts.map +1 -0
  113. package/dist/core/decorators/health-check.decorator.js +153 -0
  114. package/dist/core/decorators/health-check.decorator.js.map +1 -0
  115. package/dist/core/decorators/rate-limit.decorator.d.ts +62 -0
  116. package/dist/core/decorators/rate-limit.decorator.d.ts.map +1 -0
  117. package/dist/core/decorators/rate-limit.decorator.js +129 -0
  118. package/dist/core/decorators/rate-limit.decorator.js.map +1 -0
  119. package/dist/core/decorators.d.ts +151 -0
  120. package/dist/core/decorators.d.ts.map +1 -0
  121. package/dist/core/decorators.js +142 -0
  122. package/dist/core/decorators.js.map +1 -0
  123. package/dist/core/di/container.d.ts +42 -0
  124. package/dist/core/di/container.d.ts.map +1 -0
  125. package/dist/core/di/container.js +76 -0
  126. package/dist/core/di/container.js.map +1 -0
  127. package/dist/core/di/injectable.decorator.d.ts +35 -0
  128. package/dist/core/di/injectable.decorator.d.ts.map +1 -0
  129. package/dist/core/di/injectable.decorator.js +57 -0
  130. package/dist/core/di/injectable.decorator.js.map +1 -0
  131. package/dist/core/errors.d.ts +54 -0
  132. package/dist/core/errors.d.ts.map +1 -0
  133. package/dist/core/errors.js +87 -0
  134. package/dist/core/errors.js.map +1 -0
  135. package/dist/core/events/event-emitter.d.ts +50 -0
  136. package/dist/core/events/event-emitter.d.ts.map +1 -0
  137. package/dist/core/events/event-emitter.js +94 -0
  138. package/dist/core/events/event-emitter.js.map +1 -0
  139. package/dist/core/events/event.decorator.d.ts +48 -0
  140. package/dist/core/events/event.decorator.d.ts.map +1 -0
  141. package/dist/core/events/event.decorator.js +68 -0
  142. package/dist/core/events/event.decorator.js.map +1 -0
  143. package/dist/core/filters/exception-filter.decorator.d.ts +40 -0
  144. package/dist/core/filters/exception-filter.decorator.d.ts.map +1 -0
  145. package/dist/core/filters/exception-filter.decorator.js +54 -0
  146. package/dist/core/filters/exception-filter.decorator.js.map +1 -0
  147. package/dist/core/filters/exception-filter.interface.d.ts +30 -0
  148. package/dist/core/filters/exception-filter.interface.d.ts.map +1 -0
  149. package/dist/core/filters/exception-filter.interface.js +2 -0
  150. package/dist/core/filters/exception-filter.interface.js.map +1 -0
  151. package/dist/core/guards/apikey.guard.d.ts +22 -0
  152. package/dist/core/guards/apikey.guard.d.ts.map +1 -0
  153. package/dist/core/guards/apikey.guard.js +11 -0
  154. package/dist/core/guards/apikey.guard.js.map +1 -0
  155. package/dist/core/guards/guard.interface.d.ts +18 -0
  156. package/dist/core/guards/guard.interface.d.ts.map +1 -0
  157. package/dist/core/guards/guard.interface.js +2 -0
  158. package/dist/core/guards/guard.interface.js.map +1 -0
  159. package/dist/core/guards/jwt.guard.d.ts +18 -0
  160. package/dist/core/guards/jwt.guard.d.ts.map +1 -0
  161. package/dist/core/guards/jwt.guard.js +2 -0
  162. package/dist/core/guards/jwt.guard.js.map +1 -0
  163. package/dist/core/guards/oauth.guard.d.ts +35 -0
  164. package/dist/core/guards/oauth.guard.d.ts.map +1 -0
  165. package/dist/core/guards/oauth.guard.js +2 -0
  166. package/dist/core/guards/oauth.guard.js.map +1 -0
  167. package/dist/core/guards/use-guards.decorator.d.ts +25 -0
  168. package/dist/core/guards/use-guards.decorator.d.ts.map +1 -0
  169. package/dist/core/guards/use-guards.decorator.js +32 -0
  170. package/dist/core/guards/use-guards.decorator.js.map +1 -0
  171. package/dist/core/health/health-checks.resource.d.ts +14 -0
  172. package/dist/core/health/health-checks.resource.d.ts.map +1 -0
  173. package/dist/core/health/health-checks.resource.js +29 -0
  174. package/dist/core/health/health-checks.resource.js.map +1 -0
  175. package/dist/core/index.d.ts +55 -0
  176. package/dist/core/index.d.ts.map +1 -0
  177. package/dist/core/index.js +57 -0
  178. package/dist/core/index.js.map +1 -0
  179. package/dist/core/interceptors/interceptor.decorator.d.ts +37 -0
  180. package/dist/core/interceptors/interceptor.decorator.d.ts.map +1 -0
  181. package/dist/core/interceptors/interceptor.decorator.js +51 -0
  182. package/dist/core/interceptors/interceptor.decorator.js.map +1 -0
  183. package/dist/core/interceptors/interceptor.interface.d.ts +31 -0
  184. package/dist/core/interceptors/interceptor.interface.d.ts.map +1 -0
  185. package/dist/core/interceptors/interceptor.interface.js +2 -0
  186. package/dist/core/interceptors/interceptor.interface.js.map +1 -0
  187. package/dist/core/jwt-module.d.ts +51 -0
  188. package/dist/core/jwt-module.d.ts.map +1 -0
  189. package/dist/core/jwt-module.js +52 -0
  190. package/dist/core/jwt-module.js.map +1 -0
  191. package/dist/core/logger.d.ts +18 -0
  192. package/dist/core/logger.d.ts.map +1 -0
  193. package/dist/core/logger.js +51 -0
  194. package/dist/core/logger.js.map +1 -0
  195. package/dist/core/middleware/middleware.decorator.d.ts +39 -0
  196. package/dist/core/middleware/middleware.decorator.d.ts.map +1 -0
  197. package/dist/core/middleware/middleware.decorator.js +53 -0
  198. package/dist/core/middleware/middleware.decorator.js.map +1 -0
  199. package/dist/core/middleware/middleware.interface.d.ts +29 -0
  200. package/dist/core/middleware/middleware.interface.d.ts.map +1 -0
  201. package/dist/core/middleware/middleware.interface.js +2 -0
  202. package/dist/core/middleware/middleware.interface.js.map +1 -0
  203. package/dist/core/module.d.ts +74 -0
  204. package/dist/core/module.d.ts.map +1 -0
  205. package/dist/core/module.js +82 -0
  206. package/dist/core/module.js.map +1 -0
  207. package/dist/core/oauth-module.d.ts +144 -0
  208. package/dist/core/oauth-module.d.ts.map +1 -0
  209. package/dist/core/oauth-module.js +190 -0
  210. package/dist/core/oauth-module.js.map +1 -0
  211. package/dist/core/pipes/pipe.decorator.d.ts +55 -0
  212. package/dist/core/pipes/pipe.decorator.d.ts.map +1 -0
  213. package/dist/core/pipes/pipe.decorator.js +85 -0
  214. package/dist/core/pipes/pipe.decorator.js.map +1 -0
  215. package/dist/core/pipes/pipe.interface.d.ts +36 -0
  216. package/dist/core/pipes/pipe.interface.d.ts.map +1 -0
  217. package/dist/core/pipes/pipe.interface.js +2 -0
  218. package/dist/core/pipes/pipe.interface.js.map +1 -0
  219. package/dist/core/prompt.d.ts +37 -0
  220. package/dist/core/prompt.d.ts.map +1 -0
  221. package/dist/core/prompt.js +76 -0
  222. package/dist/core/prompt.js.map +1 -0
  223. package/dist/core/resource.d.ts +42 -0
  224. package/dist/core/resource.d.ts.map +1 -0
  225. package/dist/core/resource.js +90 -0
  226. package/dist/core/resource.js.map +1 -0
  227. package/dist/core/server.d.ts +72 -0
  228. package/dist/core/server.d.ts.map +1 -0
  229. package/dist/core/server.js +406 -0
  230. package/dist/core/server.js.map +1 -0
  231. package/dist/core/tool.d.ts +78 -0
  232. package/dist/core/tool.d.ts.map +1 -0
  233. package/dist/core/tool.js +190 -0
  234. package/dist/core/tool.js.map +1 -0
  235. package/dist/core/transports/http-server.d.ts +102 -0
  236. package/dist/core/transports/http-server.d.ts.map +1 -0
  237. package/dist/core/transports/http-server.js +265 -0
  238. package/dist/core/transports/http-server.js.map +1 -0
  239. package/dist/core/types.d.ts +123 -0
  240. package/dist/core/types.d.ts.map +1 -0
  241. package/dist/core/types.js +2 -0
  242. package/dist/core/types.js.map +1 -0
  243. package/dist/core/widgets/widget-examples.resource.d.ts +17 -0
  244. package/dist/core/widgets/widget-examples.resource.d.ts.map +1 -0
  245. package/dist/core/widgets/widget-examples.resource.js +28 -0
  246. package/dist/core/widgets/widget-examples.resource.js.map +1 -0
  247. package/dist/core/widgets/widget-registry.d.ts +56 -0
  248. package/dist/core/widgets/widget-registry.d.ts.map +1 -0
  249. package/dist/core/widgets/widget-registry.js +75 -0
  250. package/dist/core/widgets/widget-registry.js.map +1 -0
  251. package/dist/testing/index.d.ts +82 -0
  252. package/dist/testing/index.d.ts.map +1 -0
  253. package/dist/testing/index.js +164 -0
  254. package/dist/testing/index.js.map +1 -0
  255. package/dist/ui-next/index.d.ts +31 -0
  256. package/dist/ui-next/index.d.ts.map +1 -0
  257. package/dist/ui-next/index.js +687 -0
  258. package/dist/ui-next/index.js.map +1 -0
  259. package/dist/widgets/index.d.ts +9 -0
  260. package/dist/widgets/index.d.ts.map +1 -0
  261. package/dist/widgets/index.js +9 -0
  262. package/dist/widgets/index.js.map +1 -0
  263. package/dist/widgets/metadata.d.ts +53 -0
  264. package/dist/widgets/metadata.d.ts.map +1 -0
  265. package/dist/widgets/metadata.js +29 -0
  266. package/dist/widgets/metadata.js.map +1 -0
  267. package/dist/widgets/withToolData.d.ts +19 -0
  268. package/dist/widgets/withToolData.d.ts.map +1 -0
  269. package/dist/widgets/withToolData.js +240 -0
  270. package/dist/widgets/withToolData.js.map +1 -0
  271. package/jest.config.js +21 -0
  272. package/package.json +108 -0
  273. package/templates/typescript-auth/AI_AGENT_CLI_REFERENCE.md +702 -0
  274. package/templates/typescript-auth/AI_AGENT_SDK_REFERENCE.md +1260 -0
  275. package/templates/typescript-auth/README.md +400 -0
  276. package/templates/typescript-auth/package.json +44 -0
  277. package/templates/typescript-auth-api-key/AI_AGENT_CLI_REFERENCE.md +701 -0
  278. package/templates/typescript-auth-api-key/AI_AGENT_SDK_REFERENCE.md +1260 -0
  279. package/templates/typescript-auth-api-key/README.md +483 -0
  280. package/templates/typescript-auth-api-key/package-lock.json +124 -0
  281. package/templates/typescript-auth-api-key/package.json +29 -0
  282. package/templates/typescript-oauth/AI_AGENT_CLI_REFERENCE.md +701 -0
  283. package/templates/typescript-oauth/AI_AGENT_SDK_REFERENCE.md +1260 -0
  284. package/templates/typescript-oauth/OAUTH_SETUP.md +406 -0
  285. package/templates/typescript-oauth/README.md +350 -0
  286. package/templates/typescript-oauth/package.json +30 -0
  287. package/templates/typescript-starter/AI_AGENT_CLI_REFERENCE.md +701 -0
  288. package/templates/typescript-starter/AI_AGENT_SDK_REFERENCE.md +1260 -0
  289. package/templates/typescript-starter/README.md +312 -0
  290. package/templates/typescript-starter/package.json +32 -0
@@ -0,0 +1,400 @@
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** (stdio mode) - 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
+ The `nitrostack dev` command handles everything automatically:
65
+ - ✅ Auto-detects widget directory
66
+ - ✅ Installs dependencies (if needed)
67
+ - ✅ Builds widgets (on first run)
68
+ - ✅ Starts all services concurrently
69
+ - ✅ Hot reload for TypeScript and widgets
70
+
71
+ ### Step 4: Login
72
+
73
+ In Studio, go to **Tools** page and execute the `login` tool:
74
+
75
+ ```json
76
+ {
77
+ "email": "emily.johnson@x.dummyjson.com",
78
+ "password": "password123"
79
+ }
80
+ ```
81
+
82
+ **Test Users:**
83
+ - Emily Johnson: `emily.johnson@x.dummyjson.com` / `password123`
84
+ - Michael Chen: `michael.chen@x.dummyjson.com` / `password123`
85
+ - Sarah Williams: `sarah.williams@x.dummyjson.com` / `password123`
86
+
87
+ The JWT token will be automatically saved in your browser.
88
+
89
+ ### Step 5: Refresh the Page
90
+
91
+ After login, refresh the page to load your session.
92
+
93
+ ### Step 6: Setup AI Chat
94
+
95
+ 1. Go to the **Chat** page
96
+ 2. Select **Gemini** as the provider
97
+ 3. Enter Gemini API key: `AIzaSyApKc********_65cABcg2U`
98
+ 4. The key will be saved in your browser for future sessions
99
+
100
+ ### Step 7: Enjoy!
101
+
102
+ Now you can:
103
+ - Chat with AI to browse products
104
+ - Add items to cart
105
+ - Create orders
106
+ - Manage addresses
107
+ - See beautiful UI widgets rendered inline
108
+
109
+ **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.
110
+
111
+ ---
112
+
113
+ ## 📁 Project Structure
114
+
115
+ ```
116
+ templates/typescript-auth/
117
+ ├── src/
118
+ │ ├── modules/ # Feature modules
119
+ │ │ ├── auth/ # Authentication (JWT, login, whoami)
120
+ │ │ ├── products/ # Product catalog
121
+ │ │ ├── cart/ # Shopping cart
122
+ │ │ ├── orders/ # Order management
123
+ │ │ └── addresses/ # Address management
124
+ │ ├── guards/ # Auth guards (JWT)
125
+ │ ├── services/ # Business logic
126
+ │ ├── db/ # Database setup & seed
127
+ │ ├── app.module.ts # Root application module
128
+ │ └── index.ts # Application entry point
129
+
130
+ ├── widgets/ # Next.js UI components
131
+ │ ├── app/ # Widget pages
132
+ │ │ ├── whoami/
133
+ │ │ ├── products-grid/
134
+ │ │ ├── product-card/
135
+ │ │ ├── cart/
136
+ │ │ ├── order-confirmation/
137
+ │ │ └── ... (20+ widgets)
138
+ │ └── styles/ # Shared styles
139
+
140
+ ├── data/ # SQLite database
141
+ ├── .env.example # Environment variables template
142
+ └── package.json
143
+ ```
144
+
145
+ ---
146
+
147
+ ## 🔧 Configuration
148
+
149
+ ### Environment Variables
150
+
151
+ Copy `.env.example` to `.env`:
152
+
153
+ ```env
154
+ # JWT Configuration
155
+ JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
156
+
157
+ # Database
158
+ DATABASE_PATH=./data/ecommerce.db
159
+
160
+ # Server
161
+ PORT=3000
162
+ NODE_ENV=development
163
+ ```
164
+
165
+ **Important:** Change `JWT_SECRET` in production!
166
+
167
+ ---
168
+
169
+ ## 🛠️ Available Commands
170
+
171
+ ```bash
172
+ # Development
173
+ npm run dev # Start dev server with Studio (auto-builds everything)
174
+ npm run build # Build TypeScript and widgets for production
175
+ npm start # Run production server
176
+
177
+ # Database
178
+ npm run setup-db # Initialize database with seed data
179
+ npm run reset-db # Reset database (WARNING: deletes all data)
180
+ npm run seed # Reseed database
181
+
182
+ # Widget Management
183
+ npm run widget <command> # Run npm command in widgets directory
184
+ npm run widget add <pkg> # Add a widget dependency (e.g., @mui/material)
185
+ ```
186
+
187
+ **Note:** The NitroStack CLI automatically handles building, installing dependencies, and hot reload. You don't need separate commands for widgets anymore!
188
+
189
+ ---
190
+
191
+ ## 🎨 Features Demonstrated
192
+
193
+ ### 1. **Decorator-Based Architecture**
194
+
195
+ ```typescript
196
+ @Tool({
197
+ name: 'browse_products',
198
+ description: 'Browse products with filters',
199
+ inputSchema: z.object({
200
+ category: z.string().optional(),
201
+ page: z.number().default(1)
202
+ })
203
+ })
204
+ @Widget('products-grid')
205
+ @Cache({ ttl: 300 })
206
+ async browseProducts(input: any, ctx: ExecutionContext) {
207
+ return await this.productService.browse(input);
208
+ }
209
+ ```
210
+
211
+ ### 2. **Modular Organization**
212
+
213
+ ```typescript
214
+ @Module({
215
+ name: 'products',
216
+ controllers: [ProductsTools, ProductsResources, ProductsPrompts],
217
+ providers: [ProductService],
218
+ exports: [ProductService]
219
+ })
220
+ export class ProductsModule {}
221
+ ```
222
+
223
+ ### 3. **Authentication Guards**
224
+
225
+ ```typescript
226
+ @Tool({ name: 'create_order' })
227
+ @UseGuards(JWTGuard) // Requires authentication
228
+ async createOrder(input: any, ctx: ExecutionContext) {
229
+ const userId = ctx.auth?.subject;
230
+ // Create order for authenticated user
231
+ }
232
+ ```
233
+
234
+ ### 4. **UI Widgets**
235
+
236
+ Beautiful Next.js components automatically render tool responses:
237
+
238
+ - Product grids with images
239
+ - Shopping cart with item management
240
+ - Order confirmations
241
+ - User profile cards
242
+ - Address management
243
+
244
+ ### 5. **Type Generation**
245
+
246
+ ```bash
247
+ nitrostack generate types
248
+ ```
249
+
250
+ Auto-generates TypeScript types for widgets from tool definitions.
251
+
252
+ ---
253
+
254
+ ## 📚 Learning Resources
255
+
256
+ ### Core Concepts
257
+
258
+ - **Tools** - Functions AI can call (`@Tool` decorator)
259
+ - **Resources** - Data AI can read (`@Resource` decorator)
260
+ - **Prompts** - Conversation templates (`@Prompt` decorator)
261
+ - **Guards** - Authentication/authorization (`@UseGuards`)
262
+ - **Modules** - Logical organization (`@Module`)
263
+
264
+ ### Key Files to Study
265
+
266
+ 1. **`src/app.module.ts`** - Application bootstrap with `@McpApp`
267
+ 2. **`src/modules/auth/auth.tools.ts`** - JWT authentication
268
+ 3. **`src/modules/products/products.tools.ts`** - Product tools with caching
269
+ 4. **`src/modules/cart/cart.tools.ts`** - Stateful cart management
270
+ 5. **`src/guards/jwt.guard.ts`** - Guard implementation
271
+
272
+ ---
273
+
274
+ ## 🐛 Troubleshooting
275
+
276
+ ### Tools not loading
277
+
278
+ ```bash
279
+ # Check if build is up to date
280
+ npm run build
281
+
282
+ # Check database exists
283
+ ls -la data/ecommerce.db
284
+
285
+ # Reset if needed
286
+ npm run reset-db
287
+ ```
288
+
289
+ ### Token expired errors
290
+
291
+ Just re-login:
292
+ 1. Go to Tools page
293
+ 2. Execute `login` tool
294
+ 3. Refresh the page
295
+
296
+ ### Widgets not rendering
297
+
298
+ ```bash
299
+ # The CLI handles widgets automatically, but if needed:
300
+ npm run widget install # Install widget dependencies
301
+ npm run dev # Restart (rebuilds everything)
302
+ ```
303
+
304
+ ### Database errors
305
+
306
+ ```bash
307
+ # Reset and reseed
308
+ npm run reset-db
309
+ ```
310
+
311
+ ### Port already in use
312
+
313
+ ```bash
314
+ # Kill processes on ports 3000 and 3001
315
+ lsof -ti:3000 | xargs kill -9
316
+ lsof -ti:3001 | xargs kill -9
317
+ ```
318
+
319
+ ---
320
+
321
+ ## 🚀 Extending the Template
322
+
323
+ ### Add a New Module
324
+
325
+ ```bash
326
+ nitrostack generate module payments
327
+ ```
328
+
329
+ ### Add a New Tool
330
+
331
+ ```bash
332
+ nitrostack generate tool process-payment --module payments
333
+ ```
334
+
335
+ ### Add a New Widget
336
+
337
+ 1. Create `src/widgets/app/payment-success/page.tsx`
338
+ 2. Implement your component
339
+ 3. Link to tool with `@Widget('payment-success')`
340
+
341
+ ### Generate Types
342
+
343
+ ```bash
344
+ nitrostack generate types
345
+ ```
346
+
347
+ ---
348
+
349
+ ## 📖 Documentation
350
+
351
+ - **NitroStack Docs**: `../../docs/`
352
+ - **Quick Start**: `../../docs/getting-started/02-quick-start.md`
353
+ - **Tools Guide**: `../../docs/sdk/typescript/04-tools-guide.md`
354
+ - **Widgets Guide**: `../../docs/sdk/typescript/16-ui-widgets-guide.md`
355
+ - **Authentication**: `../../docs/sdk/typescript/09-authentication-overview.md`
356
+
357
+ ---
358
+
359
+ ## 🎯 What You Can Build
360
+
361
+ This template is a starting point for:
362
+
363
+ - **E-commerce platforms** - Already set up!
364
+ - **Content management** - Replace products with articles
365
+ - **Task management** - Replace products with tasks
366
+ - **CRM systems** - Manage customers and contacts
367
+ - **Booking systems** - Replace products with services
368
+ - **Inventory management** - Track stock and orders
369
+
370
+ ---
371
+
372
+ ## 💡 Tips
373
+
374
+ 1. **Check the seed data** in `src/db/seed.ts` to understand the schema
375
+ 2. **Study the widget styles** in `src/widgets/styles/ecommerce.ts`
376
+ 3. **Use Studio's chat** to test your tools interactively
377
+ 4. **Generate types** after adding new tools
378
+ 5. **Keep JWT_SECRET secure** in production
379
+
380
+ ---
381
+
382
+ ## 🤝 Support
383
+
384
+ - **Documentation**: Full docs in `../../docs/`
385
+ - **Examples**: This template is a complete example
386
+ - **Issues**: Report bugs on GitHub
387
+ - **Community**: Join our Discord
388
+
389
+ ---
390
+
391
+ ## 📄 License
392
+
393
+ MIT License - See LICENSE file in repository root
394
+
395
+ ---
396
+
397
+ **Happy Building! 🎉**
398
+
399
+ Create amazing AI-powered applications with NitroStack!
400
+
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "ecommerce-mcp-server",
3
+ "version": "3.0.0",
4
+ "description": "E-commerce MCP server with JWT authentication - NitroStack V3 Template",
5
+ "main": "dist/index.js",
6
+ "type": "module",
7
+ "scripts": {
8
+ "dev": "nitrostack dev",
9
+ "build": "nitrostack build",
10
+ "start": "nitrostack start",
11
+ "widget": "npm --prefix src/widgets",
12
+ "setup-db": "node --loader ts-node/esm src/db/setup.ts"
13
+ },
14
+ "keywords": [
15
+ "mcp",
16
+ "ecommerce",
17
+ "jwt-auth",
18
+ "model-context-protocol"
19
+ ],
20
+ "author": "",
21
+ "license": "MIT",
22
+ "dependencies": {
23
+ "nitrostack": "^1.0.0",
24
+ "dotenv": "^16.3.1",
25
+ "better-sqlite3": "^9.2.2",
26
+ "uuid": "^9.0.1",
27
+ "bcryptjs": "^2.4.3",
28
+ "jsonwebtoken": "^9.0.2",
29
+ "zod": "^3.22.4",
30
+ "reflect-metadata": "^0.2.1"
31
+ },
32
+ "devDependencies": {
33
+ "@types/better-sqlite3": "^7.6.8",
34
+ "@types/node": "^20.10.5",
35
+ "@types/uuid": "^9.0.7",
36
+ "@types/bcryptjs": "^2.4.6",
37
+ "@types/jsonwebtoken": "^9.0.5",
38
+ "typescript": "^5.3.3",
39
+ "ts-node": "^10.9.2",
40
+ "prettier": "^3.1.1",
41
+ "eslint": "^8.56.0"
42
+ }
43
+ }
44
+