wexts 4.1.5 → 4.1.7
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 +49 -49
- package/bin/wexts.cjs +2 -2
- package/dist/chunk-27NEYQD2.mjs +222 -0
- package/dist/chunk-27NEYQD2.mjs.map +1 -0
- package/dist/chunk-2LJVUMXW.js +228 -0
- package/dist/chunk-2LJVUMXW.js.map +1 -0
- package/dist/chunk-5DBFN65W.mjs +183 -0
- package/dist/chunk-5DBFN65W.mjs.map +1 -0
- package/dist/chunk-75HBI2XG.js +504 -0
- package/dist/chunk-75HBI2XG.js.map +1 -0
- package/dist/chunk-AVMQJWYD.js +95 -0
- package/dist/chunk-AVMQJWYD.js.map +1 -0
- package/dist/chunk-C2AG7Q3C.mjs +65 -0
- package/dist/chunk-C2AG7Q3C.mjs.map +1 -0
- package/dist/chunk-DS5KVVWJ.mjs +95 -0
- package/dist/chunk-DS5KVVWJ.mjs.map +1 -0
- package/dist/chunk-FUPLZMSR.mjs +228 -0
- package/dist/chunk-FUPLZMSR.mjs.map +1 -0
- package/dist/chunk-HLT3IHJY.js +183 -0
- package/dist/chunk-HLT3IHJY.js.map +1 -0
- package/dist/chunk-IRRJJ7KL.js +273 -0
- package/dist/chunk-IRRJJ7KL.js.map +1 -0
- package/dist/chunk-L77ANWWT.mjs +22 -0
- package/dist/chunk-L77ANWWT.mjs.map +1 -0
- package/dist/chunk-P3Q4I5FD.js +222 -0
- package/dist/chunk-P3Q4I5FD.js.map +1 -0
- package/dist/chunk-VBIQGUDI.mjs +504 -0
- package/dist/chunk-VBIQGUDI.mjs.map +1 -0
- package/dist/chunk-VJY6PHYF.mjs +273 -0
- package/dist/chunk-VJY6PHYF.mjs.map +1 -0
- package/dist/chunk-WCKSKU3C.js +65 -0
- package/dist/chunk-WCKSKU3C.js.map +1 -0
- package/dist/chunk-XE4OXN2W.js +12 -0
- package/dist/chunk-XE4OXN2W.js.map +1 -0
- package/dist/cli/index.d.mts +23 -0
- package/dist/cli/index.d.ts +23 -0
- package/dist/cli/index.js +634 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/index.mjs +636 -0
- package/dist/cli/index.mjs.map +1 -0
- package/dist/client/index.d.mts +43 -0
- package/dist/client/index.d.ts +43 -0
- package/dist/client/index.js +187 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/index.mjs +166 -0
- package/dist/client/index.mjs.map +1 -0
- package/dist/codegen/index.d.mts +2 -0
- package/dist/codegen/index.d.ts +2 -0
- package/dist/codegen/index.js +16 -0
- package/dist/codegen/index.js.map +1 -0
- package/dist/codegen/index.mjs +16 -0
- package/dist/codegen/index.mjs.map +1 -0
- package/dist/decorators-BiQtOHuF.d.ts +60 -0
- package/dist/decorators-vBopODtr.d.mts +60 -0
- package/dist/dev-server/index.d.mts +1 -0
- package/dist/dev-server/index.d.ts +1 -0
- package/dist/dev-server/index.js +13 -0
- package/dist/dev-server/index.js.map +1 -0
- package/dist/dev-server/index.mjs +13 -0
- package/dist/dev-server/index.mjs.map +1 -0
- package/dist/errors-D545UvXf.d.mts +37 -0
- package/dist/errors-D545UvXf.d.ts +37 -0
- package/dist/index-7RvU-jGE.d.mts +66 -0
- package/dist/index-7RvU-jGE.d.ts +66 -0
- package/dist/index-BsafLP-a.d.mts +70 -0
- package/dist/index-BsafLP-a.d.ts +70 -0
- package/dist/index-CJKs4wtN.d.ts +92 -0
- package/dist/index-CUR6CnLk.d.ts +27 -0
- package/dist/index-h66Vq9dK.d.mts +92 -0
- package/dist/index-tqmYsTUn.d.mts +27 -0
- package/dist/index.d.mts +289 -0
- package/dist/index.d.ts +289 -0
- package/dist/index.js +544 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +544 -0
- package/dist/index.mjs.map +1 -0
- package/dist/nest/index.d.mts +2 -0
- package/dist/nest/index.d.ts +2 -0
- package/dist/nest/index.js +36 -0
- package/dist/nest/index.js.map +1 -0
- package/dist/nest/index.mjs +36 -0
- package/dist/nest/index.mjs.map +1 -0
- package/dist/next/index.d.mts +66 -0
- package/dist/next/index.d.ts +66 -0
- package/dist/next/index.js +282 -0
- package/dist/next/index.js.map +1 -0
- package/dist/next/index.mjs +251 -0
- package/dist/next/index.mjs.map +1 -0
- package/dist/rpc/index.d.mts +32 -0
- package/dist/rpc/index.d.ts +32 -0
- package/dist/rpc/index.js +19 -0
- package/dist/rpc/index.js.map +1 -0
- package/dist/rpc/index.mjs +1 -0
- package/dist/rpc/index.mjs.map +1 -0
- package/dist/runtime/index.d.mts +55 -0
- package/dist/runtime/index.d.ts +55 -0
- package/dist/runtime/index.js +15 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/index.mjs +15 -0
- package/dist/runtime/index.mjs.map +1 -0
- package/dist/server/index.d.mts +7 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.js +58 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/index.mjs +58 -0
- package/dist/server/index.mjs.map +1 -0
- package/dist/types/index.d.mts +12 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/types-CQ_aexOX.d.mts +32 -0
- package/dist/types-CQ_aexOX.d.ts +32 -0
- package/dist/vercel-builder/index.d.mts +58 -0
- package/dist/vercel-builder/index.d.ts +58 -0
- package/dist/vercel-builder/index.js +330 -0
- package/dist/vercel-builder/index.js.map +1 -0
- package/dist/vercel-builder/index.mjs +330 -0
- package/dist/vercel-builder/index.mjs.map +1 -0
- package/package.json +153 -153
- package/templates/.dockerignore +43 -43
- package/templates/.env.example +17 -17
- package/templates/Dockerfile +60 -60
- package/templates/Procfile +1 -1
- package/templates/README.md +67 -67
- package/templates/api-sdk.ts +115 -115
- package/templates/docker-compose.yml +34 -34
- package/templates/nestjs-api/.env.example +3 -3
- package/templates/nestjs-api/README.md +87 -87
- package/templates/nestjs-api/nest-cli.json +6 -6
- package/templates/nestjs-api/package.json +40 -40
- package/templates/nestjs-api/prisma/migrations/20251123205437_init/migration.sql +24 -24
- package/templates/nestjs-api/prisma/migrations/migration_lock.toml +3 -3
- package/templates/nestjs-api/prisma/schema.prisma +29 -29
- package/templates/nestjs-api/src/app.module.ts +19 -17
- package/templates/nestjs-api/src/auth/auth.controller.ts +27 -27
- package/templates/nestjs-api/src/auth/auth.module.ts +37 -37
- package/templates/nestjs-api/src/auth/auth.service.ts +86 -86
- package/templates/nestjs-api/src/auth/dto/auth.dto.ts +22 -22
- package/templates/nestjs-api/src/auth/guards/jwt-auth.guard.ts +5 -5
- package/templates/nestjs-api/src/auth/strategies/jwt.strategy.ts +27 -27
- package/templates/nestjs-api/src/hello.service.ts +11 -0
- package/templates/nestjs-api/src/main.ts +32 -32
- package/templates/nestjs-api/src/prisma/prisma.module.ts +9 -9
- package/templates/nestjs-api/src/prisma/prisma.service.ts +14 -14
- package/templates/nestjs-api/src/todos/dto/todo.dto.ts +24 -24
- package/templates/nestjs-api/src/todos/todos.controller.ts +39 -39
- package/templates/nestjs-api/src/todos/todos.module.ts +11 -11
- package/templates/nestjs-api/src/todos/todos.service.ts +53 -53
- package/templates/nestjs-api/src/users/users.controller.ts +14 -14
- package/templates/nestjs-api/src/users/users.module.ts +12 -12
- package/templates/nestjs-api/src/users/users.service.ts +19 -19
- package/templates/nestjs-api/tsconfig.json +39 -39
- package/templates/nextjs-web/README.md +76 -76
- package/templates/nextjs-web/app/actions/auth.ts +108 -108
- package/templates/nextjs-web/app/dashboard/error.tsx +39 -39
- package/templates/nextjs-web/app/dashboard/loading.tsx +14 -14
- package/templates/nextjs-web/app/dashboard/page.tsx +5 -5
- package/templates/nextjs-web/app/globals.css +93 -93
- package/templates/nextjs-web/app/layout.tsx +29 -29
- package/templates/nextjs-web/app/login/page.tsx +5 -5
- package/templates/nextjs-web/app/page.tsx +138 -28
- package/templates/nextjs-web/app/register/page.tsx +5 -5
- package/templates/nextjs-web/components/ui/button.tsx +56 -56
- package/templates/nextjs-web/components/ui/card.tsx +79 -79
- package/templates/nextjs-web/components/ui/input.tsx +25 -25
- package/templates/nextjs-web/components/ui/label.tsx +24 -24
- package/templates/nextjs-web/features/auth/LoginForm.tsx +140 -140
- package/templates/nextjs-web/features/auth/RegisterForm.tsx +159 -159
- package/templates/nextjs-web/features/auth/api.ts +35 -35
- package/templates/nextjs-web/features/auth/index.ts +3 -3
- package/templates/nextjs-web/features/dashboard/DashboardView.tsx +204 -204
- package/templates/nextjs-web/features/dashboard/api.ts +9 -9
- package/templates/nextjs-web/features/dashboard/components.tsx +74 -74
- package/templates/nextjs-web/features/dashboard/index.ts +3 -3
- package/templates/nextjs-web/hooks/index.ts +4 -4
- package/templates/nextjs-web/lib/api-client.ts +89 -89
- package/templates/nextjs-web/lib/api.ts +115 -115
- package/templates/nextjs-web/lib/axios-global-config.ts +17 -17
- package/templates/nextjs-web/lib/utils.ts +6 -6
- package/templates/nextjs-web/lib/wexts-client.ts +4 -4
- package/templates/nextjs-web/next-env.d.ts +6 -6
- package/templates/nextjs-web/next.config.ts +20 -20
- package/templates/nextjs-web/package.json +37 -37
- package/templates/nextjs-web/postcss.config.js +6 -6
- package/templates/nextjs-web/tailwind.config.ts +69 -69
- package/templates/nextjs-web/tsconfig.json +41 -41
- package/templates/nixpacks.toml +11 -11
- package/templates/root-package.json +31 -31
- package/templates/server.ts +66 -66
- package/templates/tsconfig.json +30 -30
package/templates/README.md
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
# Deprecated Legacy Templates
|
|
2
|
-
|
|
3
|
-
These templates predate the verified `examples/hello-rpc` runtime/RPC/security model. They are retained for compatibility while the scaffold is consolidated.
|
|
4
|
-
|
|
5
|
-
For release validation and production guidance, use `examples/hello-rpc`. Do not treat these legacy templates as the recommended production app structure.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# WEXTS Legacy Templates
|
|
10
|
-
|
|
11
|
-
This directory contains all the templates needed to create a WEXTS unified server application.
|
|
12
|
-
|
|
13
|
-
## 📁 Files Included
|
|
14
|
-
|
|
15
|
-
### Core Templates
|
|
16
|
-
- `server.ts` - Unified server that runs Next.js + NestJS in one process
|
|
17
|
-
- `api-sdk.ts` - legacy SDK scaffold retained for compatibility
|
|
18
|
-
- `root-package.json` - Root package.json with all scripts
|
|
19
|
-
- `tsconfig.json` - TypeScript configuration
|
|
20
|
-
- `.env.example` - Environment variables template
|
|
21
|
-
|
|
22
|
-
### Deployment Templates
|
|
23
|
-
- `Dockerfile` - Docker multi-stage build
|
|
24
|
-
- `docker-compose.yml` - Docker Compose with PostgreSQL
|
|
25
|
-
- `.dockerignore` - Docker ignore file
|
|
26
|
-
- `nixpacks.toml` - Railway deployment config
|
|
27
|
-
- `Procfile` - Render/Heroku deployment
|
|
28
|
-
|
|
29
|
-
### App Templates
|
|
30
|
-
- `nestjs-api/` - NestJS backend template
|
|
31
|
-
- `nextjs-web/` - Next.js frontend template
|
|
32
|
-
|
|
33
|
-
## 🚀 Usage
|
|
34
|
-
|
|
35
|
-
These templates are legacy scaffold assets. The canonical verified example is:
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
pnpm --filter wexts-example-hello-rpc generate
|
|
39
|
-
pnpm --filter wexts-example-hello-rpc build
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## ✨ Features
|
|
43
|
-
|
|
44
|
-
✅ **Unified Server** - Single Node.js process for frontend + backend
|
|
45
|
-
✅ **Generated RPC** - In the canonical `examples/hello-rpc` path
|
|
46
|
-
✅ **Smart Routing** - In the production Fastify runtime
|
|
47
|
-
✅ **Docker Ready** - Complete Docker setup included
|
|
48
|
-
✅ **Multi-Platform Deploy** - Railway, Render, Docker, VPS
|
|
49
|
-
|
|
50
|
-
## 📦 Template Structure
|
|
51
|
-
|
|
52
|
-
```
|
|
53
|
-
project/
|
|
54
|
-
├── server.ts ← Unified server
|
|
55
|
-
├── package.json ← Root package
|
|
56
|
-
├── tsconfig.json ← TS config
|
|
57
|
-
├── .env.example ← Env template
|
|
58
|
-
├── Dockerfile ← Docker build
|
|
59
|
-
├── docker-compose.yml ← Docker + DB
|
|
60
|
-
├── apps/
|
|
61
|
-
│ ├── api/ ← From nestjs-api template
|
|
62
|
-
│ └── web/ ← From nextjs-web template
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## 🔧 Customization
|
|
66
|
-
|
|
67
|
-
Templates can be customized before project creation. See CLI documentation for details.
|
|
1
|
+
# Deprecated Legacy Templates
|
|
2
|
+
|
|
3
|
+
These templates predate the verified `examples/hello-rpc` runtime/RPC/security model. They are retained for compatibility while the scaffold is consolidated.
|
|
4
|
+
|
|
5
|
+
For release validation and production guidance, use `examples/hello-rpc`. Do not treat these legacy templates as the recommended production app structure.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# WEXTS Legacy Templates
|
|
10
|
+
|
|
11
|
+
This directory contains all the templates needed to create a WEXTS unified server application.
|
|
12
|
+
|
|
13
|
+
## 📁 Files Included
|
|
14
|
+
|
|
15
|
+
### Core Templates
|
|
16
|
+
- `server.ts` - Unified server that runs Next.js + NestJS in one process
|
|
17
|
+
- `api-sdk.ts` - legacy SDK scaffold retained for compatibility
|
|
18
|
+
- `root-package.json` - Root package.json with all scripts
|
|
19
|
+
- `tsconfig.json` - TypeScript configuration
|
|
20
|
+
- `.env.example` - Environment variables template
|
|
21
|
+
|
|
22
|
+
### Deployment Templates
|
|
23
|
+
- `Dockerfile` - Docker multi-stage build
|
|
24
|
+
- `docker-compose.yml` - Docker Compose with PostgreSQL
|
|
25
|
+
- `.dockerignore` - Docker ignore file
|
|
26
|
+
- `nixpacks.toml` - Railway deployment config
|
|
27
|
+
- `Procfile` - Render/Heroku deployment
|
|
28
|
+
|
|
29
|
+
### App Templates
|
|
30
|
+
- `nestjs-api/` - NestJS backend template
|
|
31
|
+
- `nextjs-web/` - Next.js frontend template
|
|
32
|
+
|
|
33
|
+
## 🚀 Usage
|
|
34
|
+
|
|
35
|
+
These templates are legacy scaffold assets. The canonical verified example is:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pnpm --filter wexts-example-hello-rpc generate
|
|
39
|
+
pnpm --filter wexts-example-hello-rpc build
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## ✨ Features
|
|
43
|
+
|
|
44
|
+
✅ **Unified Server** - Single Node.js process for frontend + backend
|
|
45
|
+
✅ **Generated RPC** - In the canonical `examples/hello-rpc` path
|
|
46
|
+
✅ **Smart Routing** - In the production Fastify runtime
|
|
47
|
+
✅ **Docker Ready** - Complete Docker setup included
|
|
48
|
+
✅ **Multi-Platform Deploy** - Railway, Render, Docker, VPS
|
|
49
|
+
|
|
50
|
+
## 📦 Template Structure
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
project/
|
|
54
|
+
├── server.ts ← Unified server
|
|
55
|
+
├── package.json ← Root package
|
|
56
|
+
├── tsconfig.json ← TS config
|
|
57
|
+
├── .env.example ← Env template
|
|
58
|
+
├── Dockerfile ← Docker build
|
|
59
|
+
├── docker-compose.yml ← Docker + DB
|
|
60
|
+
├── apps/
|
|
61
|
+
│ ├── api/ ← From nestjs-api template
|
|
62
|
+
│ └── web/ ← From nextjs-web template
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 🔧 Customization
|
|
66
|
+
|
|
67
|
+
Templates can be customized before project creation. See CLI documentation for details.
|
package/templates/api-sdk.ts
CHANGED
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WEXTS Internal SDK
|
|
3
|
-
* Type-safe API client - ZERO URLs needed!
|
|
4
|
-
* Works in both Client and Server Components
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// HTTP client - uses relative paths only
|
|
8
|
-
async function request<T>(method: string, path: string, data?: any): Promise<T> {
|
|
9
|
-
const url = `/api${path}`;
|
|
10
|
-
|
|
11
|
-
const options: RequestInit = {
|
|
12
|
-
method,
|
|
13
|
-
headers: {
|
|
14
|
-
'Content-Type': 'application/json',
|
|
15
|
-
},
|
|
16
|
-
credentials: 'include',
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
if (data) {
|
|
20
|
-
options.body = JSON.stringify(data);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const response = await fetch(url, options);
|
|
24
|
-
|
|
25
|
-
if (!response.ok) {
|
|
26
|
-
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
27
|
-
throw new Error(error.message || 'Request failed');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return response.json();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// ==========================================
|
|
34
|
-
// TYPE-SAFE API - NO URLs ANYWHERE!
|
|
35
|
-
// ==========================================
|
|
36
|
-
|
|
37
|
-
export const api = {
|
|
38
|
-
/**
|
|
39
|
-
* Authentication API
|
|
40
|
-
*/
|
|
41
|
-
auth: {
|
|
42
|
-
/**
|
|
43
|
-
* Register new user
|
|
44
|
-
* @example await api.auth.register({ email, password, name })
|
|
45
|
-
*/
|
|
46
|
-
register: (data: { email: string; password: string; name?: string }) =>
|
|
47
|
-
request<{ user: any; access_token: string }>('POST', '/auth/register', data),
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Login user
|
|
51
|
-
* @example await api.auth.login({ email, password })
|
|
52
|
-
*/
|
|
53
|
-
login: (data: { email: string; password: string }) =>
|
|
54
|
-
request<{ user: any; access_token: string }>('POST', '/auth/login', data),
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Get current user
|
|
58
|
-
* @example const user = await api.auth.me()
|
|
59
|
-
*/
|
|
60
|
-
me: () => request<any>('GET', '/auth/me'),
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Users API
|
|
65
|
-
*/
|
|
66
|
-
users: {
|
|
67
|
-
/**
|
|
68
|
-
* Get current user profile
|
|
69
|
-
* @example const profile = await api.users.me()
|
|
70
|
-
*/
|
|
71
|
-
me: () => request<any>('GET', '/users/me'),
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Todos API
|
|
76
|
-
*/
|
|
77
|
-
todos: {
|
|
78
|
-
/**
|
|
79
|
-
* Get all todos
|
|
80
|
-
* @example const todos = await api.todos.findAll()
|
|
81
|
-
*/
|
|
82
|
-
findAll: () => request<any[]>('GET', '/todos'),
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Get single todo
|
|
86
|
-
* @example const todo = await api.todos.findOne('123')
|
|
87
|
-
*/
|
|
88
|
-
findOne: (id: string) => request<any>('GET', `/todos/${id}`),
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Create new todo
|
|
92
|
-
* @example await api.todos.create({ title: 'Task', description: 'Do it' })
|
|
93
|
-
*/
|
|
94
|
-
create: (data: { title: string; description?: string }) =>
|
|
95
|
-
request<any>('POST', '/todos', data),
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Update todo
|
|
99
|
-
* @example await api.todos.update('123', { completed: true })
|
|
100
|
-
*/
|
|
101
|
-
update: (id: string, data: { title?: string; description?: string; completed?: boolean }) =>
|
|
102
|
-
request<any>('PUT', `/todos/${id}`, data),
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Delete todo
|
|
106
|
-
* @example await api.todos.delete('123')
|
|
107
|
-
*/
|
|
108
|
-
delete: (id: string) => request<void>('DELETE', `/todos/${id}`),
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Export type-safe API
|
|
114
|
-
*/
|
|
115
|
-
export type API = typeof api;
|
|
1
|
+
/**
|
|
2
|
+
* WEXTS Internal SDK
|
|
3
|
+
* Type-safe API client - ZERO URLs needed!
|
|
4
|
+
* Works in both Client and Server Components
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// HTTP client - uses relative paths only
|
|
8
|
+
async function request<T>(method: string, path: string, data?: any): Promise<T> {
|
|
9
|
+
const url = `/api${path}`;
|
|
10
|
+
|
|
11
|
+
const options: RequestInit = {
|
|
12
|
+
method,
|
|
13
|
+
headers: {
|
|
14
|
+
'Content-Type': 'application/json',
|
|
15
|
+
},
|
|
16
|
+
credentials: 'include',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
if (data) {
|
|
20
|
+
options.body = JSON.stringify(data);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const response = await fetch(url, options);
|
|
24
|
+
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
27
|
+
throw new Error(error.message || 'Request failed');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return response.json();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// ==========================================
|
|
34
|
+
// TYPE-SAFE API - NO URLs ANYWHERE!
|
|
35
|
+
// ==========================================
|
|
36
|
+
|
|
37
|
+
export const api = {
|
|
38
|
+
/**
|
|
39
|
+
* Authentication API
|
|
40
|
+
*/
|
|
41
|
+
auth: {
|
|
42
|
+
/**
|
|
43
|
+
* Register new user
|
|
44
|
+
* @example await api.auth.register({ email, password, name })
|
|
45
|
+
*/
|
|
46
|
+
register: (data: { email: string; password: string; name?: string }) =>
|
|
47
|
+
request<{ user: any; access_token: string }>('POST', '/auth/register', data),
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Login user
|
|
51
|
+
* @example await api.auth.login({ email, password })
|
|
52
|
+
*/
|
|
53
|
+
login: (data: { email: string; password: string }) =>
|
|
54
|
+
request<{ user: any; access_token: string }>('POST', '/auth/login', data),
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Get current user
|
|
58
|
+
* @example const user = await api.auth.me()
|
|
59
|
+
*/
|
|
60
|
+
me: () => request<any>('GET', '/auth/me'),
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Users API
|
|
65
|
+
*/
|
|
66
|
+
users: {
|
|
67
|
+
/**
|
|
68
|
+
* Get current user profile
|
|
69
|
+
* @example const profile = await api.users.me()
|
|
70
|
+
*/
|
|
71
|
+
me: () => request<any>('GET', '/users/me'),
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Todos API
|
|
76
|
+
*/
|
|
77
|
+
todos: {
|
|
78
|
+
/**
|
|
79
|
+
* Get all todos
|
|
80
|
+
* @example const todos = await api.todos.findAll()
|
|
81
|
+
*/
|
|
82
|
+
findAll: () => request<any[]>('GET', '/todos'),
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Get single todo
|
|
86
|
+
* @example const todo = await api.todos.findOne('123')
|
|
87
|
+
*/
|
|
88
|
+
findOne: (id: string) => request<any>('GET', `/todos/${id}`),
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Create new todo
|
|
92
|
+
* @example await api.todos.create({ title: 'Task', description: 'Do it' })
|
|
93
|
+
*/
|
|
94
|
+
create: (data: { title: string; description?: string }) =>
|
|
95
|
+
request<any>('POST', '/todos', data),
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Update todo
|
|
99
|
+
* @example await api.todos.update('123', { completed: true })
|
|
100
|
+
*/
|
|
101
|
+
update: (id: string, data: { title?: string; description?: string; completed?: boolean }) =>
|
|
102
|
+
request<any>('PUT', `/todos/${id}`, data),
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Delete todo
|
|
106
|
+
* @example await api.todos.delete('123')
|
|
107
|
+
*/
|
|
108
|
+
delete: (id: string) => request<void>('DELETE', `/todos/${id}`),
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Export type-safe API
|
|
114
|
+
*/
|
|
115
|
+
export type API = typeof api;
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
version: '3.8'
|
|
2
|
-
|
|
3
|
-
services:
|
|
4
|
-
# WEXTS Application
|
|
5
|
-
app:
|
|
6
|
-
build:
|
|
7
|
-
context: .
|
|
8
|
-
dockerfile: Dockerfile
|
|
9
|
-
ports:
|
|
10
|
-
- "3000:3000"
|
|
11
|
-
environment:
|
|
12
|
-
- NODE_ENV=production
|
|
13
|
-
- DATABASE_URL=postgresql://wexts:wexts_password@postgres:5432/wexts_db
|
|
14
|
-
- JWT_SECRET=your-super-secret-jwt-key-change-this
|
|
15
|
-
- PORT=3000
|
|
16
|
-
depends_on:
|
|
17
|
-
- postgres
|
|
18
|
-
restart: unless-stopped
|
|
19
|
-
|
|
20
|
-
# PostgreSQL Database
|
|
21
|
-
postgres:
|
|
22
|
-
image: postgres:16-alpine
|
|
23
|
-
ports:
|
|
24
|
-
- "5432:5432"
|
|
25
|
-
environment:
|
|
26
|
-
- POSTGRES_USER=wexts
|
|
27
|
-
- POSTGRES_PASSWORD=wexts_password
|
|
28
|
-
- POSTGRES_DB=wexts_db
|
|
29
|
-
volumes:
|
|
30
|
-
- postgres_data:/var/lib/postgresql/data
|
|
31
|
-
restart: unless-stopped
|
|
32
|
-
|
|
33
|
-
volumes:
|
|
34
|
-
postgres_data:
|
|
1
|
+
version: '3.8'
|
|
2
|
+
|
|
3
|
+
services:
|
|
4
|
+
# WEXTS Application
|
|
5
|
+
app:
|
|
6
|
+
build:
|
|
7
|
+
context: .
|
|
8
|
+
dockerfile: Dockerfile
|
|
9
|
+
ports:
|
|
10
|
+
- "3000:3000"
|
|
11
|
+
environment:
|
|
12
|
+
- NODE_ENV=production
|
|
13
|
+
- DATABASE_URL=postgresql://wexts:wexts_password@postgres:5432/wexts_db
|
|
14
|
+
- JWT_SECRET=your-super-secret-jwt-key-change-this
|
|
15
|
+
- PORT=3000
|
|
16
|
+
depends_on:
|
|
17
|
+
- postgres
|
|
18
|
+
restart: unless-stopped
|
|
19
|
+
|
|
20
|
+
# PostgreSQL Database
|
|
21
|
+
postgres:
|
|
22
|
+
image: postgres:16-alpine
|
|
23
|
+
ports:
|
|
24
|
+
- "5432:5432"
|
|
25
|
+
environment:
|
|
26
|
+
- POSTGRES_USER=wexts
|
|
27
|
+
- POSTGRES_PASSWORD=wexts_password
|
|
28
|
+
- POSTGRES_DB=wexts_db
|
|
29
|
+
volumes:
|
|
30
|
+
- postgres_data:/var/lib/postgresql/data
|
|
31
|
+
restart: unless-stopped
|
|
32
|
+
|
|
33
|
+
volumes:
|
|
34
|
+
postgres_data:
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
DATABASE_URL="file:./dev.db"
|
|
2
|
-
JWT_SECRET="super-secret-secret"
|
|
3
|
-
PORT=5050
|
|
1
|
+
DATABASE_URL="file:./dev.db"
|
|
2
|
+
JWT_SECRET="super-secret-secret"
|
|
3
|
+
PORT=5050
|
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
# Deprecated Legacy API Template
|
|
2
|
-
|
|
3
|
-
This template predates the verified `examples/hello-rpc` runtime/RPC/security model. It is retained for compatibility and should not be used as the production reference.
|
|
4
|
-
|
|
5
|
-
Use `examples/hello-rpc` for the canonical generated-RPC path.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# Fusion NestJS API
|
|
10
|
-
|
|
11
|
-
Deprecated compatibility backend template. The verified Wexts 4 starter uses NestJS 11, generated RPC, and no required Prisma/Auth/Todos stack.
|
|
12
|
-
|
|
13
|
-
## Features
|
|
14
|
-
|
|
15
|
-
- ✅ JWT Authentication
|
|
16
|
-
- ✅ Prisma ORM (SQLite for development)
|
|
17
|
-
- ✅ User Management
|
|
18
|
-
- ✅ Todo CRUD Operations
|
|
19
|
-
- ⚠️ Legacy Fusion decorator notes; canonical RPC uses `@RpcService()` and `@RpcMethod()`
|
|
20
|
-
- ✅ Fastify Adapter
|
|
21
|
-
- ✅ Input Validation
|
|
22
|
-
|
|
23
|
-
## Setup
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
# Install dependencies
|
|
27
|
-
npm install
|
|
28
|
-
|
|
29
|
-
# Copy environment variables
|
|
30
|
-
cp .env.example .env
|
|
31
|
-
|
|
32
|
-
# Generate Prisma client
|
|
33
|
-
npm run prisma:generate
|
|
34
|
-
|
|
35
|
-
# Run migrations
|
|
36
|
-
npm run prisma:migrate
|
|
37
|
-
|
|
38
|
-
# Start development server
|
|
39
|
-
npm run start:dev
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## API Endpoints
|
|
43
|
-
|
|
44
|
-
### Authentication
|
|
45
|
-
- `POST /auth/register` - Register new user
|
|
46
|
-
- `POST /auth/login` - Login
|
|
47
|
-
- `GET /auth/me` - Get current user (protected)
|
|
48
|
-
|
|
49
|
-
### Todos
|
|
50
|
-
- `GET /todos` - Get all todos (protected)
|
|
51
|
-
- `GET /todos/:id` - Get single todo (protected)
|
|
52
|
-
- `POST /todos` - Create todo (protected)
|
|
53
|
-
- `PUT /todos/:id` - Update todo (protected)
|
|
54
|
-
- `DELETE /todos/:id` - Delete todo (protected)
|
|
55
|
-
|
|
56
|
-
### Users
|
|
57
|
-
- `GET /users/me` - Get current user profile (protected)
|
|
58
|
-
|
|
59
|
-
## Environment Variables
|
|
60
|
-
|
|
61
|
-
```env
|
|
62
|
-
DATABASE_URL="file:./dev.db"
|
|
63
|
-
JWT_SECRET="your-secret-key"
|
|
64
|
-
JWT_EXPIRES_IN="7d"
|
|
65
|
-
PORT=5050
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Database
|
|
69
|
-
|
|
70
|
-
Using Prisma with SQLite for development. To create a new migration:
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
npm run prisma:migrate
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
To view database in Prisma Studio:
|
|
77
|
-
|
|
78
|
-
```bash
|
|
79
|
-
npm run prisma:studio
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
## Building for Production
|
|
83
|
-
|
|
84
|
-
```bash
|
|
85
|
-
npm run build
|
|
86
|
-
npm run start:prod
|
|
87
|
-
```
|
|
1
|
+
# Deprecated Legacy API Template
|
|
2
|
+
|
|
3
|
+
This template predates the verified `examples/hello-rpc` runtime/RPC/security model. It is retained for compatibility and should not be used as the production reference.
|
|
4
|
+
|
|
5
|
+
Use `examples/hello-rpc` for the canonical generated-RPC path.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Fusion NestJS API
|
|
10
|
+
|
|
11
|
+
Deprecated compatibility backend template. The verified Wexts 4 starter uses NestJS 11, generated RPC, and no required Prisma/Auth/Todos stack.
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- ✅ JWT Authentication
|
|
16
|
+
- ✅ Prisma ORM (SQLite for development)
|
|
17
|
+
- ✅ User Management
|
|
18
|
+
- ✅ Todo CRUD Operations
|
|
19
|
+
- ⚠️ Legacy Fusion decorator notes; canonical RPC uses `@RpcService()` and `@RpcMethod()`
|
|
20
|
+
- ✅ Fastify Adapter
|
|
21
|
+
- ✅ Input Validation
|
|
22
|
+
|
|
23
|
+
## Setup
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Install dependencies
|
|
27
|
+
npm install
|
|
28
|
+
|
|
29
|
+
# Copy environment variables
|
|
30
|
+
cp .env.example .env
|
|
31
|
+
|
|
32
|
+
# Generate Prisma client
|
|
33
|
+
npm run prisma:generate
|
|
34
|
+
|
|
35
|
+
# Run migrations
|
|
36
|
+
npm run prisma:migrate
|
|
37
|
+
|
|
38
|
+
# Start development server
|
|
39
|
+
npm run start:dev
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## API Endpoints
|
|
43
|
+
|
|
44
|
+
### Authentication
|
|
45
|
+
- `POST /auth/register` - Register new user
|
|
46
|
+
- `POST /auth/login` - Login
|
|
47
|
+
- `GET /auth/me` - Get current user (protected)
|
|
48
|
+
|
|
49
|
+
### Todos
|
|
50
|
+
- `GET /todos` - Get all todos (protected)
|
|
51
|
+
- `GET /todos/:id` - Get single todo (protected)
|
|
52
|
+
- `POST /todos` - Create todo (protected)
|
|
53
|
+
- `PUT /todos/:id` - Update todo (protected)
|
|
54
|
+
- `DELETE /todos/:id` - Delete todo (protected)
|
|
55
|
+
|
|
56
|
+
### Users
|
|
57
|
+
- `GET /users/me` - Get current user profile (protected)
|
|
58
|
+
|
|
59
|
+
## Environment Variables
|
|
60
|
+
|
|
61
|
+
```env
|
|
62
|
+
DATABASE_URL="file:./dev.db"
|
|
63
|
+
JWT_SECRET="your-secret-key"
|
|
64
|
+
JWT_EXPIRES_IN="7d"
|
|
65
|
+
PORT=5050
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Database
|
|
69
|
+
|
|
70
|
+
Using Prisma with SQLite for development. To create a new migration:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
npm run prisma:migrate
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
To view database in Prisma Studio:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
npm run prisma:studio
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Building for Production
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npm run build
|
|
86
|
+
npm run start:prod
|
|
87
|
+
```
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
{
|
|
2
|
-
"collection": "@nestjs/schematics",
|
|
3
|
-
"sourceRoot": "src",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"deleteOutDir": true
|
|
6
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"collection": "@nestjs/schematics",
|
|
3
|
+
"sourceRoot": "src",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"deleteOutDir": true
|
|
6
|
+
}
|
|
7
7
|
}
|