@windrun-huaiin/backend-core 30.0.0 → 31.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 +95 -0
- package/dist/app/api/user/anonymous/init/fingerprint-only-route.d.ts +8 -0
- package/dist/app/api/user/anonymous/init/fingerprint-only-route.d.ts.map +1 -0
- package/dist/app/api/user/anonymous/init/fingerprint-only-route.js +20 -0
- package/dist/app/api/user/anonymous/init/fingerprint-only-route.mjs +18 -0
- package/dist/app/api/user/anonymous/init/route-shared.d.ts +10 -0
- package/dist/app/api/user/anonymous/init/route-shared.d.ts.map +1 -0
- package/dist/app/api/user/anonymous/init/route-shared.js +557 -0
- package/dist/app/api/user/anonymous/init/route-shared.mjs +555 -0
- package/dist/app/api/user/anonymous/init/route.d.ts +3 -3
- package/dist/app/api/user/anonymous/init/route.d.ts.map +1 -1
- package/dist/app/api/user/anonymous/init/route.js +6 -554
- package/dist/app/api/user/anonymous/init/route.mjs +7 -555
- package/dist/app/api/webhook/clerk/user/route.js +16 -16
- package/dist/app/api/webhook/clerk/user/route.mjs +16 -16
- package/dist/auth/auth-utils.d.ts +8 -23
- package/dist/auth/auth-utils.d.ts.map +1 -1
- package/dist/auth/auth-utils.js +8 -20
- package/dist/auth/auth-utils.mjs +8 -20
- package/dist/lib/money-price-config.d.ts +28 -28
- package/dist/lib/money-price-config.js +31 -31
- package/dist/lib/money-price-config.mjs +31 -31
- package/dist/lib/stripe-config.js +3 -3
- package/dist/lib/stripe-config.mjs +3 -3
- package/dist/prisma/prisma-transaction-util.js +1 -1
- package/dist/prisma/prisma-transaction-util.mjs +1 -1
- package/dist/prisma/prisma.d.ts.map +1 -1
- package/dist/prisma/prisma.js +18 -19
- package/dist/prisma/prisma.mjs +18 -19
- package/dist/services/aggregate/billing.aggregate.service.js +6 -6
- package/dist/services/aggregate/billing.aggregate.service.mjs +6 -6
- package/dist/services/aggregate/user.aggregate.service.d.ts +9 -9
- package/dist/services/aggregate/user.aggregate.service.js +16 -16
- package/dist/services/aggregate/user.aggregate.service.mjs +16 -16
- package/dist/services/database/constants.js +34 -34
- package/dist/services/database/constants.mjs +34 -34
- package/dist/services/database/credit.service.js +2 -2
- package/dist/services/database/credit.service.mjs +2 -2
- package/dist/services/database/transaction.service.js +1 -1
- package/dist/services/database/transaction.service.mjs +1 -1
- package/dist/services/database/user.service.js +2 -2
- package/dist/services/database/user.service.mjs +2 -2
- package/dist/services/stripe/webhook-handler.js +5 -5
- package/dist/services/stripe/webhook-handler.mjs +5 -5
- package/package.json +18 -6
- package/src/app/api/user/anonymous/init/fingerprint-only-route.ts +14 -0
- package/src/app/api/user/anonymous/init/route-shared.ts +710 -0
- package/src/app/api/user/anonymous/init/route.ts +7 -712
- package/src/app/api/webhook/clerk/user/route.ts +17 -17
- package/src/auth/auth-utils.ts +8 -23
- package/src/lib/money-price-config.ts +31 -32
- package/src/lib/stripe-config.ts +3 -3
- package/src/prisma/prisma-transaction-util.ts +1 -1
- package/src/prisma/prisma.ts +18 -19
- package/src/services/aggregate/billing.aggregate.service.ts +7 -7
- package/src/services/aggregate/user.aggregate.service.ts +16 -16
- package/src/services/database/constants.ts +34 -34
- package/src/services/database/credit.service.ts +2 -2
- package/src/services/database/transaction.service.ts +1 -1
- package/src/services/database/user.service.ts +2 -2
- package/src/services/stripe/webhook-handler.ts +5 -5
package/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# @windrun-huaiin/backend-core
|
|
2
|
+
|
|
3
|
+
Shared backend primitives for Next.js applications, including Prisma access, database services, authentication helpers, Stripe integration, credit and pricing server utilities, Upstash utilities, AI services, and ready-to-wire API route handlers.
|
|
4
|
+
|
|
5
|
+
This package is organized around public subpath exports. Import the narrowest entry point that matches the backend capability you need, especially when separating server-only code from route handlers.
|
|
6
|
+
|
|
7
|
+
## Feature Areas
|
|
8
|
+
|
|
9
|
+
### Core Backend Utilities
|
|
10
|
+
|
|
11
|
+
The root entry provides shared backend exports for application code that needs the common backend surface of the package.
|
|
12
|
+
|
|
13
|
+
| Entry | Purpose |
|
|
14
|
+
| --- | --- |
|
|
15
|
+
| `@windrun-huaiin/backend-core` | Shared backend primitives and common exports |
|
|
16
|
+
|
|
17
|
+
### Prisma and Database Services
|
|
18
|
+
|
|
19
|
+
The Prisma and database entries provide the data-access layer for applications that share database models, service methods, and transaction-oriented backend logic.
|
|
20
|
+
|
|
21
|
+
| Entry | Purpose |
|
|
22
|
+
| --- | --- |
|
|
23
|
+
| `@windrun-huaiin/backend-core/prisma` | Prisma client and Prisma-related utilities |
|
|
24
|
+
| `@windrun-huaiin/backend-core/database` | Database service layer |
|
|
25
|
+
| `@windrun-huaiin/backend-core/aggregate` | Aggregate service layer |
|
|
26
|
+
| `@windrun-huaiin/backend-core/context` | Backend context helpers |
|
|
27
|
+
|
|
28
|
+
### Authentication
|
|
29
|
+
|
|
30
|
+
Authentication entries provide shared server utilities, shared auth definitions, and middleware helpers for applications that need consistent auth handling.
|
|
31
|
+
|
|
32
|
+
| Entry | Purpose |
|
|
33
|
+
| --- | --- |
|
|
34
|
+
| `@windrun-huaiin/backend-core/auth/server` | Server-side authentication helpers |
|
|
35
|
+
| `@windrun-huaiin/backend-core/auth/shared` | Shared authentication utilities and definitions |
|
|
36
|
+
| `@windrun-huaiin/backend-core/auth/middleware` | Authentication middleware helpers |
|
|
37
|
+
|
|
38
|
+
### Stripe, Pricing, and Credits
|
|
39
|
+
|
|
40
|
+
Commerce entries cover Stripe integration, checkout and customer portal route handlers, pricing server helpers, and credit server helpers.
|
|
41
|
+
|
|
42
|
+
| Entry | Purpose |
|
|
43
|
+
| --- | --- |
|
|
44
|
+
| `@windrun-huaiin/backend-core/stripe` | Stripe service layer |
|
|
45
|
+
| `@windrun-huaiin/backend-core/stripe/server` | Server-side Stripe configuration helpers |
|
|
46
|
+
| `@windrun-huaiin/backend-core/pricing/server` | Server-side pricing helpers |
|
|
47
|
+
| `@windrun-huaiin/backend-core/credit/server` | Server-side credit helpers |
|
|
48
|
+
| `@windrun-huaiin/backend-core/config/money-price` | Money-price configuration |
|
|
49
|
+
| `@windrun-huaiin/backend-core/app/api/stripe/checkout/route` | Stripe checkout API route handler |
|
|
50
|
+
| `@windrun-huaiin/backend-core/app/api/stripe/customer-portal/route` | Stripe customer portal API route handler |
|
|
51
|
+
| `@windrun-huaiin/backend-core/app/api/webhook/stripe/route` | Stripe webhook API route handler |
|
|
52
|
+
|
|
53
|
+
### User and Clerk Routes
|
|
54
|
+
|
|
55
|
+
User route handlers provide reusable API endpoints for anonymous user initialization, credit overview, pricing context, and Clerk user webhooks.
|
|
56
|
+
|
|
57
|
+
| Entry | Purpose |
|
|
58
|
+
| --- | --- |
|
|
59
|
+
| `@windrun-huaiin/backend-core/app/api/user/anonymous/init/route` | Anonymous user initialization API route handler |
|
|
60
|
+
| `@windrun-huaiin/backend-core/app/api/user/credit-overview/route` | User credit overview API route handler |
|
|
61
|
+
| `@windrun-huaiin/backend-core/app/api/user/pricing-context/route` | User pricing context API route handler |
|
|
62
|
+
| `@windrun-huaiin/backend-core/app/api/webhook/clerk/user/route` | Clerk user webhook API route handler |
|
|
63
|
+
|
|
64
|
+
### Fingerprint and Upstash
|
|
65
|
+
|
|
66
|
+
Fingerprint and Upstash entries expose server-side configuration and infrastructure helpers for identity and storage-related backend workflows.
|
|
67
|
+
|
|
68
|
+
| Entry | Purpose |
|
|
69
|
+
| --- | --- |
|
|
70
|
+
| `@windrun-huaiin/backend-core/config/fingerprint` | Fingerprint configuration |
|
|
71
|
+
| `@windrun-huaiin/backend-core/upstash/server` | Server-side Upstash helpers |
|
|
72
|
+
|
|
73
|
+
### AI Services
|
|
74
|
+
|
|
75
|
+
AI entries provide shared AI service utilities and a reusable API route handler for AI endpoints.
|
|
76
|
+
|
|
77
|
+
| Entry | Purpose |
|
|
78
|
+
| --- | --- |
|
|
79
|
+
| `@windrun-huaiin/backend-core/ai` | AI service layer |
|
|
80
|
+
| `@windrun-huaiin/backend-core/app/api/ai/route` | AI API route handler |
|
|
81
|
+
|
|
82
|
+
## Usage Notes
|
|
83
|
+
|
|
84
|
+
- Use server-only entries from server components, route handlers, server actions, or backend modules.
|
|
85
|
+
- Use API route handler entries when an application wants to mount the package-provided route behavior directly in a Next.js route.
|
|
86
|
+
- Keep Prisma, database, Stripe, auth, and Upstash imports out of client-side code.
|
|
87
|
+
- Prefer feature-specific subpath imports so each application depends only on the backend capabilities it actually uses.
|
|
88
|
+
|
|
89
|
+
## Installation
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
pnpm add @windrun-huaiin/backend-core
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
This package is intended for Next.js backend usage. The consuming application is responsible for its environment variables, database setup, authentication provider setup, Stripe setup, and deployment configuration.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { NextRequest } from 'next/server';
|
|
2
|
+
/**
|
|
3
|
+
* Fingerprint-only anonymous user initialization API.
|
|
4
|
+
* Use this route in apps that do not install or configure Clerk.
|
|
5
|
+
* POST /api/user/anonymous/init
|
|
6
|
+
*/
|
|
7
|
+
export declare function POST(request: NextRequest): Promise<import("next/server").NextResponse<unknown>>;
|
|
8
|
+
//# sourceMappingURL=fingerprint-only-route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fingerprint-only-route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/user/anonymous/init/fingerprint-only-route.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;GAIG;AACH,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW,wDAK9C"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var routeShared = require('./route-shared.js');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Fingerprint-only anonymous user initialization API.
|
|
8
|
+
* Use this route in apps that do not install or configure Clerk.
|
|
9
|
+
* POST /api/user/anonymous/init
|
|
10
|
+
*/
|
|
11
|
+
function POST(request) {
|
|
12
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
return routeShared.handleFingerprintRequest(request, {
|
|
14
|
+
createIfNotExists: true,
|
|
15
|
+
getAuthIdentity: () => tslib.__awaiter(this, void 0, void 0, function* () { return null; }),
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
exports.POST = POST;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { __awaiter } from 'tslib';
|
|
2
|
+
import { handleFingerprintRequest } from './route-shared.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Fingerprint-only anonymous user initialization API.
|
|
6
|
+
* Use this route in apps that do not install or configure Clerk.
|
|
7
|
+
* POST /api/user/anonymous/init
|
|
8
|
+
*/
|
|
9
|
+
function POST(request) {
|
|
10
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
return handleFingerprintRequest(request, {
|
|
12
|
+
createIfNotExists: true,
|
|
13
|
+
getAuthIdentity: () => __awaiter(this, void 0, void 0, function* () { return null; }),
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { POST };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ProviderIdentity } from '@core/auth/auth-shared';
|
|
2
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
3
|
+
/**
|
|
4
|
+
* Shared fingerprint request handling logic.
|
|
5
|
+
*/
|
|
6
|
+
export declare function handleFingerprintRequest(request: NextRequest, options: {
|
|
7
|
+
createIfNotExists?: boolean;
|
|
8
|
+
getAuthIdentity: () => Promise<ProviderIdentity | null>;
|
|
9
|
+
}): Promise<NextResponse<unknown>>;
|
|
10
|
+
//# sourceMappingURL=route-shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-shared.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/user/anonymous/init/route-shared.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAknBxD;;GAEG;AACH,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE;IAC5E,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,eAAe,EAAE,MAAM,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;CACzD,kCAkEA"}
|