wexts 3.0.0 → 3.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/README.md CHANGED
@@ -1,340 +1,346 @@
1
- # Wexts Framework v2
1
+ <div align="center">
2
2
 
3
- ![npm version](https://img.shields.io/npm/v/wexts)
4
- ![license](https://img.shields.io/npm/l/wexts)
5
- ![node version](https://img.shields.io/node/v/wexts)
6
-
7
- **Wexts v2** is a modern, production‑ready full‑stack framework that seamlessly integrates **NestJS 11** and **Next.js 16**. Build type‑safe applications with automatic API client generation, shared types, and an exceptional developer experience.
3
+ ```
4
+ ██╗ ██╗███████╗██╗ ██╗████████╗███████╗
5
+ ██║ ██║██╔════╝╚██╗██╔╝╚══██╔══╝██╔════╝
6
+ ██║ █╗ ██║█████╗ ╚███╔╝ ██║ ███████╗
7
+ ██║███╗██║██╔══╝ ██╔██╗ ██║ ╚════██║
8
+ ╚███╔███╔╝███████╗██╔╝ ██╗ ██║ ███████║
9
+ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚══════╝
10
+ ```
8
11
 
9
- > **Requirements:** Node.js 20.9.0+, PNPM 10.0.0+
12
+ <h1>WEXTS Framework</h1>
10
13
 
11
- ## What's New in v2
14
+ **Build production-ready full-stack apps with Next.js 16 + NestJS 11 in a unified runtime**
12
15
 
13
- - 🎯 **Next.js 16** with Turbopack (stable) and React Compiler
14
- - 🚀 **NestJS 11** with latest architectural improvements
15
- - ⚡ **TypeScript 5.9** with enhanced type inference
16
- - 📦 **Modern Build System** with optimized bundling
17
- - 🔥 **React 19** full support
16
+ [![npm version](https://img.shields.io/npm/v/wexts.svg)](https://www.npmjs.com/package/wexts)
17
+ [![Downloads](https://img.shields.io/npm/dm/wexts.svg)](https://www.npmjs.com/package/wexts)
18
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
19
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.3-blue.svg)](https://www.typescriptlang.org/)
18
20
 
19
- ## 🚀 Features
21
+ [Quick Start](#-quick-start) • [Documentation](https://github.com/ziadmustafa1/wexts#documentation) • [Examples](https://github.com/ziadmustafa1/wexts/tree/main/demo)
20
22
 
21
- - **🔗 NestJS + Next.js Integration** – seamless backend‑frontend connection
22
- - **📦 All‑in‑One SDK** – core utilities, HTTP client, decorators, and hooks in one package
23
- - **🎯 Type‑Safe** – end‑to‑end TypeScript from database to UI
24
- - **🛠️ CLI Tools** – scaffold projects, generate code, manage development
25
- - **⚡ Auto API Client** – generate type‑safe clients from NestJS controllers
26
- - **🔐 Auth Built‑in** – ready‑to‑use authentication hooks for Next.js
27
- - **📝 Configuration Management** – environment‑aware config loader
28
- - **🎨 React Hooks** – `useWexts()`, `useAuth()` for seamless API integration
23
+ </div>
29
24
 
30
25
  ---
31
26
 
32
- ## 📦 Installation
27
+ ## Why WEXTS?
33
28
 
34
- ### Global CLI (run without installing globally)
29
+ Stop managing separate Next.js and NestJS servers. **WEXTS runs both in a single Node.js process** with zero configuration.
35
30
 
36
- ```bash
37
- npx wexts
31
+ **Traditional Approach:**
32
+ ```
33
+ ❌ Two separate servers (Next.js + NestJS)
34
+ ❌ Complex proxy setup
35
+ ❌ CORS configuration nightmare
36
+ ❌ URLs everywhere in your code
37
+ ❌ Two deployments to manage
38
38
  ```
39
39
 
40
- ### Project Dependency
41
-
42
- ```bash
43
- npm install wexts
44
- # or
45
- yarn add wexts
40
+ **WEXTS:**
41
+ ```
42
+ ✅ One unified server
43
+ Smart routing (automatic)
44
+ Zero configuration
45
+ Type-safe SDK (no URLs!)
46
+ ✅ Single deployment
46
47
  ```
47
48
 
48
49
  ---
49
50
 
50
- ## 🏁 Quick Start
51
+ ## 🎯 Key Features
52
+
53
+ - 🔥 **Unified Runtime** - Single Node.js process for frontend + backend
54
+ - 🎨 **Zero URLs** - Call APIs without explicit URLs
55
+ - ⚡ **Type-Safe** - End-to-end TypeScript with auto-complete
56
+ - 🚀 **Production Ready** - Docker, Railway, Render, Vercel support
57
+ - 🔒 **Auth Built-in** - JWT authentication out of the box
58
+ - 📦 **Prisma ORM** - Database integration ready
59
+ - 🐳 **Docker Ready** - Complete Docker setup included
60
+
61
+ ---
51
62
 
52
- ### Create New Project
63
+ ## 🚀 Quick Start
53
64
 
54
65
  ```bash
55
- npx wexts create my-app --template monorepo
66
+ # Create new project
67
+ npx wexts create my-app
68
+
69
+ # Start development
56
70
  cd my-app
57
- pnpm dev
71
+ pnpm install
72
+ pnpm run dev
73
+
74
+ # Open http://localhost:3000
58
75
  ```
59
76
 
60
- This creates:
61
- - `apps/api/` NestJS 11 backend
62
- - `apps/web/` Next.js 16 frontend
63
- - `packages/types/` shared TypeScript definitions
64
- - `packages/api-client/` auto‑generated SDK
77
+ **That's it!** Your unified server is running with:
78
+ - Next.js frontend
79
+ - NestJS backend API
80
+ - Smart routing
81
+ - Hot reload
65
82
 
66
83
  ---
67
84
 
68
- ## 📚 Usage
85
+ ## 💡 The Magic - Zero URLs!
69
86
 
70
- ### NestJS Backend
87
+ ### Without WEXTS
71
88
 
72
89
  ```typescript
73
- import { Controller, Get, Post, Body } from '@nestjs/common';
74
- import { WextsController, WextsGet, WextsPost } from 'wexts/nest';
75
-
76
- @WextsController('users')
77
- @Controller('users')
78
- export class UsersController {
79
- @WextsGet()
80
- async findAll() {
81
- return this.usersService.findAll();
82
- }
83
-
84
- @WextsPost()
85
- async create(@Body() createUserDto: CreateUserDto) {
86
- return this.usersService.create(createUserDto);
87
- }
88
- }
90
+ // Hardcoded URLs everywhere
91
+ const response = await fetch('http://localhost:3001/api/users');
92
+ const users = await response.json();
93
+
94
+ // Problems:
95
+ // - No type safety
96
+ // - CORS issues
97
+ // - Environment management
98
+ // - Proxy configuration
89
99
  ```
90
100
 
91
- **Benefits**: The `WextsController` and `WextsRoute` decorators add metadata for automatic API client generation.
101
+ ### With WEXTS
92
102
 
93
- ---
94
-
95
- ### Next.js Frontend
96
-
97
- #### Setup Provider
98
-
99
- ```tsx
100
- // app/layout.tsx
101
- import { WextsProvider } from 'wexts/next';
103
+ ```typescript
104
+ import { api } from '@/lib/api';
102
105
 
103
- export default function RootLayout({ children }: { children: React.ReactNode }) {
104
- return (
105
- <html lang="en">
106
- <body>
107
- <WextsProvider baseUrl={process.env.NEXT_PUBLIC_API_URL || '/api'}>
108
- {children}
109
- </WextsProvider>
110
- </body>
111
- </html>
112
- );
113
- }
106
+ // Type-safe, zero URLs, works everywhere!
107
+ const users = await api.users.findAll();
108
+ // Auto-complete
109
+ // ✅ Type-safe
110
+ // ✅ No configuration
114
111
  ```
115
112
 
116
- #### Use in Components
117
-
118
- ```tsx
119
- 'use client';
120
- import { useWexts, useAuth } from 'wexts/next';
121
- import { useEffect, useState } from 'react';
122
-
123
- export default function UsersPage() {
124
- const { client } = useWexts();
125
- const { user, isAuthenticated } = useAuth();
126
- const [users, setUsers] = useState([]);
127
-
128
- useEffect(() => {
129
- client.get<User[]>('/users').then(setUsers);
130
- }, []);
131
-
132
- return (
133
- <div>
134
- {isAuthenticated && <p>Welcome, {user.name}!</p>}
135
- <ul>
136
- {users.map(u => (
137
- <li key={u.id}>{u.name}</li>
138
- ))}
139
- </ul>
140
- </div>
141
- );
142
- }
143
- ```
113
+ **The SDK automatically connects to your backend. No URLs needed!**
144
114
 
145
115
  ---
146
116
 
147
- ### HTTP Client
117
+ ## 📖 Project Structure
148
118
 
149
- ```typescript
150
- import { apiFetcher } from 'wexts/client';
119
+ ```
120
+ my-app/
121
+ ├── 🚀 server.ts # Unified server
122
+ ├── apps/
123
+ │ ├── 🔙 api/ # NestJS Backend
124
+ │ │ ├── src/
125
+ │ │ │ ├── auth/ # JWT Authentication
126
+ │ │ │ └── prisma/ # Database ORM
127
+ │ │ └── prisma/schema.prisma
128
+ │ │
129
+ │ └── 🎨 web/ # Next.js Frontend
130
+ │ ├── app/ # App Router
131
+ │ └── lib/
132
+ │ └── api.ts # 🔥 Type-safe SDK
133
+
134
+ ├── 🐳 Dockerfile # Production build
135
+ └── docker-compose.yml # Docker + PostgreSQL
136
+ ```
151
137
 
152
- // GET request
153
- const users = await apiFetcher.get<User[]>('/users');
138
+ ---
154
139
 
155
- // POST request
156
- const newUser = await apiFetcher.post('/users', {
157
- name: 'John',
158
- email: 'john@example.com',
159
- });
140
+ ## 🏗️ How It Works
160
141
 
161
- // Automatic Bearer token from localStorage
162
- // Token stored as 'wexts_token'
142
+ ```
143
+ ┌─────────────────────────────────────────┐
144
+ │ Single Node.js Process │
145
+ │ │
146
+ │ ┌──────────┐ ┌──────────┐ │
147
+ │ │ Next.js │ │ NestJS │ │
148
+ │ │ Frontend │ │ Backend │ │
149
+ │ └──────────┘ └──────────┘ │
150
+ │ │
151
+ │ Smart Router Middleware │
152
+ │ ┌─────────────────────────────┐ │
153
+ │ │ /api/* → NestJS │ │
154
+ │ │ /* → Next.js │ │
155
+ │ └─────────────────────────────┘ │
156
+ └─────────────────────────────────────────┘
163
157
  ```
164
158
 
159
+ **No proxy. No CORS. Just works.** ✨
160
+
165
161
  ---
166
162
 
167
- ## ⚙️ Configuration
163
+ ## 🔐 Built-in Authentication
168
164
 
169
165
  ```typescript
170
- import { config } from 'wexts';
166
+ // Register
167
+ const { user, access_token } = await api.auth.register({
168
+ email: 'user@example.com',
169
+ password: 'secure123',
170
+ name: 'John Doe'
171
+ });
171
172
 
172
- // Load from wexts.config.json or environment variables
173
- const dbUrl = config.load('database');
174
- const apiKey = config.load('apiKey', 'default-key');
173
+ // Login
174
+ const { user, access_token } = await api.auth.login({
175
+ email: 'user@example.com',
176
+ password: 'secure123'
177
+ });
175
178
 
176
- // Set runtime config
177
- config.set('feature_flags', { newUI: true });
179
+ // Get current user
180
+ const user = await api.auth.me();
178
181
  ```
179
182
 
180
- Create `wexts.config.json` in your project root:
181
-
182
- ```json
183
- {
184
- "database": "postgresql://localhost/mydb",
185
- "apiPort": 5050,
186
- "webPort": 3000,
187
- "jwt": {
188
- "secret": "your-secret-key",
189
- "expiresIn": "7d"
190
- }
191
- }
192
- ```
183
+ **Secure JWT authentication with httpOnly cookies included!**
193
184
 
194
- **Environment Variables**: Prefix with `WEXTS_`
185
+ ---
186
+
187
+ ## 🐳 Deploy Anywhere
188
+
189
+ ### Docker (Recommended)
195
190
 
196
191
  ```bash
197
- WEXTS_DATABASE=postgresql://localhost/mydb
198
- WEXTS_JWT__SECRET=your-secret-key
192
+ docker-compose up -d
199
193
  ```
200
194
 
201
- ---
195
+ **Includes PostgreSQL!** Your app is live at `http://localhost:3000`
202
196
 
203
- ## 🛠 CLI Commands
197
+ ### Railway (Easiest)
204
198
 
205
199
  ```bash
206
- # Create new project
207
- wexts create <name> [--template monorepo|api|web]
208
-
209
- # Start development servers
210
- wexts dev [--port <port>]
200
+ # Push to GitHub, connect Railway, done!
201
+ ```
211
202
 
212
- # Build for production
213
- wexts build
203
+ Railway auto-detects WEXTS configuration.
214
204
 
215
- # Generate code
216
- wexts generate controller <name>
205
+ ### Render / VPS
217
206
 
218
- # Shortcut for generate
219
- wexts g module <name>
207
+ ```bash
208
+ pnpm run build
209
+ pnpm start
220
210
  ```
221
211
 
222
- ---
212
+ **One build. One deployment. Works everywhere.**
223
213
 
224
- ## 📖 API Reference
214
+ ---
225
215
 
226
- ### Core Modules
216
+ ## 📚 Full Example
227
217
 
228
218
  ```typescript
229
- import { Core, Config, Insight, Nest, Next } from 'wexts';
230
- ```
231
-
232
- - **Core** process management, filesystem utilities
233
- - **Config** – configuration loader
234
- - **Insight** – logging and metrics
235
- - **Nest** – NestJS decorators and helpers
236
- - **Next** – Next.js providers and hooks
237
-
238
- ### `wexts/client`
219
+ // Backend - apps/api/src/posts/posts.controller.ts
220
+ @Controller('posts')
221
+ @UseGuards(JwtAuthGuard)
222
+ export class PostsController {
223
+ @Get()
224
+ findAll() {
225
+ return this.postsService.findAll();
226
+ }
227
+
228
+ @Post()
229
+ create(@Body() dto: CreatePostDto) {
230
+ return this.postsService.create(dto);
231
+ }
232
+ }
239
233
 
240
- ```typescript
241
- import { WextsFetcher, apiFetcher } from 'wexts/client';
234
+ // Frontend - apps/web/lib/api.ts
235
+ export const api = {
236
+ posts: {
237
+ findAll: () => request<Post[]>('GET', '/posts'),
238
+ create: (data) => request<Post>('POST', '/posts', data),
239
+ },
240
+ };
241
+
242
+ // Usage - apps/web/app/posts/page.tsx
243
+ import { api } from '@/lib/api';
244
+
245
+ export default async function PostsPage() {
246
+ const posts = await api.posts.findAll(); // Type-safe!
247
+
248
+ return (
249
+ <div>
250
+ {posts.map(post => (
251
+ <article key={post.id}>
252
+ <h2>{post.title}</h2>
253
+ <p>{post.content}</p>
254
+ </article>
255
+ ))}
256
+ </div>
257
+ );
258
+ }
242
259
  ```
243
260
 
244
- - **WextsFetcher** HTTP client class
245
- - **apiFetcher** – singleton instance
261
+ **Complete type safety from database to UI!**
246
262
 
247
- ### `wexts/nest`
263
+ ---
248
264
 
249
- ```typescript
250
- import { WextsController, WextsGet, WextsPost, WextsPut, WextsDelete } from 'wexts/nest';
251
- ```
265
+ ## 🛠️ Commands
252
266
 
253
- - NestJS decorators for API codegen (works alongside standard `@nestjs/common` decorators)
267
+ ```bash
268
+ # Development
269
+ pnpm run dev # Start dev server
254
270
 
255
- ### `wexts/next`
271
+ # Production
272
+ pnpm run build # Build everything
273
+ pnpm start # Start production server
256
274
 
257
- ```typescript
258
- import { WextsProvider, useWexts, useAuth } from 'wexts/next';
275
+ # Database
276
+ cd apps/api
277
+ npx prisma migrate dev
278
+ npx prisma studio
259
279
  ```
260
280
 
261
- - **WextsProvider** – React context provider for API client
262
- - **useWexts()** – access API client in components
263
- - **useAuth()** – authentication state management
264
-
265
- ### `wexts/types`
281
+ ---
266
282
 
267
- ```typescript
268
- import type { User, ApiResponse, WextsConfig } from 'wexts/types';
269
- ```
283
+ ## 📦 What's Included
270
284
 
271
- - Shared TypeScript type definitions
285
+ - **Next.js 16** - Latest React framework with App Router
286
+ - **NestJS 11** - Modern Node.js framework
287
+ - **Prisma** - Type-safe database ORM
288
+ - **JWT Auth** - Secure authentication
289
+ - **TypeScript** - Full type safety
290
+ - **Tailwind CSS** - Utility-first CSS
291
+ - **Docker** - Production deployment
292
+ - **Examples** - Auth, CRUD, and more
272
293
 
273
294
  ---
274
295
 
275
- ## 🏗️ Project Structure
296
+ ## 🎯 Perfect For
276
297
 
277
- When you create a project with `wexts create`, you get:
278
-
279
- ```text
280
- my-app/
281
- ├── apps/
282
- │ ├── api/ # NestJS 11 backend
283
- │ │ └── src/
284
- │ └── web/ # Next.js 16 frontend
285
- │ └── app/
286
- ├── packages/
287
- │ ├── types/ # Shared DTOs
288
- │ └── api-client/ # Auto‑generated SDK
289
- ├── turbo.json
290
- ├── package.json
291
- └── wexts.config.json
292
- ```
298
+ Full-stack applications
299
+ ✅ SaaS products
300
+ ✅ Admin dashboards
301
+ ✅ API + Web combo
302
+ Production-ready apps
303
+ Rapid prototyping
293
304
 
294
305
  ---
295
306
 
296
- ## 🚀 Deployment
297
-
298
- ### Build
307
+ ## 📚 Documentation
299
308
 
300
- ```bash
301
- wexts build
302
- ```
303
-
304
- ### Deploy API (NestJS)
309
+ - [Getting Started](https://github.com/ziadmustafa1/wexts/blob/main/docs/getting-started.md)
310
+ - [Architecture](https://github.com/ziadmustafa1/wexts/blob/main/docs/architecture.md)
311
+ - [API Reference](https://github.com/ziadmustafa1/wexts/blob/main/docs/api-reference.md)
312
+ - [Deployment](https://github.com/ziadmustafa1/wexts/blob/main/docs/deployment.md)
313
+ - [Examples](https://github.com/ziadmustafa1/wexts/tree/main/demo)
305
314
 
306
- ```bash
307
- cd apps/api
308
- npm run build
309
- npm run start:prod
310
- ```
315
+ ---
311
316
 
312
- ### Deploy Web (Next.js)
317
+ ## 🤝 Contributing
313
318
 
314
- ```bash
315
- cd apps/web
316
- npm run build
317
- npm start
318
- ```
319
+ Contributions are welcome! See [CONTRIBUTING.md](https://github.com/ziadmustafa1/wexts/blob/main/CONTRIBUTING.md)
319
320
 
320
321
  ---
321
322
 
322
323
  ## 📄 License
323
324
 
324
- MIT © [wexts Team](https://github.com/ziadmustafa1/wexts)
325
+ MIT © WEXTS Team
325
326
 
326
327
  ---
327
328
 
328
- ## 🤝 Contributing
329
+ ## 🙏 Built With
329
330
 
330
- Contributions welcome! Please read our contributing guidelines.
331
+ - [Next.js](https://nextjs.org/) - React framework
332
+ - [NestJS](https://nestjs.com/) - Node.js framework
333
+ - [Prisma](https://www.prisma.io/) - Database ORM
334
+ - [TypeScript](https://www.typescriptlang.org/) - Type safety
331
335
 
332
- ## 📬 Support
336
+ ---
333
337
 
334
- - **GitHub**: [ziadmustafa1/wexts](https://github.com/ziadmustafa1/wexts)
335
- - **Issues**: [Report bugs](https://github.com/ziadmustafa1/wexts/issues)
336
- - **Discussions**: [Community forums](https://github.com/ziadmustafa1/wexts/discussions)
338
+ <div align="center">
337
339
 
338
- ---
340
+ **Stop managing separate servers. Start building with WEXTS.** 🚀
341
+
342
+ [GitHub](https://github.com/ziadmustafa1/wexts) • [npm](https://www.npmjs.com/package/wexts) • [Documentation](https://github.com/ziadmustafa1/wexts#readme)
343
+
344
+ Made with ❤️ for the TypeScript community
339
345
 
340
- **Built with ❤️ by the wexts Team**
346
+ </div>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wexts",
3
- "version": "3.0.0",
4
- "description": "Modern full-stack framework combining NestJS 11 and Next.js 16",
3
+ "version": "3.0.1",
4
+ "description": "Build production-ready full-stack apps with Next.js 16 + NestJS 11 in a unified runtime. Zero URLs. Zero configuration.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
7
7
  "types": "./dist/index.d.ts",
@@ -10,7 +10,9 @@
10
10
  },
11
11
  "files": [
12
12
  "dist",
13
- "templates"
13
+ "templates",
14
+ "README.md",
15
+ "LICENSE"
14
16
  ],
15
17
  "exports": {
16
18
  ".": {
@@ -56,14 +58,25 @@
56
58
  "nextjs",
57
59
  "monorepo",
58
60
  "typescript",
59
- "react"
61
+ "react",
62
+ "unified-runtime",
63
+ "zero-config",
64
+ "type-safe",
65
+ "prisma",
66
+ "jwt-auth",
67
+ "docker",
68
+ "next.js",
69
+ "nest.js"
60
70
  ],
61
- "author": "wexts Team",
71
+ "author": "WEXTS Team",
62
72
  "license": "MIT",
63
73
  "repository": {
64
74
  "type": "git",
65
- "url": "https://github.com/ziadmustafa1/wexts.git",
66
- "directory": "packages/fusionjs"
75
+ "url": "https://github.com/ziadmustafa1/wexts.git"
76
+ },
77
+ "homepage": "https://github.com/ziadmustafa1/wexts#readme",
78
+ "bugs": {
79
+ "url": "https://github.com/ziadmustafa1/wexts/issues"
67
80
  },
68
81
  "engines": {
69
82
  "node": ">=20.9.0",
@@ -0,0 +1,43 @@
1
+ # Environment files
2
+ .env
3
+ .env.local
4
+ .env.*.local
5
+
6
+ # Node modules
7
+ node_modules
8
+ dist
9
+ build
10
+ .next
11
+ .turbo
12
+
13
+ # Database
14
+ *.db
15
+ *.db-journal
16
+
17
+ # Logs
18
+ *.log
19
+ npm-debug.log*
20
+
21
+ # OS
22
+ .DS_Store
23
+ Thumbs.db
24
+
25
+ # IDE
26
+ .vscode
27
+ .idea
28
+ *.swp
29
+
30
+ # Git
31
+ .git
32
+ .gitignore
33
+
34
+ # CI/CD
35
+ .github
36
+
37
+ # Documentation
38
+ *.md
39
+ !README.md
40
+
41
+ # Config files
42
+ .prettierrc
43
+ .eslintrc*