@nitrostack/cli 1.0.6 → 1.0.8
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/LICENSE +201 -0
- package/README.md +39 -96
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +4 -1
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +24 -52
- package/dist/commands/generate-types.d.ts +0 -1
- package/dist/commands/generate-types.d.ts.map +1 -1
- package/dist/commands/generate-types.js +18 -39
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +12 -4
- package/dist/commands/init.d.ts +3 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +27 -15
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +3 -1
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +4 -4
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +92 -77
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/ui/branding.d.ts +21 -4
- package/dist/ui/branding.d.ts.map +1 -1
- package/dist/ui/branding.js +121 -52
- package/package.json +5 -6
- package/templates/typescript-oauth/.env.example +27 -0
- package/templates/typescript-oauth/README.md +36 -231
- package/templates/typescript-pizzaz/.env.example +8 -0
- package/templates/typescript-pizzaz/README.md +42 -217
- package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.module.ts +2 -1
- package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.tasks.ts +294 -0
- package/templates/typescript-starter/.env.example +7 -0
- package/templates/typescript-starter/README.md +51 -284
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# OAuth 2.1 MCP Server Configuration
|
|
2
|
+
# =============================================================================
|
|
3
|
+
# TRANSPORT MODE (AUTO-CONFIGURED)
|
|
4
|
+
# =============================================================================
|
|
5
|
+
# When OAuth is configured, the server automatically runs in DUAL mode:
|
|
6
|
+
# - STDIO: For MCP proto¯col communication with Studio/Claude
|
|
7
|
+
# - HTTP: For OAuth metadata endpoints (/.well-known/oauth-protected-resource)
|
|
8
|
+
# Both transports run simultaneously on different channels.
|
|
9
|
+
# =============================================================================
|
|
10
|
+
# REQUIRED: Server Configuration
|
|
11
|
+
# =============================================================================
|
|
12
|
+
# =============================================================================
|
|
13
|
+
# Auth0 Configuration
|
|
14
|
+
# =============================================================================
|
|
15
|
+
# After creating your API and Application in Auth0, fill in these values:
|
|
16
|
+
# Your Auth0 API Identifier (from APIs → MCP Server → Identifier)
|
|
17
|
+
# This MUST match exactly what you set when creating the API
|
|
18
|
+
# This MUST match exactly what you set when creating the API
|
|
19
|
+
RESOURCE_URI=https://mcplocal
|
|
20
|
+
# Your Auth0 tenant domain (authorization server)
|
|
21
|
+
AUTH_SERVER_URL=https://dev-5dt0utuk315713tjm.us.auth0.com
|
|
22
|
+
# Expected token audience (should match RESOURCE_URI)
|
|
23
|
+
TOKEN_AUDIENCE=https://mcplocal
|
|
24
|
+
# Expected token issuer (your Auth0 tenant domain with trailing slash)
|
|
25
|
+
TOKEN_ISSUER=https://dev-5dt0utuk315713tjm.us.auth0.com
|
|
26
|
+
|
|
27
|
+
DUFFEL_API_KEY=duffel_test_-w0wGDHB0M3DU9k-sBeUbxLqwcibUQqfEbjWDTKNnly
|
|
@@ -1,263 +1,68 @@
|
|
|
1
1
|
# ✈️ NitroStack Flight Booking
|
|
2
2
|
|
|
3
|
-
A production-ready
|
|
3
|
+
A production-ready template showcasing real-time flight search and booking with **Duffel API** integration. Learn how to build complex, authenticated MCP servers with high-impact visual widgets.
|
|
4
4
|
|
|
5
5
|
## ✨ Features
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
- Booking and order management
|
|
7
|
+
- **Real-time Search** — Powered by the Duffel API (300+ airlines).
|
|
8
|
+
- **Seat Selection** — Interactive visual cabin maps with seat pickers.
|
|
9
|
+
- **Secure Payments** — Simulated secure booking and confirmation flows.
|
|
10
|
+
- **Advanced Auth** — Optional OAuth 2.1 support for protected MCP servers.
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
- **Airport Search** - Autocomplete airport selection
|
|
15
|
-
- **Flight Search Results** - Compare flights with prices
|
|
16
|
-
- **Flight Details** - Comprehensive flight information
|
|
17
|
-
- **Seat Selection** - Visual cabin map with seat picker
|
|
18
|
-
- **Order Summary** - Complete booking overview
|
|
19
|
-
- **Payment Confirmation** - Secure payment flow
|
|
20
|
-
|
|
21
|
-
### 🛠️ **MCP Tools**
|
|
22
|
-
- `search_airports` - Find airports by name/code
|
|
23
|
-
- `search_flights` - Search available flights
|
|
24
|
-
- `show_flight_details` - Detailed flight information
|
|
25
|
-
- `select_seats` - Interactive seat selection
|
|
26
|
-
- `create_booking` - Book flights
|
|
27
|
-
- `get_order` - Retrieve booking details
|
|
12
|
+
---
|
|
28
13
|
|
|
29
14
|
## 🚀 Quick Start
|
|
30
15
|
|
|
31
|
-
###
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
# Install NitroStack CLI globally
|
|
35
|
-
npm install -g nitrostack
|
|
36
|
-
|
|
37
|
-
# Or use npx
|
|
38
|
-
npx nitrostack --version
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### 1. Create Your Project
|
|
16
|
+
### 1. Initialize Your Project
|
|
42
17
|
|
|
43
18
|
```bash
|
|
44
|
-
|
|
45
|
-
nitrostack init my-flight-app --template typescript-oauth
|
|
19
|
+
npx nitrostack init my-flight-app --template typescript-oauth
|
|
46
20
|
cd my-flight-app
|
|
47
|
-
|
|
48
|
-
# Install all dependencies (root + widgets)
|
|
49
|
-
nitrostack install
|
|
50
21
|
```
|
|
51
22
|
|
|
52
|
-
### 2.
|
|
53
|
-
|
|
54
|
-
[Duffel](https://duffel.com/) provides a free API for flight search and booking:
|
|
55
|
-
|
|
56
|
-
1. **Sign up** at [duffel.com](https://duffel.com/) (click "Start now" - it's free!)
|
|
57
|
-
2. Create a free account (no credit card required)
|
|
58
|
-
3. Go to your **Dashboard** → **Developers** → **Access tokens**
|
|
59
|
-
4. Click **"Create token"** to generate your API key
|
|
60
|
-
5. Copy the token (starts with `duffel_test_` for sandbox)
|
|
61
|
-
|
|
62
|
-
> 💡 **Tip**: The test mode (`duffel_test_*` tokens) gives you access to realistic mock data for development. Production tokens (`duffel_live_*`) connect to real airlines.
|
|
63
|
-
|
|
64
|
-
### 3. Configure Environment
|
|
65
|
-
|
|
66
|
-
Copy the example environment file and add your Duffel API key:
|
|
23
|
+
### 2. Install Dependencies
|
|
67
24
|
|
|
68
25
|
```bash
|
|
69
|
-
|
|
26
|
+
npm run install:all
|
|
70
27
|
```
|
|
71
28
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
```env
|
|
75
|
-
# Duffel API Configuration
|
|
76
|
-
DUFFEL_API_KEY=duffel_test_your_api_key_here
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### 4. Run Development Server
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
npm run dev
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
This starts:
|
|
86
|
-
- **MCP Server** - Hot reloads on code changes
|
|
87
|
-
- **Studio** on http://localhost:3000 - Visual testing environment
|
|
88
|
-
- **Widget Dev Server** on http://localhost:3001 - Hot module replacement
|
|
89
|
-
|
|
90
|
-
### 5. Test in Studio
|
|
91
|
-
|
|
92
|
-
Try these prompts in Studio chat:
|
|
93
|
-
- "Search flights from London to New York for next week"
|
|
94
|
-
- "Show me flight details"
|
|
95
|
-
- "I want to select seats"
|
|
96
|
-
- "Show me flights from JFK to LAX"
|
|
97
|
-
|
|
98
|
-
## 📁 Project Structure
|
|
99
|
-
|
|
100
|
-
```
|
|
101
|
-
typescript-oauth/
|
|
102
|
-
├── src/
|
|
103
|
-
│ ├── index.ts # Main server entry
|
|
104
|
-
│ ├── app.module.ts # App module
|
|
105
|
-
│ ├── services/
|
|
106
|
-
│ │ └── duffel.service.ts # Duffel API client
|
|
107
|
-
│ └── modules/
|
|
108
|
-
│ └── flights/
|
|
109
|
-
│ ├── flights.module.ts # Module definition
|
|
110
|
-
│ ├── flights.tools.ts # Search & display tools
|
|
111
|
-
│ ├── flights.prompts.ts # AI prompts
|
|
112
|
-
│ ├── flights.resources.ts # Static resources
|
|
113
|
-
│ └── booking.tools.ts # Booking tools
|
|
114
|
-
│ └── widgets/
|
|
115
|
-
│ ├── app/
|
|
116
|
-
│ │ ├── airport-search/ # Airport autocomplete
|
|
117
|
-
│ │ ├── flight-search-results/ # Results list
|
|
118
|
-
│ │ ├── flight-details/ # Flight info
|
|
119
|
-
│ │ ├── seat-selection/ # Seat picker
|
|
120
|
-
│ │ ├── order-summary/ # Booking summary
|
|
121
|
-
│ │ └── payment-confirmation/ # Payment widget
|
|
122
|
-
├── .env.example # Environment template
|
|
123
|
-
├── OAUTH_SETUP.md # OAuth configuration guide
|
|
124
|
-
├── package.json
|
|
125
|
-
└── README.md
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
## 🔧 Commands
|
|
129
|
-
|
|
130
|
-
```bash
|
|
131
|
-
# Installation
|
|
132
|
-
npm install # Install all dependencies (root + widgets)
|
|
133
|
-
nitrostack install # Same as above
|
|
29
|
+
### 3. Get NitroStudio
|
|
134
30
|
|
|
135
|
-
|
|
136
|
-
npm run dev # Start dev server with Studio
|
|
137
|
-
npm run build # Build TypeScript and widgets for production
|
|
138
|
-
npm start # Run production server
|
|
31
|
+
Experience the visual seat selection and flight search as your users would see it.
|
|
139
32
|
|
|
140
|
-
|
|
141
|
-
|
|
33
|
+
1. **Download NitroStudio**: [nitrostack.ai/studio](https://nitrostack.ai/studio)
|
|
34
|
+
2. **Open Project**: Launch NitroStudio and select your project folder.
|
|
142
35
|
|
|
143
|
-
|
|
144
|
-
npm run widget <command> # Run npm command in widgets directory
|
|
145
|
-
npm run widget add <pkg> # Add a widget dependency
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
## 🔐 OAuth Setup (Optional)
|
|
149
|
-
|
|
150
|
-
This template includes OAuth 2.1 authentication support. If you want to protect your MCP server with authentication:
|
|
151
|
-
|
|
152
|
-
1. Read the detailed guide: **[OAUTH_SETUP.md](./OAUTH_SETUP.md)**
|
|
153
|
-
2. Configure Auth0 (or your OAuth provider)
|
|
154
|
-
3. Update your `.env` with OAuth credentials
|
|
155
|
-
|
|
156
|
-
> **Note**: OAuth is optional for local development. The template works without it using Duffel's test API.
|
|
157
|
-
|
|
158
|
-
## 📊 Duffel API Features
|
|
159
|
-
|
|
160
|
-
### Test Mode vs Live Mode
|
|
161
|
-
|
|
162
|
-
| Feature | Test Mode (`duffel_test_*`) | Live Mode (`duffel_live_*`) |
|
|
163
|
-
|---------|----------------------------|----------------------------|
|
|
164
|
-
| API Access | ✅ Full access | ✅ Full access |
|
|
165
|
-
| Pricing | Mock data | Real prices |
|
|
166
|
-
| Bookings | Simulated | Real bookings |
|
|
167
|
-
| Credit Card | Not charged | Charged |
|
|
168
|
-
| Rate Limits | Generous | Production limits |
|
|
169
|
-
|
|
170
|
-
### Supported Airlines
|
|
171
|
-
|
|
172
|
-
Duffel provides access to 300+ airlines including:
|
|
173
|
-
- Major carriers (British Airways, Lufthansa, Emirates, etc.)
|
|
174
|
-
- Low-cost carriers (Ryanair, EasyJet, Spirit, etc.)
|
|
175
|
-
- Regional airlines
|
|
176
|
-
|
|
177
|
-
### API Capabilities
|
|
178
|
-
|
|
179
|
-
- **Search**: Real-time availability and pricing
|
|
180
|
-
- **Ancillaries**: Seats, bags, meals
|
|
181
|
-
- **Booking**: Create and manage orders
|
|
182
|
-
- **Changes**: Modify existing bookings
|
|
183
|
-
- **Cancellations**: Cancel and refund
|
|
184
|
-
|
|
185
|
-
## 🎨 Widget Features
|
|
186
|
-
|
|
187
|
-
### Airport Search Widget
|
|
188
|
-
- Autocomplete with IATA codes
|
|
189
|
-
- City and airport name search
|
|
190
|
-
- Recent searches
|
|
191
|
-
|
|
192
|
-
### Flight Search Results Widget
|
|
193
|
-
- Compare multiple flights
|
|
194
|
-
- Filter by stops, price, time
|
|
195
|
-
- Sort options
|
|
196
|
-
- Airline logos
|
|
197
|
-
|
|
198
|
-
### Flight Details Widget
|
|
199
|
-
- Complete itinerary
|
|
200
|
-
- Fare breakdown
|
|
201
|
-
- Baggage allowance
|
|
202
|
-
- Flight duration and stops
|
|
203
|
-
|
|
204
|
-
### Seat Selection Widget
|
|
205
|
-
- Visual cabin map
|
|
206
|
-
- Seat categories (standard, extra legroom, etc.)
|
|
207
|
-
- Price per seat
|
|
208
|
-
- Real-time availability
|
|
209
|
-
|
|
210
|
-
## 🛠️ Customization
|
|
211
|
-
|
|
212
|
-
### Adding New Airlines
|
|
213
|
-
|
|
214
|
-
Duffel handles airline integrations automatically. You don't need to configure individual airlines.
|
|
215
|
-
|
|
216
|
-
### Modifying Search Parameters
|
|
217
|
-
|
|
218
|
-
Edit `src/modules/flights/flights.tools.ts` to customize:
|
|
219
|
-
- Default passenger counts
|
|
220
|
-
- Cabin class options
|
|
221
|
-
- Date ranges
|
|
222
|
-
- Result limits
|
|
223
|
-
|
|
224
|
-
### Styling Widgets
|
|
225
|
-
|
|
226
|
-
Each widget in `src/widgets/app/` can be customized:
|
|
227
|
-
- Edit page.tsx for layout
|
|
228
|
-
- Add custom CSS
|
|
229
|
-
- Modify component styles
|
|
36
|
+
---
|
|
230
37
|
|
|
231
|
-
##
|
|
38
|
+
## ⚙️ Configuration
|
|
232
39
|
|
|
233
|
-
### Duffel
|
|
234
|
-
- [Duffel API Docs](https://duffel.com/docs/api)
|
|
235
|
-
- [Duffel SDK (Node.js)](https://github.com/duffel/duffel-api-javascript)
|
|
236
|
-
- [Duffel Postman Collection](https://duffel.com/docs/postman)
|
|
40
|
+
### 1. Duffel API Key
|
|
237
41
|
|
|
238
|
-
|
|
239
|
-
- [NitroStack Docs](https://nitrostack.ai/docs)
|
|
240
|
-
- [Widget Development Guide](https://nitrostack.ai/docs/widgets)
|
|
42
|
+
You need a free Duffel API key to see live flight data:
|
|
241
43
|
|
|
242
|
-
|
|
44
|
+
1. Sign up at [duffel.com](https://duffel.com/).
|
|
45
|
+
2. Copy your **Test Token** from the dashboard.
|
|
46
|
+
3. Create `.env` from the example:
|
|
47
|
+
```bash
|
|
48
|
+
cp .env.example .env
|
|
49
|
+
```
|
|
50
|
+
4. Update `DUFFEL_API_KEY` in your `.env`.
|
|
243
51
|
|
|
244
|
-
|
|
245
|
-
- **Check Rate Limits**: Duffel has rate limits - cache searches when possible
|
|
246
|
-
- **Error Handling**: The template includes comprehensive error handling
|
|
247
|
-
- **Responsive Design**: Widgets are mobile-friendly out of the box
|
|
52
|
+
### 2. OAuth (Optional)
|
|
248
53
|
|
|
249
|
-
|
|
54
|
+
For production scenarios requiring user authentication, refer to [OAUTH_SETUP.md](./OAUTH_SETUP.md).
|
|
250
55
|
|
|
251
|
-
|
|
252
|
-
- Try the **Pizza Shop Template** - Interactive maps with Mapbox
|
|
253
|
-
- Read the [Duffel Getting Started Guide](https://duffel.com/docs/guides/getting-started)
|
|
56
|
+
---
|
|
254
57
|
|
|
255
|
-
##
|
|
58
|
+
## 🛠️ Commands
|
|
256
59
|
|
|
257
|
-
|
|
60
|
+
- `npm run dev` — Start the development ecosystem.
|
|
61
|
+
- `npm run build` — Bundle TypeScript and widgets for deployment.
|
|
62
|
+
- `npm run upgrade` — Keep NitroStack core up to date.
|
|
258
63
|
|
|
259
64
|
---
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
65
|
+
**Official Resources**
|
|
66
|
+
- [Website](https://nitrostack.ai)
|
|
67
|
+
- [Docs](https://docs.nitrostack.ai)
|
|
68
|
+
- [Duffel API](https://duffel.com/docs)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Mapbox Configuration (Optional)
|
|
2
|
+
# =============================================================================
|
|
3
|
+
# The map widget uses Mapbox GL for interactive maps.
|
|
4
|
+
# Get a free API key at: https://www.mapbox.com/
|
|
5
|
+
# =============================================================================
|
|
6
|
+
|
|
7
|
+
# Your Mapbox Public Token (starts with pk.)
|
|
8
|
+
NEXT_PUBLIC_MAPBOX_TOKEN=pk.your_mapbox_token_here
|
|
@@ -1,252 +1,77 @@
|
|
|
1
1
|
# 🍕 NitroStack Pizza Shop Finder
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A high-performance interactive template showcasing discovery with maps, lists, and detailed views. This template demonstrates the **NitroStack Widget SDK** for building beautiful, tool-driven visual experiences.
|
|
4
4
|
|
|
5
|
-
## Features
|
|
5
|
+
## ✨ Features
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
- ✅ `useDisplayMode()` - Fullscreen mode adaptation
|
|
12
|
-
- ✅ `useWidgetSDK()` - Tool calling, navigation, and external links
|
|
13
|
-
- ✅ `<WidgetLayout>` - Automatic RPC setup
|
|
7
|
+
- **Mapbox Integration** — Interactive maps with custom markers.
|
|
8
|
+
- **Real-time State** — Shared state between server and widgets.
|
|
9
|
+
- **Responsive Layouts** — Auto-adapting heights and display modes (Inline, PiP, Fullscreen).
|
|
10
|
+
- **Interactive UI** — Sorting, filtering, and favorites persistence.
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
1. **Pizza Map** - Interactive Mapbox map with markers and shop selection
|
|
17
|
-
2. **Pizza List** - Grid/list view with sorting, filtering, and favorites
|
|
18
|
-
3. **Pizza Shop** - Detailed shop information with contact actions
|
|
19
|
-
|
|
20
|
-
### 📊 **MCP Tools**
|
|
21
|
-
- `show_pizza_map` - Display shops on an interactive map
|
|
22
|
-
- `show_pizza_list` - Show filterable list of shops
|
|
23
|
-
- `show_pizza_shop` - Display detailed shop information
|
|
12
|
+
---
|
|
24
13
|
|
|
25
14
|
## 🚀 Quick Start
|
|
26
15
|
|
|
27
|
-
###
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
# Install NitroStack CLI globally
|
|
31
|
-
npm install -g nitrostack
|
|
32
|
-
|
|
33
|
-
# Or use npx
|
|
34
|
-
npx nitrostack --version
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### Setup Your Project
|
|
16
|
+
### 1. Initialize Your Project
|
|
38
17
|
|
|
39
18
|
```bash
|
|
40
|
-
|
|
41
|
-
nitrostack init my-pizza-app --template typescript-pizzaz
|
|
19
|
+
npx nitrostack init my-pizza-app --template typescript-pizzaz
|
|
42
20
|
cd my-pizza-app
|
|
43
|
-
|
|
44
|
-
# Install all dependencies (root + widgets)
|
|
45
|
-
nitrostack install
|
|
46
21
|
```
|
|
47
22
|
|
|
48
|
-
###
|
|
49
|
-
|
|
50
|
-
The map widget uses Mapbox GL for beautiful interactive maps:
|
|
51
|
-
|
|
52
|
-
1. Get a **free** API key from [Mapbox](https://www.mapbox.com/) (sign up takes 1 minute)
|
|
53
|
-
2. Create `src/widgets/.env` file:
|
|
23
|
+
### 2. Install Dependencies
|
|
54
24
|
|
|
55
25
|
```bash
|
|
56
|
-
|
|
26
|
+
npm run install:all
|
|
57
27
|
```
|
|
58
28
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
### Run Development Server
|
|
29
|
+
### 3. Step Up NitroStudio
|
|
62
30
|
|
|
63
|
-
|
|
64
|
-
npm run dev
|
|
65
|
-
```
|
|
31
|
+
NitroStudio provides the best experience for visual testing of widgets and maps.
|
|
66
32
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
- **Widget Dev Server** on http://localhost:3001 - Hot module replacement
|
|
33
|
+
1. **Download NitroStudio**: [nitrostack.ai/studio](https://nitrostack.ai/studio)
|
|
34
|
+
2. **Open Project**: Launch NitroStudio and select your project folder.
|
|
35
|
+
3. **View Maps**: Use the chat or visual tools to explore your pizza shops.
|
|
71
36
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
Try these prompts in Studio chat:
|
|
75
|
-
- "Show me pizza shops on a map"
|
|
76
|
-
- "List all pizza shops"
|
|
77
|
-
- "Show me details for Tony's New York Pizza"
|
|
78
|
-
- "Find pizza shops with high ratings"
|
|
37
|
+
---
|
|
79
38
|
|
|
80
|
-
##
|
|
39
|
+
## ⚙️ Configuration
|
|
81
40
|
|
|
82
|
-
|
|
83
|
-
typescript-pizzaz/
|
|
84
|
-
├── src/
|
|
85
|
-
│ ├── index.ts # Main server entry
|
|
86
|
-
│ ├── app.module.ts # App module
|
|
87
|
-
│ └── modules/
|
|
88
|
-
│ └── pizzaz/
|
|
89
|
-
│ ├── pizzaz.data.ts # Pizza shop data
|
|
90
|
-
│ ├── pizzaz.service.ts # Business logic
|
|
91
|
-
│ ├── pizzaz.tools.ts # MCP tools
|
|
92
|
-
│ └── pizzaz.module.ts # Module definition
|
|
93
|
-
│ └── widgets/
|
|
94
|
-
│ ├── app/
|
|
95
|
-
│ │ ├── pizza-map/ # Map widget
|
|
96
|
-
│ │ ├── pizza-list/ # List widget
|
|
97
|
-
│ │ └── pizza-shop/ # Shop detail widget
|
|
98
|
-
│ └── components/
|
|
99
|
-
│ └── PizzaCard.tsx # Reusable card component
|
|
100
|
-
├── package.json
|
|
101
|
-
└── README.md
|
|
102
|
-
```
|
|
41
|
+
### Mapbox (Optional)
|
|
103
42
|
|
|
104
|
-
|
|
43
|
+
To enable the interactive map, add your Mapbox token:
|
|
105
44
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
- **Theme-aware** map styles (light/dark)
|
|
45
|
+
1. Get a free token at [mapbox.com](https://www.mapbox.com/).
|
|
46
|
+
2. Create `src/widgets/.env` and add:
|
|
47
|
+
```env
|
|
48
|
+
NEXT_PUBLIC_MAPBOX_TOKEN=pk.your_token_here
|
|
49
|
+
```
|
|
112
50
|
|
|
113
|
-
|
|
114
|
-
- **Grid/List view toggle** with state persistence
|
|
115
|
-
- **Sorting** by rating, name, or price
|
|
116
|
-
- **Favorites tracking** across sessions
|
|
117
|
-
- **Responsive layout** using `useMaxHeight()`
|
|
118
|
-
- **Filter panel** for advanced search
|
|
119
|
-
|
|
120
|
-
### Pizza Shop Widget
|
|
121
|
-
- **Hero image** with overlay information
|
|
122
|
-
- **Contact actions** (call, directions, website)
|
|
123
|
-
- **Specialties showcase**
|
|
124
|
-
- **Related shops** recommendations
|
|
125
|
-
- **External link handling** via `useWidgetSDK()`
|
|
51
|
+
---
|
|
126
52
|
|
|
127
|
-
##
|
|
53
|
+
## 🛠️ Commands
|
|
128
54
|
|
|
129
55
|
```bash
|
|
130
|
-
#
|
|
131
|
-
npm
|
|
132
|
-
nitrostack install # Same as above
|
|
133
|
-
|
|
134
|
-
# Development
|
|
135
|
-
npm run dev # Start dev server with Studio
|
|
136
|
-
npm run build # Build TypeScript and widgets for production
|
|
137
|
-
npm start # Run production server
|
|
138
|
-
|
|
139
|
-
# Upgrade
|
|
140
|
-
npm run upgrade # Upgrade nitrostack to latest version
|
|
141
|
-
|
|
142
|
-
# Widget Management
|
|
143
|
-
npm run widget <command> # Run npm command in widgets directory
|
|
144
|
-
npm run widget add <pkg> # Add a widget dependency
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
## 🛠️ Customization
|
|
148
|
-
|
|
149
|
-
### Adding More Shops
|
|
150
|
-
|
|
151
|
-
Edit `src/modules/pizzaz/pizzaz.data.ts`:
|
|
152
|
-
|
|
153
|
-
```typescript
|
|
154
|
-
export const PIZZA_SHOPS: PizzaShop[] = [
|
|
155
|
-
{
|
|
156
|
-
id: 'my-pizza-shop',
|
|
157
|
-
name: 'My Pizza Shop',
|
|
158
|
-
description: 'Amazing pizza!',
|
|
159
|
-
address: '123 Main St, City, State 12345',
|
|
160
|
-
coords: [-122.4194, 37.7749], // [lng, lat]
|
|
161
|
-
rating: 4.5,
|
|
162
|
-
reviews: 100,
|
|
163
|
-
priceLevel: 2,
|
|
164
|
-
cuisine: ['Italian', 'Pizza'],
|
|
165
|
-
hours: { open: '11:00 AM', close: '10:00 PM' },
|
|
166
|
-
phone: '(555) 123-4567',
|
|
167
|
-
website: 'https://example.com',
|
|
168
|
-
image: 'https://images.unsplash.com/photo-...',
|
|
169
|
-
specialties: ['Margherita', 'Pepperoni'],
|
|
170
|
-
openNow: true,
|
|
171
|
-
},
|
|
172
|
-
// ... more shops
|
|
173
|
-
];
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
### Changing Map Style
|
|
177
|
-
|
|
178
|
-
Edit `src/widgets/app/pizza-map/page.tsx`:
|
|
179
|
-
|
|
180
|
-
```typescript
|
|
181
|
-
style: isDark
|
|
182
|
-
? 'mapbox://styles/mapbox/dark-v11' // Dark mode style
|
|
183
|
-
: 'mapbox://styles/mapbox/streets-v12' // Light mode style
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
### Adding New Filters
|
|
187
|
-
|
|
188
|
-
Edit `src/modules/pizzaz/pizzaz.service.ts` to add more filter options.
|
|
189
|
-
|
|
190
|
-
## 📚 SDK Features Demonstrated
|
|
191
|
-
|
|
192
|
-
### Theme Awareness
|
|
193
|
-
```typescript
|
|
194
|
-
const theme = useTheme(); // 'light' | 'dark'
|
|
195
|
-
const bgColor = theme === 'dark' ? '#000' : '#fff';
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
### State Persistence
|
|
199
|
-
```typescript
|
|
200
|
-
const [state, setState] = useWidgetState(() => ({
|
|
201
|
-
favorites: [],
|
|
202
|
-
viewMode: 'grid',
|
|
203
|
-
}));
|
|
204
|
-
|
|
205
|
-
// State persists across widget reloads
|
|
206
|
-
setState({ ...state, favorites: [...state.favorites, shopId] });
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
### Responsive Layouts
|
|
210
|
-
```typescript
|
|
211
|
-
const maxHeight = useMaxHeight();
|
|
212
|
-
return <div style={{ maxHeight }}>{content}</div>;
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
### Display Mode Adaptation
|
|
216
|
-
```typescript
|
|
217
|
-
const displayMode = useDisplayMode(); // 'inline' | 'pip' | 'fullscreen'
|
|
218
|
-
const showSidebar = displayMode === 'fullscreen';
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
### External Links
|
|
222
|
-
```typescript
|
|
223
|
-
const { openExternal } = useWidgetSDK();
|
|
224
|
-
openExternal('https://example.com');
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
## 🚀 Deployment
|
|
228
|
-
|
|
229
|
-
### Build for Production
|
|
56
|
+
# Start dev server with Studio integration
|
|
57
|
+
npm run dev
|
|
230
58
|
|
|
231
|
-
|
|
59
|
+
# Build for production
|
|
232
60
|
npm run build
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
### Deploy Widgets
|
|
236
|
-
|
|
237
|
-
Widget HTML files will be generated in `src/widgets/out/` - these work identically in any MCP-compatible client including OpenAI ChatGPT.
|
|
238
61
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
- Try the **Flight Booking Template** - API integration with Duffel
|
|
243
|
-
- Read the [NitroStack Documentation](https://nitrostack.ai/docs)
|
|
244
|
-
- Check out [Mapbox GL JS Documentation](https://docs.mapbox.com/mapbox-gl-js/)
|
|
62
|
+
# Manage widgets directly
|
|
63
|
+
npm run widget <command>
|
|
64
|
+
```
|
|
245
65
|
|
|
246
|
-
##
|
|
66
|
+
## 📁 Structure
|
|
247
67
|
|
|
248
|
-
|
|
68
|
+
- `src/modules/pizzaz/` — Core logic and pizza shop data.
|
|
69
|
+
- `src/widgets/app/pizza-map/` — Next.js Map widget.
|
|
70
|
+
- `src/widgets/app/pizza-list/` — Filterable shop list.
|
|
71
|
+
- `src/widgets/app/pizza-shop/` — Detail view with actions.
|
|
249
72
|
|
|
250
73
|
---
|
|
251
|
-
|
|
252
|
-
|
|
74
|
+
**Official Resources**
|
|
75
|
+
- [Website](https://nitrostack.ai)
|
|
76
|
+
- [Docs](https://docs.nitrostack.ai)
|
|
77
|
+
- [Download Studio](https://nitrostack.ai/studio)
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Module } from '@nitrostack/core';
|
|
2
2
|
import { PizzazService } from './pizzaz.service.js';
|
|
3
3
|
import { PizzazTools } from './pizzaz.tools.js';
|
|
4
|
+
import { PizzazTaskTools } from './pizzaz.tasks.js';
|
|
4
5
|
|
|
5
6
|
@Module({
|
|
6
7
|
name: 'pizzaz',
|
|
7
8
|
description: 'Pizza shop finder module',
|
|
8
|
-
controllers: [PizzazTools],
|
|
9
|
+
controllers: [PizzazTools, PizzazTaskTools],
|
|
9
10
|
providers: [PizzazService],
|
|
10
11
|
})
|
|
11
12
|
export class PizzazModule { }
|