hylekit 1.0.0 → 1.0.2
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 +434 -0
- package/dist/bff/index.cjs +338 -0
- package/dist/bff/index.cjs.map +1 -0
- package/dist/bff/index.d.cts +2 -0
- package/dist/bff/index.d.ts +2 -0
- package/dist/bff/index.js +316 -0
- package/dist/bff/index.js.map +1 -0
- package/dist/client/nextjs.cjs +250 -0
- package/dist/client/nextjs.cjs.map +1 -0
- package/dist/client/nextjs.d.cts +868 -0
- package/dist/client/nextjs.d.ts +868 -0
- package/dist/client/nextjs.js +230 -0
- package/dist/client/nextjs.js.map +1 -0
- package/dist/client/sveltekit.cjs +237 -0
- package/dist/client/sveltekit.cjs.map +1 -0
- package/dist/client/sveltekit.d.cts +844 -0
- package/dist/client/sveltekit.d.ts +844 -0
- package/dist/client/sveltekit.js +217 -0
- package/dist/client/sveltekit.js.map +1 -0
- package/dist/index-DYW73KK3.d.cts +58 -0
- package/dist/index-DYW73KK3.d.ts +58 -0
- package/dist/index.cjs +502 -553
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3266 -1897
- package/dist/index.d.ts +3266 -1897
- package/dist/index.js +488 -535
- package/dist/index.js.map +1 -1
- package/dist/lib/schema.cjs +118 -0
- package/dist/lib/schema.cjs.map +1 -0
- package/dist/lib/schema.d.cts +3 -0
- package/dist/lib/schema.d.ts +3 -0
- package/dist/lib/schema.js +87 -0
- package/dist/lib/schema.js.map +1 -0
- package/dist/schema-ph9L8QMm.d.cts +674 -0
- package/dist/schema-ph9L8QMm.d.ts +674 -0
- package/dist/server/express.cjs +243 -0
- package/dist/server/express.cjs.map +1 -0
- package/dist/server/express.d.cts +85 -0
- package/dist/server/express.d.ts +85 -0
- package/dist/server/express.js +219 -0
- package/dist/server/express.js.map +1 -0
- package/dist/types-BHiK1JUX.d.cts +32 -0
- package/dist/types-GOn9sn7-.d.ts +32 -0
- package/package.json +45 -10
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// src/client/sveltekit.ts
|
|
8
|
+
import { toSvelteKitHandler } from "better-auth/svelte-kit";
|
|
9
|
+
import { createAuthClient } from "better-auth/svelte";
|
|
10
|
+
|
|
11
|
+
// src/lib/auth.ts
|
|
12
|
+
import { betterAuth } from "better-auth";
|
|
13
|
+
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
14
|
+
|
|
15
|
+
// src/lib/db.ts
|
|
16
|
+
import { drizzle } from "drizzle-orm/libsql";
|
|
17
|
+
import { createClient } from "@libsql/client";
|
|
18
|
+
|
|
19
|
+
// src/lib/schema.ts
|
|
20
|
+
var schema_exports = {};
|
|
21
|
+
__export(schema_exports, {
|
|
22
|
+
account: () => account,
|
|
23
|
+
accountRelations: () => accountRelations,
|
|
24
|
+
session: () => session,
|
|
25
|
+
sessionRelations: () => sessionRelations,
|
|
26
|
+
user: () => user,
|
|
27
|
+
userRelations: () => userRelations,
|
|
28
|
+
verification: () => verification
|
|
29
|
+
});
|
|
30
|
+
import { relations, sql } from "drizzle-orm";
|
|
31
|
+
import { sqliteTable, text, integer, index } from "drizzle-orm/sqlite-core";
|
|
32
|
+
var user = sqliteTable("user", {
|
|
33
|
+
id: text("id").primaryKey(),
|
|
34
|
+
name: text("name").notNull(),
|
|
35
|
+
email: text("email").notNull().unique(),
|
|
36
|
+
emailVerified: integer("email_verified", { mode: "boolean" }).default(false).notNull(),
|
|
37
|
+
image: text("image"),
|
|
38
|
+
createdAt: integer("created_at", { mode: "timestamp_ms" }).default(sql`(cast(unixepoch('subsecond') * 1000 as integer))`).notNull(),
|
|
39
|
+
updatedAt: integer("updated_at", { mode: "timestamp_ms" }).default(sql`(cast(unixepoch('subsecond') * 1000 as integer))`).$onUpdate(() => /* @__PURE__ */ new Date()).notNull()
|
|
40
|
+
});
|
|
41
|
+
var session = sqliteTable(
|
|
42
|
+
"session",
|
|
43
|
+
{
|
|
44
|
+
id: text("id").primaryKey(),
|
|
45
|
+
expiresAt: integer("expires_at", { mode: "timestamp_ms" }).notNull(),
|
|
46
|
+
token: text("token").notNull().unique(),
|
|
47
|
+
createdAt: integer("created_at", { mode: "timestamp_ms" }).default(sql`(cast(unixepoch('subsecond') * 1000 as integer))`).notNull(),
|
|
48
|
+
updatedAt: integer("updated_at", { mode: "timestamp_ms" }).$onUpdate(() => /* @__PURE__ */ new Date()).notNull(),
|
|
49
|
+
ipAddress: text("ip_address"),
|
|
50
|
+
userAgent: text("user_agent"),
|
|
51
|
+
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" })
|
|
52
|
+
},
|
|
53
|
+
(table) => [index("session_userId_idx").on(table.userId)]
|
|
54
|
+
);
|
|
55
|
+
var account = sqliteTable(
|
|
56
|
+
"account",
|
|
57
|
+
{
|
|
58
|
+
id: text("id").primaryKey(),
|
|
59
|
+
accountId: text("account_id").notNull(),
|
|
60
|
+
providerId: text("provider_id").notNull(),
|
|
61
|
+
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
62
|
+
accessToken: text("access_token"),
|
|
63
|
+
refreshToken: text("refresh_token"),
|
|
64
|
+
idToken: text("id_token"),
|
|
65
|
+
accessTokenExpiresAt: integer("access_token_expires_at", {
|
|
66
|
+
mode: "timestamp_ms"
|
|
67
|
+
}),
|
|
68
|
+
refreshTokenExpiresAt: integer("refresh_token_expires_at", {
|
|
69
|
+
mode: "timestamp_ms"
|
|
70
|
+
}),
|
|
71
|
+
scope: text("scope"),
|
|
72
|
+
password: text("password"),
|
|
73
|
+
createdAt: integer("created_at", { mode: "timestamp_ms" }).default(sql`(cast(unixepoch('subsecond') * 1000 as integer))`).notNull(),
|
|
74
|
+
updatedAt: integer("updated_at", { mode: "timestamp_ms" }).$onUpdate(() => /* @__PURE__ */ new Date()).notNull()
|
|
75
|
+
},
|
|
76
|
+
(table) => [index("account_userId_idx").on(table.userId)]
|
|
77
|
+
);
|
|
78
|
+
var verification = sqliteTable(
|
|
79
|
+
"verification",
|
|
80
|
+
{
|
|
81
|
+
id: text("id").primaryKey(),
|
|
82
|
+
identifier: text("identifier").notNull(),
|
|
83
|
+
value: text("value").notNull(),
|
|
84
|
+
expiresAt: integer("expires_at", { mode: "timestamp_ms" }).notNull(),
|
|
85
|
+
createdAt: integer("created_at", { mode: "timestamp_ms" }).default(sql`(cast(unixepoch('subsecond') * 1000 as integer))`).notNull(),
|
|
86
|
+
updatedAt: integer("updated_at", { mode: "timestamp_ms" }).default(sql`(cast(unixepoch('subsecond') * 1000 as integer))`).$onUpdate(() => /* @__PURE__ */ new Date()).notNull()
|
|
87
|
+
},
|
|
88
|
+
(table) => [index("verification_identifier_idx").on(table.identifier)]
|
|
89
|
+
);
|
|
90
|
+
var userRelations = relations(user, ({ many }) => ({
|
|
91
|
+
sessions: many(session),
|
|
92
|
+
accounts: many(account)
|
|
93
|
+
}));
|
|
94
|
+
var sessionRelations = relations(session, ({ one }) => ({
|
|
95
|
+
user: one(user, {
|
|
96
|
+
fields: [session.userId],
|
|
97
|
+
references: [user.id]
|
|
98
|
+
})
|
|
99
|
+
}));
|
|
100
|
+
var accountRelations = relations(account, ({ one }) => ({
|
|
101
|
+
user: one(user, {
|
|
102
|
+
fields: [account.userId],
|
|
103
|
+
references: [user.id]
|
|
104
|
+
})
|
|
105
|
+
}));
|
|
106
|
+
|
|
107
|
+
// src/lib/db.ts
|
|
108
|
+
var client = createClient({
|
|
109
|
+
url: process.env.DATABASE_URL,
|
|
110
|
+
authToken: process.env.DATABASE_AUTH_TOKEN
|
|
111
|
+
});
|
|
112
|
+
var db = drizzle(client, { schema: schema_exports });
|
|
113
|
+
|
|
114
|
+
// src/lib/auth.ts
|
|
115
|
+
var auth = betterAuth({
|
|
116
|
+
database: drizzleAdapter(db, {
|
|
117
|
+
provider: "sqlite",
|
|
118
|
+
schema: {
|
|
119
|
+
...schema_exports
|
|
120
|
+
}
|
|
121
|
+
}),
|
|
122
|
+
baseURL: process.env.BETTER_AUTH_URL || process.env.PUBLIC_APP_URL || process.env.NEXT_PUBLIC_APP_URL,
|
|
123
|
+
secret: process.env.BETTER_AUTH_SECRET,
|
|
124
|
+
trustedOrigins: process.env.TRUSTED_ORIGINS ? process.env.TRUSTED_ORIGINS.split(",") : void 0,
|
|
125
|
+
socialProviders: {
|
|
126
|
+
google: {
|
|
127
|
+
clientId: process.env.GOOGLE_CLIENT_ID || "",
|
|
128
|
+
clientSecret: process.env.GOOGLE_CLIENT_SECRET || ""
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
session: {
|
|
132
|
+
expiresIn: 60 * 60 * 24 * 7,
|
|
133
|
+
// 7 days
|
|
134
|
+
updateAge: 60 * 60 * 24,
|
|
135
|
+
// Update session every 24 hours
|
|
136
|
+
cookieCache: {
|
|
137
|
+
enabled: true,
|
|
138
|
+
maxAge: 60 * 5
|
|
139
|
+
// 5 minutes
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// src/client/sveltekit.ts
|
|
145
|
+
var handler = toSvelteKitHandler(auth);
|
|
146
|
+
var authClient = createAuthClient();
|
|
147
|
+
var client2 = {
|
|
148
|
+
...authClient,
|
|
149
|
+
/**
|
|
150
|
+
* Alias for signIn.
|
|
151
|
+
*/
|
|
152
|
+
login: authClient.signIn
|
|
153
|
+
};
|
|
154
|
+
var server = {
|
|
155
|
+
/**
|
|
156
|
+
* The underlying BetterAuth instance.
|
|
157
|
+
*/
|
|
158
|
+
auth,
|
|
159
|
+
/**
|
|
160
|
+
* SvelteKit request handler for auth routes.
|
|
161
|
+
* Place this in `src/routes/api/auth/[...auth]/+server.ts`
|
|
162
|
+
*/
|
|
163
|
+
handler: {
|
|
164
|
+
GET: handler,
|
|
165
|
+
POST: handler
|
|
166
|
+
},
|
|
167
|
+
/**
|
|
168
|
+
* Creates a SvelteKit handle hook for session management.
|
|
169
|
+
*/
|
|
170
|
+
createHandle: () => {
|
|
171
|
+
return async ({ event, resolve }) => {
|
|
172
|
+
const session2 = await auth.api.getSession({
|
|
173
|
+
headers: event.request.headers
|
|
174
|
+
});
|
|
175
|
+
event.locals.session = session2;
|
|
176
|
+
event.locals.user = session2?.user ?? null;
|
|
177
|
+
return resolve(event);
|
|
178
|
+
};
|
|
179
|
+
},
|
|
180
|
+
/**
|
|
181
|
+
* Get session from request event.
|
|
182
|
+
*/
|
|
183
|
+
getSession: async (event) => {
|
|
184
|
+
return auth.api.getSession({
|
|
185
|
+
headers: event.request.headers
|
|
186
|
+
});
|
|
187
|
+
},
|
|
188
|
+
/**
|
|
189
|
+
* Check if user is authenticated.
|
|
190
|
+
*/
|
|
191
|
+
isAuthenticated: async (event) => {
|
|
192
|
+
const session2 = await auth.api.getSession({
|
|
193
|
+
headers: event.request.headers
|
|
194
|
+
});
|
|
195
|
+
return session2 !== null;
|
|
196
|
+
},
|
|
197
|
+
/**
|
|
198
|
+
* Wraps a function to ensure the user is authenticated before execution.
|
|
199
|
+
* Injects the user, session, and db into the first argument.
|
|
200
|
+
*/
|
|
201
|
+
makeAuthenticatedCall: (fn) => {
|
|
202
|
+
return async (event, ...args) => {
|
|
203
|
+
const session2 = await auth.api.getSession({
|
|
204
|
+
headers: event.request.headers
|
|
205
|
+
});
|
|
206
|
+
if (!session2) {
|
|
207
|
+
throw new Error("Unauthorized");
|
|
208
|
+
}
|
|
209
|
+
return fn({ user: session2.user, session: session2.session, db, event }, ...args);
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
export {
|
|
214
|
+
client2 as client,
|
|
215
|
+
server
|
|
216
|
+
};
|
|
217
|
+
//# sourceMappingURL=sveltekit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/client/sveltekit.ts","../../src/lib/auth.ts","../../src/lib/db.ts","../../src/lib/schema.ts"],"sourcesContent":["import { toSvelteKitHandler } from \"better-auth/svelte-kit\";\nimport { createAuthClient } from \"better-auth/svelte\";\nimport type { Handle, RequestEvent } from \"@sveltejs/kit\";\nimport { auth as betterAuthInstance } from \"../lib/auth\";\nimport { db } from \"../lib/db\";\nimport type { SessionResult, UserInfo, SessionData } from \"./types\";\n\nexport type { SessionResult, UserInfo, SessionData } from \"./types\";\n\nconst handler = toSvelteKitHandler(betterAuthInstance);\n\n// Initialize the Better Auth Client (for browser/client-side use)\nconst authClient = createAuthClient();\n\n/**\n * Client-side Auth instance.\n * Use this in your Svelte components and client-side logic.\n */\nexport const client = {\n ...authClient,\n /**\n * Alias for signIn.\n */\n login: authClient.signIn\n};\n\n/**\n * Server-side Auth instance.\n * Use this in your +page.server.ts, hooks.server.ts, and API routes.\n */\nexport const server = {\n /**\n * The underlying BetterAuth instance.\n */\n auth: betterAuthInstance,\n\n /**\n * SvelteKit request handler for auth routes.\n * Place this in `src/routes/api/auth/[...auth]/+server.ts`\n */\n handler: {\n GET: handler,\n POST: handler,\n },\n\n /**\n * Creates a SvelteKit handle hook for session management.\n */\n createHandle: (): Handle => {\n return async ({ event, resolve }) => {\n const session = await betterAuthInstance.api.getSession({\n headers: event.request.headers,\n });\n\n // Set on locals - consumer must extend App.Locals type\n (event.locals as Record<string, unknown>).session = session;\n (event.locals as Record<string, unknown>).user = session?.user ?? null;\n\n return resolve(event);\n };\n },\n\n /**\n * Get session from request event.\n */\n getSession: async (event: RequestEvent): Promise<SessionResult> => {\n return betterAuthInstance.api.getSession({\n headers: event.request.headers,\n });\n },\n\n /**\n * Check if user is authenticated.\n */\n isAuthenticated: async (event: RequestEvent): Promise<boolean> => {\n const session = await betterAuthInstance.api.getSession({\n headers: event.request.headers,\n });\n return session !== null;\n },\n\n /**\n * Wraps a function to ensure the user is authenticated before execution.\n * Injects the user, session, and db into the first argument.\n */\n makeAuthenticatedCall: <TArgs extends any[], TReturn>(\n fn: (ctx: { user: SessionData['user']; session: SessionData['session']; db: typeof db; event: RequestEvent }, ...args: TArgs) => Promise<TReturn>\n ) => {\n return async (event: RequestEvent, ...args: TArgs): Promise<TReturn> => {\n const session = await betterAuthInstance.api.getSession({\n headers: event.request.headers,\n });\n if (!session) {\n throw new Error(\"Unauthorized\");\n }\n return fn({ user: session.user, session: session.session, db, event }, ...args);\n }\n }\n};\n\n","import { betterAuth } from \"better-auth\";\nimport { drizzleAdapter } from \"better-auth/adapters/drizzle\";\nimport { db } from \"./db\";\nimport * as schema from \"./schema\";\n\nexport const auth = betterAuth({\n database: drizzleAdapter(db, {\n provider: \"sqlite\",\n schema: {\n ...schema\n }\n }),\n baseURL: process.env.BETTER_AUTH_URL || process.env.PUBLIC_APP_URL || process.env.NEXT_PUBLIC_APP_URL,\n secret: process.env.BETTER_AUTH_SECRET,\n trustedOrigins: process.env.TRUSTED_ORIGINS ? process.env.TRUSTED_ORIGINS.split(\",\") : undefined,\n socialProviders: {\n google: {\n clientId: process.env.GOOGLE_CLIENT_ID || \"\",\n clientSecret: process.env.GOOGLE_CLIENT_SECRET || \"\",\n },\n },\n session: {\n expiresIn: 60 * 60 * 24 * 7, // 7 days\n updateAge: 60 * 60 * 24, // Update session every 24 hours\n cookieCache: {\n enabled: true,\n maxAge: 60 * 5, // 5 minutes\n },\n },\n});\n","import { drizzle } from \"drizzle-orm/libsql\";\nimport { createClient } from \"@libsql/client\";\nimport * as schema from \"./schema\";\n\nconst client = createClient({\n url: process.env.DATABASE_URL!,\n authToken: process.env.DATABASE_AUTH_TOKEN!,\n});\n\nexport const db = drizzle(client, { schema });\n","import { relations, sql } from \"drizzle-orm\";\nimport { sqliteTable, text, integer, index } from \"drizzle-orm/sqlite-core\";\n\nexport const user = sqliteTable(\"user\", {\n id: text(\"id\").primaryKey(),\n name: text(\"name\").notNull(),\n email: text(\"email\").notNull().unique(),\n emailVerified: integer(\"email_verified\", { mode: \"boolean\" })\n .default(false)\n .notNull(),\n image: text(\"image\"),\n createdAt: integer(\"created_at\", { mode: \"timestamp_ms\" })\n .default(sql`(cast(unixepoch('subsecond') * 1000 as integer))`)\n .notNull(),\n updatedAt: integer(\"updated_at\", { mode: \"timestamp_ms\" })\n .default(sql`(cast(unixepoch('subsecond') * 1000 as integer))`)\n .$onUpdate(() => /* @__PURE__ */ new Date())\n .notNull(),\n});\n\nexport const session = sqliteTable(\n \"session\",\n {\n id: text(\"id\").primaryKey(),\n expiresAt: integer(\"expires_at\", { mode: \"timestamp_ms\" }).notNull(),\n token: text(\"token\").notNull().unique(),\n createdAt: integer(\"created_at\", { mode: \"timestamp_ms\" })\n .default(sql`(cast(unixepoch('subsecond') * 1000 as integer))`)\n .notNull(),\n updatedAt: integer(\"updated_at\", { mode: \"timestamp_ms\" })\n .$onUpdate(() => /* @__PURE__ */ new Date())\n .notNull(),\n ipAddress: text(\"ip_address\"),\n userAgent: text(\"user_agent\"),\n userId: text(\"user_id\")\n .notNull()\n .references(() => user.id, { onDelete: \"cascade\" }),\n },\n (table) => [index(\"session_userId_idx\").on(table.userId)],\n);\n\nexport const account = sqliteTable(\n \"account\",\n {\n id: text(\"id\").primaryKey(),\n accountId: text(\"account_id\").notNull(),\n providerId: text(\"provider_id\").notNull(),\n userId: text(\"user_id\")\n .notNull()\n .references(() => user.id, { onDelete: \"cascade\" }),\n accessToken: text(\"access_token\"),\n refreshToken: text(\"refresh_token\"),\n idToken: text(\"id_token\"),\n accessTokenExpiresAt: integer(\"access_token_expires_at\", {\n mode: \"timestamp_ms\",\n }),\n refreshTokenExpiresAt: integer(\"refresh_token_expires_at\", {\n mode: \"timestamp_ms\",\n }),\n scope: text(\"scope\"),\n password: text(\"password\"),\n createdAt: integer(\"created_at\", { mode: \"timestamp_ms\" })\n .default(sql`(cast(unixepoch('subsecond') * 1000 as integer))`)\n .notNull(),\n updatedAt: integer(\"updated_at\", { mode: \"timestamp_ms\" })\n .$onUpdate(() => /* @__PURE__ */ new Date())\n .notNull(),\n },\n (table) => [index(\"account_userId_idx\").on(table.userId)],\n);\n\nexport const verification = sqliteTable(\n \"verification\",\n {\n id: text(\"id\").primaryKey(),\n identifier: text(\"identifier\").notNull(),\n value: text(\"value\").notNull(),\n expiresAt: integer(\"expires_at\", { mode: \"timestamp_ms\" }).notNull(),\n createdAt: integer(\"created_at\", { mode: \"timestamp_ms\" })\n .default(sql`(cast(unixepoch('subsecond') * 1000 as integer))`)\n .notNull(),\n updatedAt: integer(\"updated_at\", { mode: \"timestamp_ms\" })\n .default(sql`(cast(unixepoch('subsecond') * 1000 as integer))`)\n .$onUpdate(() => /* @__PURE__ */ new Date())\n .notNull(),\n },\n (table) => [index(\"verification_identifier_idx\").on(table.identifier)],\n);\n\nexport const userRelations = relations(user, ({ many }) => ({\n sessions: many(session),\n accounts: many(account),\n}));\n\nexport const sessionRelations = relations(session, ({ one }) => ({\n user: one(user, {\n fields: [session.userId],\n references: [user.id],\n }),\n}));\n\nexport const accountRelations = relations(account, ({ one }) => ({\n user: one(user, {\n fields: [account.userId],\n references: [user.id],\n }),\n}));\n"],"mappings":";;;;;;;AAAA,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;;;ACDjC,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;;;ACD/B,SAAS,eAAe;AACxB,SAAS,oBAAoB;;;ACD7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,WAAW,WAAW;AAC/B,SAAS,aAAa,MAAM,SAAS,aAAa;AAE3C,IAAM,OAAO,YAAY,QAAQ;AAAA,EACtC,IAAI,KAAK,IAAI,EAAE,WAAW;AAAA,EAC1B,MAAM,KAAK,MAAM,EAAE,QAAQ;AAAA,EAC3B,OAAO,KAAK,OAAO,EAAE,QAAQ,EAAE,OAAO;AAAA,EACtC,eAAe,QAAQ,kBAAkB,EAAE,MAAM,UAAU,CAAC,EACzD,QAAQ,KAAK,EACb,QAAQ;AAAA,EACX,OAAO,KAAK,OAAO;AAAA,EACnB,WAAW,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
|
|
1
|
+
import { RequestEvent } from '@sveltejs/kit';
|
|
2
|
+
|
|
3
|
+
interface BffClientConfig {
|
|
4
|
+
/**
|
|
5
|
+
* The base URL of your Express backend.
|
|
6
|
+
* @example "http://localhost:3000"
|
|
7
|
+
*/
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
/**
|
|
10
|
+
* Default headers to include in every request.
|
|
11
|
+
*/
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
}
|
|
14
|
+
type FetchMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
15
|
+
interface RequestOptions extends RequestInit {
|
|
16
|
+
/**
|
|
17
|
+
* Query parameters to append to the URL.
|
|
18
|
+
*/
|
|
19
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Base client logic.
|
|
24
|
+
*/
|
|
25
|
+
declare class BffClientBase {
|
|
26
|
+
private config;
|
|
27
|
+
constructor(config: BffClientConfig);
|
|
28
|
+
protected request<T>(path: string, method: FetchMethod, options?: RequestOptions): Promise<T>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare class SvelteKitBffClient extends BffClientBase {
|
|
32
|
+
constructor(config: BffClientConfig);
|
|
33
|
+
/**
|
|
34
|
+
* Creates a request context bound to a specific SvelteKit event.
|
|
35
|
+
* This is necessary because SvelteKit doesn't have global request storage.
|
|
36
|
+
*/
|
|
37
|
+
with(event: RequestEvent): {
|
|
38
|
+
get: <T>(path: string, options?: RequestOptions) => Promise<T>;
|
|
39
|
+
post: <T>(path: string, body?: any, options?: RequestOptions) => Promise<T>;
|
|
40
|
+
put: <T>(path: string, body?: any, options?: RequestOptions) => Promise<T>;
|
|
41
|
+
patch: <T>(path: string, body?: any, options?: RequestOptions) => Promise<T>;
|
|
42
|
+
delete: <T>(path: string, options?: RequestOptions) => Promise<T>;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
declare const createSvelteKitBff: (baseUrlOrConfig: string | BffClientConfig) => SvelteKitBffClient;
|
|
46
|
+
|
|
47
|
+
declare class NextJsBffClient extends BffClientBase {
|
|
48
|
+
constructor(config: BffClientConfig);
|
|
49
|
+
private getAuthHeaders;
|
|
50
|
+
get<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
51
|
+
post<T>(path: string, body?: any, options?: RequestOptions): Promise<T>;
|
|
52
|
+
put<T>(path: string, body?: any, options?: RequestOptions): Promise<T>;
|
|
53
|
+
patch<T>(path: string, body?: any, options?: RequestOptions): Promise<T>;
|
|
54
|
+
delete<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
55
|
+
}
|
|
56
|
+
declare const createNextJsBff: (baseUrlOrConfig: string | BffClientConfig) => NextJsBffClient;
|
|
57
|
+
|
|
58
|
+
export { type BffClientConfig as B, NextJsBffClient as N, type RequestOptions as R, SvelteKitBffClient as S, createSvelteKitBff as a, createNextJsBff as c };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { RequestEvent } from '@sveltejs/kit';
|
|
2
|
+
|
|
3
|
+
interface BffClientConfig {
|
|
4
|
+
/**
|
|
5
|
+
* The base URL of your Express backend.
|
|
6
|
+
* @example "http://localhost:3000"
|
|
7
|
+
*/
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
/**
|
|
10
|
+
* Default headers to include in every request.
|
|
11
|
+
*/
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
}
|
|
14
|
+
type FetchMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
15
|
+
interface RequestOptions extends RequestInit {
|
|
16
|
+
/**
|
|
17
|
+
* Query parameters to append to the URL.
|
|
18
|
+
*/
|
|
19
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Base client logic.
|
|
24
|
+
*/
|
|
25
|
+
declare class BffClientBase {
|
|
26
|
+
private config;
|
|
27
|
+
constructor(config: BffClientConfig);
|
|
28
|
+
protected request<T>(path: string, method: FetchMethod, options?: RequestOptions): Promise<T>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare class SvelteKitBffClient extends BffClientBase {
|
|
32
|
+
constructor(config: BffClientConfig);
|
|
33
|
+
/**
|
|
34
|
+
* Creates a request context bound to a specific SvelteKit event.
|
|
35
|
+
* This is necessary because SvelteKit doesn't have global request storage.
|
|
36
|
+
*/
|
|
37
|
+
with(event: RequestEvent): {
|
|
38
|
+
get: <T>(path: string, options?: RequestOptions) => Promise<T>;
|
|
39
|
+
post: <T>(path: string, body?: any, options?: RequestOptions) => Promise<T>;
|
|
40
|
+
put: <T>(path: string, body?: any, options?: RequestOptions) => Promise<T>;
|
|
41
|
+
patch: <T>(path: string, body?: any, options?: RequestOptions) => Promise<T>;
|
|
42
|
+
delete: <T>(path: string, options?: RequestOptions) => Promise<T>;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
declare const createSvelteKitBff: (baseUrlOrConfig: string | BffClientConfig) => SvelteKitBffClient;
|
|
46
|
+
|
|
47
|
+
declare class NextJsBffClient extends BffClientBase {
|
|
48
|
+
constructor(config: BffClientConfig);
|
|
49
|
+
private getAuthHeaders;
|
|
50
|
+
get<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
51
|
+
post<T>(path: string, body?: any, options?: RequestOptions): Promise<T>;
|
|
52
|
+
put<T>(path: string, body?: any, options?: RequestOptions): Promise<T>;
|
|
53
|
+
patch<T>(path: string, body?: any, options?: RequestOptions): Promise<T>;
|
|
54
|
+
delete<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
55
|
+
}
|
|
56
|
+
declare const createNextJsBff: (baseUrlOrConfig: string | BffClientConfig) => NextJsBffClient;
|
|
57
|
+
|
|
58
|
+
export { type BffClientConfig as B, NextJsBffClient as N, type RequestOptions as R, SvelteKitBffClient as S, createSvelteKitBff as a, createNextJsBff as c };
|