nitrostack 1.0.0 → 1.0.1
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/CHANGELOG.md +15 -0
- package/package.json +1 -1
- package/templates/typescript-auth/.env.example +23 -0
- package/templates/typescript-auth/src/app.module.ts +103 -0
- package/templates/typescript-auth/src/db/database.ts +163 -0
- package/templates/typescript-auth/src/db/seed.ts +374 -0
- package/templates/typescript-auth/src/db/setup.ts +87 -0
- package/templates/typescript-auth/src/events/analytics.service.ts +52 -0
- package/templates/typescript-auth/src/events/notification.service.ts +40 -0
- package/templates/typescript-auth/src/filters/global-exception.filter.ts +28 -0
- package/templates/typescript-auth/src/guards/README.md +75 -0
- package/templates/typescript-auth/src/guards/jwt.guard.ts +105 -0
- package/templates/typescript-auth/src/health/database.health.ts +41 -0
- package/templates/typescript-auth/src/index.ts +26 -0
- package/templates/typescript-auth/src/interceptors/transform.interceptor.ts +24 -0
- package/templates/typescript-auth/src/middleware/logging.middleware.ts +42 -0
- package/templates/typescript-auth/src/modules/addresses/addresses.module.ts +16 -0
- package/templates/typescript-auth/src/modules/addresses/addresses.prompts.ts +114 -0
- package/templates/typescript-auth/src/modules/addresses/addresses.resources.ts +40 -0
- package/templates/typescript-auth/src/modules/addresses/addresses.tools.ts +241 -0
- package/templates/typescript-auth/src/modules/auth/auth.module.ts +16 -0
- package/templates/typescript-auth/src/modules/auth/auth.prompts.ts +147 -0
- package/templates/typescript-auth/src/modules/auth/auth.resources.ts +84 -0
- package/templates/typescript-auth/src/modules/auth/auth.tools.ts +139 -0
- package/templates/typescript-auth/src/modules/cart/cart.module.ts +16 -0
- package/templates/typescript-auth/src/modules/cart/cart.prompts.ts +95 -0
- package/templates/typescript-auth/src/modules/cart/cart.resources.ts +44 -0
- package/templates/typescript-auth/src/modules/cart/cart.tools.ts +281 -0
- package/templates/typescript-auth/src/modules/orders/orders.module.ts +16 -0
- package/templates/typescript-auth/src/modules/orders/orders.prompts.ts +88 -0
- package/templates/typescript-auth/src/modules/orders/orders.resources.ts +48 -0
- package/templates/typescript-auth/src/modules/orders/orders.tools.ts +281 -0
- package/templates/typescript-auth/src/modules/products/products.module.ts +16 -0
- package/templates/typescript-auth/src/modules/products/products.prompts.ts +146 -0
- package/templates/typescript-auth/src/modules/products/products.resources.ts +98 -0
- package/templates/typescript-auth/src/modules/products/products.tools.ts +266 -0
- package/templates/typescript-auth/src/pipes/validation.pipe.ts +42 -0
- package/templates/typescript-auth/src/services/database.service.ts +90 -0
- package/templates/typescript-auth/src/widgets/app/add-to-cart/page.tsx +122 -0
- package/templates/typescript-auth/src/widgets/app/address-added/page.tsx +116 -0
- package/templates/typescript-auth/src/widgets/app/address-deleted/page.tsx +105 -0
- package/templates/typescript-auth/src/widgets/app/address-list/page.tsx +139 -0
- package/templates/typescript-auth/src/widgets/app/address-updated/page.tsx +153 -0
- package/templates/typescript-auth/src/widgets/app/cart-cleared/page.tsx +86 -0
- package/templates/typescript-auth/src/widgets/app/cart-updated/page.tsx +116 -0
- package/templates/typescript-auth/src/widgets/app/categories/page.tsx +134 -0
- package/templates/typescript-auth/src/widgets/app/layout.tsx +21 -0
- package/templates/typescript-auth/src/widgets/app/login-result/page.tsx +129 -0
- package/templates/typescript-auth/src/widgets/app/order-confirmation/page.tsx +206 -0
- package/templates/typescript-auth/src/widgets/app/order-details/page.tsx +225 -0
- package/templates/typescript-auth/src/widgets/app/order-history/page.tsx +218 -0
- package/templates/typescript-auth/src/widgets/app/product-card/page.tsx +121 -0
- package/templates/typescript-auth/src/widgets/app/products-grid/page.tsx +173 -0
- package/templates/typescript-auth/src/widgets/app/shopping-cart/page.tsx +187 -0
- package/templates/typescript-auth/src/widgets/app/whoami/page.tsx +165 -0
- package/templates/typescript-auth/src/widgets/next.config.js +38 -0
- package/templates/typescript-auth/src/widgets/package.json +18 -0
- package/templates/typescript-auth/src/widgets/styles/ecommerce.ts +169 -0
- package/templates/typescript-auth/src/widgets/tsconfig.json +28 -0
- package/templates/typescript-auth/src/widgets/types/tool-data.ts +141 -0
- package/templates/typescript-auth/src/widgets/widget-manifest.json +464 -0
- package/templates/typescript-auth/tsconfig.json +27 -0
- package/templates/typescript-auth-api-key/.env +15 -0
- package/templates/typescript-auth-api-key/.env.example +4 -0
- package/templates/typescript-auth-api-key/src/app.module.ts +38 -0
- package/templates/typescript-auth-api-key/src/guards/apikey.guard.ts +47 -0
- package/templates/typescript-auth-api-key/src/guards/multi-auth.guard.ts +157 -0
- package/templates/typescript-auth-api-key/src/health/system.health.ts +55 -0
- package/templates/typescript-auth-api-key/src/index.ts +47 -0
- package/templates/typescript-auth-api-key/src/modules/calculator/calculator.module.ts +12 -0
- package/templates/typescript-auth-api-key/src/modules/calculator/calculator.prompts.ts +73 -0
- package/templates/typescript-auth-api-key/src/modules/calculator/calculator.resources.ts +60 -0
- package/templates/typescript-auth-api-key/src/modules/calculator/calculator.tools.ts +71 -0
- package/templates/typescript-auth-api-key/src/modules/demo/demo.module.ts +18 -0
- package/templates/typescript-auth-api-key/src/modules/demo/demo.tools.ts +155 -0
- package/templates/typescript-auth-api-key/src/modules/demo/multi-auth.tools.ts +123 -0
- package/templates/typescript-auth-api-key/src/widgets/app/calculator-operations/page.tsx +133 -0
- package/templates/typescript-auth-api-key/src/widgets/app/calculator-result/page.tsx +134 -0
- package/templates/typescript-auth-api-key/src/widgets/app/layout.tsx +14 -0
- package/templates/typescript-auth-api-key/src/widgets/next.config.js +37 -0
- package/templates/typescript-auth-api-key/src/widgets/package.json +24 -0
- package/templates/typescript-auth-api-key/src/widgets/tsconfig.json +28 -0
- package/templates/typescript-auth-api-key/src/widgets/widget-manifest.json +48 -0
- package/templates/typescript-auth-api-key/tsconfig.json +23 -0
- package/templates/typescript-oauth/.env.example +91 -0
- package/templates/typescript-oauth/src/app.module.ts +89 -0
- package/templates/typescript-oauth/src/guards/oauth.guard.ts +127 -0
- package/templates/typescript-oauth/src/index.ts +74 -0
- package/templates/typescript-oauth/src/modules/demo/demo.module.ts +16 -0
- package/templates/typescript-oauth/src/modules/demo/demo.tools.ts +190 -0
- package/templates/typescript-oauth/src/widgets/app/calculator-operations/page.tsx +133 -0
- package/templates/typescript-oauth/src/widgets/app/calculator-result/page.tsx +134 -0
- package/templates/typescript-oauth/src/widgets/app/layout.tsx +14 -0
- package/templates/typescript-oauth/src/widgets/next.config.js +37 -0
- package/templates/typescript-oauth/src/widgets/package.json +24 -0
- package/templates/typescript-oauth/src/widgets/tsconfig.json +28 -0
- package/templates/typescript-oauth/src/widgets/widget-manifest.json +48 -0
- package/templates/typescript-oauth/tsconfig.json +23 -0
- package/templates/typescript-starter/.env.example +4 -0
- package/templates/typescript-starter/src/app.module.ts +34 -0
- package/templates/typescript-starter/src/health/system.health.ts +55 -0
- package/templates/typescript-starter/src/index.ts +27 -0
- package/templates/typescript-starter/src/modules/calculator/calculator.module.ts +12 -0
- package/templates/typescript-starter/src/modules/calculator/calculator.prompts.ts +73 -0
- package/templates/typescript-starter/src/modules/calculator/calculator.resources.ts +60 -0
- package/templates/typescript-starter/src/modules/calculator/calculator.tools.ts +71 -0
- package/templates/typescript-starter/src/widgets/app/calculator-operations/page.tsx +133 -0
- package/templates/typescript-starter/src/widgets/app/calculator-result/page.tsx +134 -0
- package/templates/typescript-starter/src/widgets/app/layout.tsx +14 -0
- package/templates/typescript-starter/src/widgets/next.config.js +37 -0
- package/templates/typescript-starter/src/widgets/package.json +24 -0
- package/templates/typescript-starter/src/widgets/tsconfig.json +28 -0
- package/templates/typescript-starter/src/widgets/widget-manifest.json +48 -0
- package/templates/typescript-starter/tsconfig.json +23 -0
- package/LICENSE_URLS_UPDATE_COMPLETE.md +0 -388
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.0",
|
|
3
|
+
"widgets": [
|
|
4
|
+
{
|
|
5
|
+
"uri": "/login-result",
|
|
6
|
+
"name": "Login Result",
|
|
7
|
+
"description": "Displays login success with user information and JWT token",
|
|
8
|
+
"examples": [
|
|
9
|
+
{
|
|
10
|
+
"name": "Successful Login - Emily",
|
|
11
|
+
"description": "Login result for Emily Johnson",
|
|
12
|
+
"data": {
|
|
13
|
+
"message": "Login successful!",
|
|
14
|
+
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
|
|
15
|
+
"user": {
|
|
16
|
+
"id": "user-emily",
|
|
17
|
+
"email": "emily.johnson@x.dummyjson.com",
|
|
18
|
+
"name": "Emily Johnson"
|
|
19
|
+
},
|
|
20
|
+
"instructions": {
|
|
21
|
+
"step1": "Copy the token above",
|
|
22
|
+
"step2": "In the inspector, go to Chat tab",
|
|
23
|
+
"step3": "Paste the token in the 'JWT Token' field (if available)",
|
|
24
|
+
"step4": "Or use: Authorization: Bearer <token>",
|
|
25
|
+
"expiresIn": "24 hours"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"tags": ["auth", "login", "jwt"]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"uri": "/whoami",
|
|
34
|
+
"name": "User Profile",
|
|
35
|
+
"description": "Shows current authenticated user's profile information",
|
|
36
|
+
"examples": [
|
|
37
|
+
{
|
|
38
|
+
"name": "Emily's Profile",
|
|
39
|
+
"description": "Profile for Emily Johnson",
|
|
40
|
+
"data": {
|
|
41
|
+
"user": {
|
|
42
|
+
"id": "user-emily",
|
|
43
|
+
"email": "emily.johnson@x.dummyjson.com",
|
|
44
|
+
"name": "Emily Johnson",
|
|
45
|
+
"profile_picture": "https://dummyjson.com/icon/emilys/128",
|
|
46
|
+
"memberSince": "2024-01-01T00:00:00Z"
|
|
47
|
+
},
|
|
48
|
+
"authenticated": true
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"tags": ["auth", "profile", "user"]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"uri": "/products-grid",
|
|
56
|
+
"name": "Products Grid",
|
|
57
|
+
"description": "Displays a grid of products with filtering and pagination",
|
|
58
|
+
"examples": [
|
|
59
|
+
{
|
|
60
|
+
"name": "Beauty Products - Page 1",
|
|
61
|
+
"description": "First page of beauty products",
|
|
62
|
+
"data": {
|
|
63
|
+
"products": [
|
|
64
|
+
{
|
|
65
|
+
"id": "prod-1",
|
|
66
|
+
"name": "Essence Mascara Lash Princess",
|
|
67
|
+
"description": "The Essence Mascara Lash Princess is a popular mascara known for its volumizing and lengthening effects.",
|
|
68
|
+
"price": 9.99,
|
|
69
|
+
"category": "Beauty",
|
|
70
|
+
"stock": 99,
|
|
71
|
+
"image_url": "https://cdn.dummyjson.com/product-images/beauty/essence-mascara-lash-princess/thumbnail.webp"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"id": "prod-2",
|
|
75
|
+
"name": "Eyeshadow Palette with Mirror",
|
|
76
|
+
"description": "The Eyeshadow Palette offers a versatile range of eyeshadow shades for creating stunning eye looks.",
|
|
77
|
+
"price": 19.99,
|
|
78
|
+
"category": "Beauty",
|
|
79
|
+
"stock": 34,
|
|
80
|
+
"image_url": "https://cdn.dummyjson.com/product-images/beauty/eyeshadow-palette-with-mirror/thumbnail.webp"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"id": "prod-3",
|
|
84
|
+
"name": "Powder Canister",
|
|
85
|
+
"description": "The Powder Canister is a finely milled setting powder designed to set makeup and control shine.",
|
|
86
|
+
"price": 14.99,
|
|
87
|
+
"category": "Beauty",
|
|
88
|
+
"stock": 89,
|
|
89
|
+
"image_url": "https://cdn.dummyjson.com/product-images/beauty/powder-canister/thumbnail.webp"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"id": "prod-4",
|
|
93
|
+
"name": "Red Lipstick",
|
|
94
|
+
"description": "The Red Lipstick is a classic and bold choice for adding a pop of color to your lips.",
|
|
95
|
+
"price": 12.99,
|
|
96
|
+
"category": "Beauty",
|
|
97
|
+
"stock": 91,
|
|
98
|
+
"image_url": "https://cdn.dummyjson.com/product-images/beauty/red-lipstick/thumbnail.webp"
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
"pagination": {
|
|
102
|
+
"page": 1,
|
|
103
|
+
"limit": 4,
|
|
104
|
+
"total": 5,
|
|
105
|
+
"totalPages": 2,
|
|
106
|
+
"hasMore": true
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
"tags": ["products", "ecommerce", "shopping", "grid"]
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"uri": "/product-card",
|
|
115
|
+
"name": "Product Card",
|
|
116
|
+
"description": "Displays detailed information for a single product",
|
|
117
|
+
"examples": [
|
|
118
|
+
{
|
|
119
|
+
"name": "Essence Mascara Details",
|
|
120
|
+
"description": "Details for Essence Mascara product",
|
|
121
|
+
"data": {
|
|
122
|
+
"product": {
|
|
123
|
+
"id": "prod-1",
|
|
124
|
+
"name": "Essence Mascara Lash Princess",
|
|
125
|
+
"description": "The Essence Mascara Lash Princess is a popular mascara known for its volumizing and lengthening effects.",
|
|
126
|
+
"price": 9.99,
|
|
127
|
+
"category": "Beauty",
|
|
128
|
+
"stock": 99,
|
|
129
|
+
"image_url": "https://cdn.dummyjson.com/product-images/beauty/essence-mascara-lash-princess/thumbnail.webp"
|
|
130
|
+
},
|
|
131
|
+
"availability": "In Stock",
|
|
132
|
+
"stockMessage": "Available"
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
],
|
|
136
|
+
"tags": ["products", "details", "ecommerce"]
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"uri": "/categories",
|
|
140
|
+
"name": "Product Categories",
|
|
141
|
+
"description": "Shows all available product categories with counts",
|
|
142
|
+
"examples": [
|
|
143
|
+
{
|
|
144
|
+
"name": "All Categories",
|
|
145
|
+
"description": "List of all product categories",
|
|
146
|
+
"data": {
|
|
147
|
+
"categories": [
|
|
148
|
+
{ "name": "Beauty", "productCount": 5 },
|
|
149
|
+
{ "name": "Fragrances", "productCount": 5 },
|
|
150
|
+
{ "name": "Furniture", "productCount": 5 },
|
|
151
|
+
{ "name": "Groceries", "productCount": 5 }
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
"tags": ["products", "categories", "navigation"]
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"uri": "/add-to-cart",
|
|
160
|
+
"name": "Add to Cart Confirmation",
|
|
161
|
+
"description": "Confirms a product was added to the shopping cart",
|
|
162
|
+
"examples": [
|
|
163
|
+
{
|
|
164
|
+
"name": "Added Mascara",
|
|
165
|
+
"description": "Confirmation for adding 2 mascaras",
|
|
166
|
+
"data": {
|
|
167
|
+
"message": "Added to cart!",
|
|
168
|
+
"item": {
|
|
169
|
+
"id": "prod-1",
|
|
170
|
+
"name": "Essence Mascara Lash Princess",
|
|
171
|
+
"price": 9.99,
|
|
172
|
+
"quantity": 2,
|
|
173
|
+
"image_url": "https://cdn.dummyjson.com/product-images/beauty/essence-mascara-lash-princess/thumbnail.webp"
|
|
174
|
+
},
|
|
175
|
+
"cartItemCount": 2
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
],
|
|
179
|
+
"tags": ["cart", "ecommerce", "confirmation"]
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"uri": "/shopping-cart",
|
|
183
|
+
"name": "Shopping Cart",
|
|
184
|
+
"description": "Displays all items in the shopping cart with total",
|
|
185
|
+
"examples": [
|
|
186
|
+
{
|
|
187
|
+
"name": "Cart with 2 Items",
|
|
188
|
+
"description": "Shopping cart with mascara and eyeshadow",
|
|
189
|
+
"data": {
|
|
190
|
+
"items": [
|
|
191
|
+
{
|
|
192
|
+
"id": "cart-item-1",
|
|
193
|
+
"quantity": 2,
|
|
194
|
+
"product_id": "prod-1",
|
|
195
|
+
"name": "Essence Mascara Lash Princess",
|
|
196
|
+
"price": 9.99,
|
|
197
|
+
"image_url": "https://cdn.dummyjson.com/product-images/beauty/essence-mascara-lash-princess/thumbnail.webp"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"id": "cart-item-2",
|
|
201
|
+
"quantity": 1,
|
|
202
|
+
"product_id": "prod-2",
|
|
203
|
+
"name": "Eyeshadow Palette with Mirror",
|
|
204
|
+
"price": 19.99,
|
|
205
|
+
"image_url": "https://cdn.dummyjson.com/product-images/beauty/eyeshadow-palette-with-mirror/thumbnail.webp"
|
|
206
|
+
}
|
|
207
|
+
],
|
|
208
|
+
"total": 39.97,
|
|
209
|
+
"itemCount": 2
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
],
|
|
213
|
+
"tags": ["cart", "ecommerce", "shopping"]
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"uri": "/cart-updated",
|
|
217
|
+
"name": "Cart Updated",
|
|
218
|
+
"description": "Confirms cart item quantity was updated",
|
|
219
|
+
"examples": [
|
|
220
|
+
{
|
|
221
|
+
"name": "Updated Quantity",
|
|
222
|
+
"description": "Updated mascara quantity to 3",
|
|
223
|
+
"data": {
|
|
224
|
+
"message": "Cart updated successfully",
|
|
225
|
+
"product": "Essence Mascara Lash Princess",
|
|
226
|
+
"quantity": 3
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
],
|
|
230
|
+
"tags": ["cart", "update", "confirmation"]
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"uri": "/cart-cleared",
|
|
234
|
+
"name": "Cart Cleared",
|
|
235
|
+
"description": "Confirms all items were removed from cart",
|
|
236
|
+
"examples": [
|
|
237
|
+
{
|
|
238
|
+
"name": "Cleared Cart",
|
|
239
|
+
"description": "Cart cleared with 2 items removed",
|
|
240
|
+
"data": {
|
|
241
|
+
"message": "Shopping cart cleared",
|
|
242
|
+
"itemsRemoved": 2
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
],
|
|
246
|
+
"tags": ["cart", "clear", "confirmation"]
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
"uri": "/order-confirmation",
|
|
250
|
+
"name": "Order Confirmation",
|
|
251
|
+
"description": "Displays order confirmation with items and total",
|
|
252
|
+
"examples": [
|
|
253
|
+
{
|
|
254
|
+
"name": "Order Placed",
|
|
255
|
+
"description": "Confirmation for order with 2 items",
|
|
256
|
+
"data": {
|
|
257
|
+
"message": "Order created successfully!",
|
|
258
|
+
"order": {
|
|
259
|
+
"id": "order-12345",
|
|
260
|
+
"total": 39.97,
|
|
261
|
+
"status": "pending",
|
|
262
|
+
"estimated_delivery": "3-5 business days",
|
|
263
|
+
"payment_method": "credit_card",
|
|
264
|
+
"created_at": "2024-01-15T10:30:00Z",
|
|
265
|
+
"items": [
|
|
266
|
+
{
|
|
267
|
+
"id": "prod-1",
|
|
268
|
+
"product_id": "prod-1",
|
|
269
|
+
"name": "Essence Mascara Lash Princess",
|
|
270
|
+
"quantity": 2,
|
|
271
|
+
"price": 9.99,
|
|
272
|
+
"image_url": "https://cdn.dummyjson.com/product-images/beauty/essence-mascara-lash-princess/thumbnail.webp"
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
"id": "prod-2",
|
|
276
|
+
"product_id": "prod-2",
|
|
277
|
+
"name": "Eyeshadow Palette with Mirror",
|
|
278
|
+
"quantity": 1,
|
|
279
|
+
"price": 19.99,
|
|
280
|
+
"image_url": "https://cdn.dummyjson.com/product-images/beauty/eyeshadow-palette-with-mirror/thumbnail.webp"
|
|
281
|
+
}
|
|
282
|
+
]
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
],
|
|
287
|
+
"tags": ["orders", "checkout", "confirmation"]
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"uri": "/order-history",
|
|
291
|
+
"name": "Order History",
|
|
292
|
+
"description": "Shows a list of all user orders",
|
|
293
|
+
"examples": [
|
|
294
|
+
{
|
|
295
|
+
"name": "Past Orders",
|
|
296
|
+
"description": "List of 2 orders",
|
|
297
|
+
"data": {
|
|
298
|
+
"orders": [
|
|
299
|
+
{
|
|
300
|
+
"id": "order-12345",
|
|
301
|
+
"total": 39.97,
|
|
302
|
+
"status": "pending",
|
|
303
|
+
"created_at": "2024-01-15T10:30:00Z",
|
|
304
|
+
"itemCount": 2
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"id": "order-12344",
|
|
308
|
+
"total": 89.96,
|
|
309
|
+
"status": "delivered",
|
|
310
|
+
"created_at": "2024-01-10T14:20:00Z",
|
|
311
|
+
"itemCount": 3
|
|
312
|
+
}
|
|
313
|
+
],
|
|
314
|
+
"totalOrders": 2,
|
|
315
|
+
"pagination": {
|
|
316
|
+
"page": 1,
|
|
317
|
+
"totalPages": 1,
|
|
318
|
+
"totalResults": 2
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
],
|
|
323
|
+
"tags": ["orders", "history", "ecommerce"]
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
"uri": "/order-details",
|
|
327
|
+
"name": "Order Details",
|
|
328
|
+
"description": "Shows detailed information for a specific order",
|
|
329
|
+
"examples": [
|
|
330
|
+
{
|
|
331
|
+
"name": "Order #12345",
|
|
332
|
+
"description": "Details for order with 2 items",
|
|
333
|
+
"data": {
|
|
334
|
+
"order": {
|
|
335
|
+
"id": "order-12345",
|
|
336
|
+
"total": 39.97,
|
|
337
|
+
"status": "pending",
|
|
338
|
+
"payment_method": "credit_card",
|
|
339
|
+
"created_at": "2024-01-15T10:30:00Z",
|
|
340
|
+
"items": [
|
|
341
|
+
{
|
|
342
|
+
"id": "prod-1",
|
|
343
|
+
"product_id": "prod-1",
|
|
344
|
+
"name": "Essence Mascara Lash Princess",
|
|
345
|
+
"quantity": 2,
|
|
346
|
+
"price": 9.99,
|
|
347
|
+
"image_url": "https://cdn.dummyjson.com/product-images/beauty/essence-mascara-lash-princess/thumbnail.webp"
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
"id": "prod-2",
|
|
351
|
+
"product_id": "prod-2",
|
|
352
|
+
"name": "Eyeshadow Palette with Mirror",
|
|
353
|
+
"quantity": 1,
|
|
354
|
+
"price": 19.99,
|
|
355
|
+
"image_url": "https://cdn.dummyjson.com/product-images/beauty/eyeshadow-palette-with-mirror/thumbnail.webp"
|
|
356
|
+
}
|
|
357
|
+
]
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
],
|
|
362
|
+
"tags": ["orders", "details", "ecommerce"]
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
"uri": "/address-added",
|
|
366
|
+
"name": "Address Added",
|
|
367
|
+
"description": "Confirms a new shipping address was added",
|
|
368
|
+
"examples": [
|
|
369
|
+
{
|
|
370
|
+
"name": "New Address",
|
|
371
|
+
"description": "Confirmation for adding address",
|
|
372
|
+
"data": {
|
|
373
|
+
"message": "Address added successfully!",
|
|
374
|
+
"addressId": "addr-1",
|
|
375
|
+
"isDefault": true
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
],
|
|
379
|
+
"tags": ["address", "shipping", "confirmation"]
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
"uri": "/address-list",
|
|
383
|
+
"name": "Address List",
|
|
384
|
+
"description": "Shows all saved shipping addresses",
|
|
385
|
+
"examples": [
|
|
386
|
+
{
|
|
387
|
+
"name": "All Addresses",
|
|
388
|
+
"description": "List of 2 saved addresses",
|
|
389
|
+
"data": {
|
|
390
|
+
"addresses": [
|
|
391
|
+
{
|
|
392
|
+
"id": "addr-1",
|
|
393
|
+
"full_name": "Emily Johnson",
|
|
394
|
+
"street": "123 Main Street",
|
|
395
|
+
"city": "San Francisco",
|
|
396
|
+
"state": "CA",
|
|
397
|
+
"zip_code": "94102",
|
|
398
|
+
"country": "USA",
|
|
399
|
+
"phone": "+1-555-0100",
|
|
400
|
+
"is_default": true
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
"id": "addr-2",
|
|
404
|
+
"full_name": "Emily Johnson",
|
|
405
|
+
"street": "456 Office Blvd",
|
|
406
|
+
"city": "San Francisco",
|
|
407
|
+
"state": "CA",
|
|
408
|
+
"zip_code": "94103",
|
|
409
|
+
"country": "USA",
|
|
410
|
+
"phone": "+1-555-0100",
|
|
411
|
+
"is_default": false
|
|
412
|
+
}
|
|
413
|
+
]
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
],
|
|
417
|
+
"tags": ["address", "shipping", "list"]
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
"uri": "/address-updated",
|
|
421
|
+
"name": "Address Updated",
|
|
422
|
+
"description": "Confirms an address was set as default",
|
|
423
|
+
"examples": [
|
|
424
|
+
{
|
|
425
|
+
"name": "Default Address Set",
|
|
426
|
+
"description": "Confirmation for setting default address",
|
|
427
|
+
"data": {
|
|
428
|
+
"message": "Default address updated!",
|
|
429
|
+
"address": {
|
|
430
|
+
"id": "addr-2",
|
|
431
|
+
"full_name": "Emily Johnson",
|
|
432
|
+
"street": "456 Office Blvd",
|
|
433
|
+
"city": "San Francisco",
|
|
434
|
+
"state": "CA",
|
|
435
|
+
"zip_code": "94103",
|
|
436
|
+
"country": "USA",
|
|
437
|
+
"phone": "+1-555-0100",
|
|
438
|
+
"is_default": true
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
],
|
|
443
|
+
"tags": ["address", "update", "confirmation"]
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
"uri": "/address-deleted",
|
|
447
|
+
"name": "Address Deleted",
|
|
448
|
+
"description": "Confirms an address was deleted",
|
|
449
|
+
"examples": [
|
|
450
|
+
{
|
|
451
|
+
"name": "Address Removed",
|
|
452
|
+
"description": "Confirmation for deleting address",
|
|
453
|
+
"data": {
|
|
454
|
+
"message": "Address deleted successfully!",
|
|
455
|
+
"addressId": "addr-2"
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
],
|
|
459
|
+
"tags": ["address", "delete", "confirmation"]
|
|
460
|
+
}
|
|
461
|
+
],
|
|
462
|
+
"generatedAt": "2025-01-24T00:00:00.000Z"
|
|
463
|
+
}
|
|
464
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ES2022",
|
|
5
|
+
"lib": ["ES2022"],
|
|
6
|
+
"moduleResolution": "node",
|
|
7
|
+
"rootDir": "./src",
|
|
8
|
+
"outDir": "./dist",
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"strict": true,
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"resolveJsonModule": true,
|
|
14
|
+
"declaration": true,
|
|
15
|
+
"declarationMap": true,
|
|
16
|
+
"sourceMap": true,
|
|
17
|
+
"experimentalDecorators": true,
|
|
18
|
+
"emitDecoratorMetadata": true
|
|
19
|
+
},
|
|
20
|
+
"include": ["src/**/*"],
|
|
21
|
+
"exclude": ["node_modules", "dist", "src/widgets"],
|
|
22
|
+
"ts-node": {
|
|
23
|
+
"esm": true,
|
|
24
|
+
"experimentalSpecifierResolution": "node"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# API Key Authentication - Test Keys
|
|
2
|
+
# ⚠️ These are demo keys for testing only - DO NOT use in production!
|
|
3
|
+
|
|
4
|
+
# Test API Keys
|
|
5
|
+
API_KEY_1=sk_test_public_demo_key_12345
|
|
6
|
+
API_KEY_2=sk_test_admin_demo_key_67890
|
|
7
|
+
|
|
8
|
+
# You can add more keys by incrementing the number
|
|
9
|
+
# API_KEY_3=your_custom_key_here
|
|
10
|
+
# API_KEY_4=another_key_here
|
|
11
|
+
|
|
12
|
+
# Note: Keys are loaded automatically by ApiKeyModule
|
|
13
|
+
# The module reads all environment variables matching the pattern API_KEY_*
|
|
14
|
+
|
|
15
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { McpApp, Module, ApiKeyModule } from 'nitrostack';
|
|
2
|
+
import { DemoModule } from './modules/demo/demo.module.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* App Module - Root module for the API Key Auth MCP Server
|
|
6
|
+
*
|
|
7
|
+
* This module demonstrates how to build an MCP server with API key authentication.
|
|
8
|
+
*/
|
|
9
|
+
@McpApp({
|
|
10
|
+
module: AppModule,
|
|
11
|
+
server: {
|
|
12
|
+
name: 'API Key Auth MCP Server',
|
|
13
|
+
version: '1.0.0',
|
|
14
|
+
},
|
|
15
|
+
logging: {
|
|
16
|
+
level: 'info',
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
@Module({
|
|
20
|
+
name: 'app',
|
|
21
|
+
description: 'Root application module with API key authentication',
|
|
22
|
+
imports: [
|
|
23
|
+
// Enable API key authentication
|
|
24
|
+
ApiKeyModule.forRoot({
|
|
25
|
+
keysEnvPrefix: 'API_KEY', // Reads API_KEY_1, API_KEY_2, etc.
|
|
26
|
+
headerName: 'x-api-key',
|
|
27
|
+
metadataField: 'apiKey',
|
|
28
|
+
hashed: false, // Set to true in production
|
|
29
|
+
}),
|
|
30
|
+
|
|
31
|
+
// Feature modules
|
|
32
|
+
DemoModule,
|
|
33
|
+
],
|
|
34
|
+
controllers: [],
|
|
35
|
+
providers: [],
|
|
36
|
+
})
|
|
37
|
+
export class AppModule {}
|
|
38
|
+
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Guard, ExecutionContext, ApiKeyModule, ApiKeyMetadata } from 'nitrostack';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* API Key Guard
|
|
5
|
+
*
|
|
6
|
+
* Validates API keys for tool access.
|
|
7
|
+
* Keys are extracted from context.metadata.apiKey or context.metadata['x-api-key']
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* ```typescript
|
|
11
|
+
* @Tool({
|
|
12
|
+
* name: 'protected_tool',
|
|
13
|
+
* description: 'A protected tool that requires API key'
|
|
14
|
+
* })
|
|
15
|
+
* @UseGuards(ApiKeyGuard)
|
|
16
|
+
* async protectedTool() {
|
|
17
|
+
* // Only accessible with valid API key
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export class ApiKeyGuard implements Guard {
|
|
22
|
+
async canActivate(context: ExecutionContext): Promise<boolean> {
|
|
23
|
+
// Extract API key from metadata (sent by Studio or client)
|
|
24
|
+
const apiKey = context.metadata?.apiKey || context.metadata?.['x-api-key'];
|
|
25
|
+
|
|
26
|
+
if (!apiKey) {
|
|
27
|
+
throw new Error('API key required. Please set your API key in the Studio Auth tab (OAuth 2.1 page).');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Validate API key using ApiKeyModule
|
|
31
|
+
const isValid = await ApiKeyModule.validate(apiKey as string);
|
|
32
|
+
|
|
33
|
+
if (!isValid) {
|
|
34
|
+
throw new Error('Invalid API key. Please check your API key in the Studio Auth tab.');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Populate context.auth with API key metadata
|
|
38
|
+
context.auth = {
|
|
39
|
+
subject: `apikey_${(apiKey as string).substring(0, 12)}`,
|
|
40
|
+
scopes: ['*'], // API keys typically have full access
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|