@infuro/cms-core 1.0.0
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 +693 -0
- package/dist/admin.cjs +7119 -0
- package/dist/admin.cjs.map +1 -0
- package/dist/admin.css +75 -0
- package/dist/admin.d.cts +209 -0
- package/dist/admin.d.ts +209 -0
- package/dist/admin.js +7079 -0
- package/dist/admin.js.map +1 -0
- package/dist/api.cjs +1158 -0
- package/dist/api.cjs.map +1 -0
- package/dist/api.d.cts +2 -0
- package/dist/api.d.ts +2 -0
- package/dist/api.js +1112 -0
- package/dist/api.js.map +1 -0
- package/dist/auth.cjs +226 -0
- package/dist/auth.cjs.map +1 -0
- package/dist/auth.d.cts +99 -0
- package/dist/auth.d.ts +99 -0
- package/dist/auth.js +181 -0
- package/dist/auth.js.map +1 -0
- package/dist/config-DJ5CmQvS.d.cts +8 -0
- package/dist/config-DJ5CmQvS.d.ts +8 -0
- package/dist/hooks.cjs +94 -0
- package/dist/hooks.cjs.map +1 -0
- package/dist/hooks.d.cts +22 -0
- package/dist/hooks.d.ts +22 -0
- package/dist/hooks.js +54 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index-DP3LK1XN.d.cts +263 -0
- package/dist/index-DP3LK1XN.d.ts +263 -0
- package/dist/index.cjs +3008 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +543 -0
- package/dist/index.d.ts +543 -0
- package/dist/index.js +2928 -0
- package/dist/index.js.map +1 -0
- package/dist/theme.cjs +113 -0
- package/dist/theme.cjs.map +1 -0
- package/dist/theme.d.cts +32 -0
- package/dist/theme.d.ts +32 -0
- package/dist/theme.js +73 -0
- package/dist/theme.js.map +1 -0
- package/dist/types-D34wmivy.d.cts +78 -0
- package/dist/types-D34wmivy.d.ts +78 -0
- package/package.json +106 -0
package/dist/api.js
ADDED
|
@@ -0,0 +1,1112 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __esm = (fn, res) => function __init() {
|
|
4
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
5
|
+
};
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// src/plugins/email/email-service.ts
|
|
12
|
+
var email_service_exports = {};
|
|
13
|
+
__export(email_service_exports, {
|
|
14
|
+
EmailService: () => EmailService,
|
|
15
|
+
emailTemplates: () => emailTemplates
|
|
16
|
+
});
|
|
17
|
+
import { SESClient, SendEmailCommand } from "@aws-sdk/client-ses";
|
|
18
|
+
import nodemailer from "nodemailer";
|
|
19
|
+
var EmailService, emailTemplates;
|
|
20
|
+
var init_email_service = __esm({
|
|
21
|
+
"src/plugins/email/email-service.ts"() {
|
|
22
|
+
"use strict";
|
|
23
|
+
EmailService = class {
|
|
24
|
+
config;
|
|
25
|
+
sesClient;
|
|
26
|
+
transporter;
|
|
27
|
+
constructor(config) {
|
|
28
|
+
this.config = config;
|
|
29
|
+
if (config.type === "AWS") {
|
|
30
|
+
if (!config.region || !config.accessKeyId || !config.secretAccessKey) {
|
|
31
|
+
throw new Error("AWS SES configuration incomplete");
|
|
32
|
+
}
|
|
33
|
+
this.sesClient = new SESClient({
|
|
34
|
+
region: config.region,
|
|
35
|
+
credentials: { accessKeyId: config.accessKeyId, secretAccessKey: config.secretAccessKey }
|
|
36
|
+
});
|
|
37
|
+
} else if (config.type === "SMTP" || config.type === "GMAIL") {
|
|
38
|
+
if (!config.user || !config.password) throw new Error("SMTP configuration incomplete");
|
|
39
|
+
this.transporter = nodemailer.createTransport({
|
|
40
|
+
host: config.type === "GMAIL" ? "smtp.gmail.com" : void 0,
|
|
41
|
+
port: 587,
|
|
42
|
+
secure: false,
|
|
43
|
+
auth: { user: config.user, pass: config.password }
|
|
44
|
+
});
|
|
45
|
+
} else {
|
|
46
|
+
throw new Error(`Unsupported email type: ${config.type}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async send(emailData) {
|
|
50
|
+
try {
|
|
51
|
+
if (this.config.type === "AWS" && this.sesClient) {
|
|
52
|
+
await this.sesClient.send(
|
|
53
|
+
new SendEmailCommand({
|
|
54
|
+
Source: emailData.from || this.config.from,
|
|
55
|
+
Destination: { ToAddresses: [emailData.to || this.config.to] },
|
|
56
|
+
Message: {
|
|
57
|
+
Subject: { Data: emailData.subject, Charset: "UTF-8" },
|
|
58
|
+
Body: {
|
|
59
|
+
Html: { Data: emailData.html, Charset: "UTF-8" },
|
|
60
|
+
...emailData.text && { Text: { Data: emailData.text, Charset: "UTF-8" } }
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
);
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
if ((this.config.type === "SMTP" || this.config.type === "GMAIL") && this.transporter) {
|
|
68
|
+
await this.transporter.sendMail({
|
|
69
|
+
from: emailData.from || this.config.from,
|
|
70
|
+
to: emailData.to || this.config.to,
|
|
71
|
+
subject: emailData.subject,
|
|
72
|
+
html: emailData.html,
|
|
73
|
+
text: emailData.text
|
|
74
|
+
});
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.error("Email sending failed:", error);
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
emailTemplates = {
|
|
85
|
+
formSubmission: (data) => ({
|
|
86
|
+
subject: `New Form Submission: ${data.formName}`,
|
|
87
|
+
html: `<h2>New Form Submission</h2><p><strong>Form:</strong> ${data.formName}</p><p><strong>Contact:</strong> ${data.contactName} (${data.contactEmail})</p><pre>${JSON.stringify(data.formData, null, 2)}</pre>`,
|
|
88
|
+
text: `New Form Submission
|
|
89
|
+
Form: ${data.formName}
|
|
90
|
+
Contact: ${data.contactName} (${data.contactEmail})
|
|
91
|
+
${JSON.stringify(data.formData, null, 2)}`
|
|
92
|
+
}),
|
|
93
|
+
contactSubmission: (data) => ({
|
|
94
|
+
subject: `New Contact Form Submission from ${data.name}`,
|
|
95
|
+
html: `<h2>New Contact Form Submission</h2><p><strong>Name:</strong> ${data.name}</p><p><strong>Email:</strong> ${data.email}</p>${data.phone ? `<p><strong>Phone:</strong> ${data.phone}</p>` : ""}${data.message ? `<p><strong>Message:</strong></p><p>${data.message}</p>` : ""}`,
|
|
96
|
+
text: `New Contact Form Submission
|
|
97
|
+
Name: ${data.name}
|
|
98
|
+
Email: ${data.email}
|
|
99
|
+
${data.phone ? `Phone: ${data.phone}
|
|
100
|
+
` : ""}${data.message ? `Message: ${data.message}` : ""}`
|
|
101
|
+
}),
|
|
102
|
+
passwordReset: (data) => ({
|
|
103
|
+
subject: "Reset your password",
|
|
104
|
+
html: `<h2>Reset your password</h2><p>Click the link below to set a new password. This link expires in 1 hour.</p><p><a href="${data.resetLink}">${data.resetLink}</a></p>`,
|
|
105
|
+
text: `Reset your password: ${data.resetLink}
|
|
106
|
+
|
|
107
|
+
This link expires in 1 hour.`
|
|
108
|
+
})
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// src/api/crud.ts
|
|
114
|
+
import { ILike, Like } from "typeorm";
|
|
115
|
+
var DATE_COLUMN_TYPES = /* @__PURE__ */ new Set([
|
|
116
|
+
"date",
|
|
117
|
+
"datetime",
|
|
118
|
+
"datetime2",
|
|
119
|
+
"timestamp",
|
|
120
|
+
"timestamptz",
|
|
121
|
+
"timetz",
|
|
122
|
+
"smalldatetime",
|
|
123
|
+
"timestamp with time zone",
|
|
124
|
+
"timestamp without time zone"
|
|
125
|
+
]);
|
|
126
|
+
var TIMESTAMP_PROP_NAMES = /* @__PURE__ */ new Set(["createdAt", "updatedAt", "deletedAt"]);
|
|
127
|
+
function isInvalidDateValue(v) {
|
|
128
|
+
if (v === "" || v == null) return true;
|
|
129
|
+
if (typeof v === "string") return isNaN(Date.parse(v)) || /NaN|Invalid/i.test(v);
|
|
130
|
+
if (v instanceof Date) return isNaN(v.getTime());
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
function sanitizeBodyForEntity(repo, body) {
|
|
134
|
+
const meta = repo.metadata;
|
|
135
|
+
for (const col of meta.columns) {
|
|
136
|
+
if (!(col.propertyName in body)) continue;
|
|
137
|
+
const v = body[col.propertyName];
|
|
138
|
+
const t = typeof col.type === "string" ? col.type : col.type?.name ?? "";
|
|
139
|
+
const isBoolean = t === "boolean" || t === "bool" || col.type === Boolean;
|
|
140
|
+
const isNumber = ["int", "integer", "int2", "int4", "int8", "smallint", "bigint", "number", "Number"].includes(t) || col.type === Number;
|
|
141
|
+
const isDate = DATE_COLUMN_TYPES.has(t) || col.type === Date || TIMESTAMP_PROP_NAMES.has(col.propertyName);
|
|
142
|
+
if (v === "" && (isBoolean || isNumber)) {
|
|
143
|
+
delete body[col.propertyName];
|
|
144
|
+
} else if (isDate && isInvalidDateValue(v)) {
|
|
145
|
+
delete body[col.propertyName];
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function createCrudHandler(dataSource, entityMap, options) {
|
|
150
|
+
const { requireAuth, json } = options;
|
|
151
|
+
return {
|
|
152
|
+
async GET(req, resource) {
|
|
153
|
+
const authError = await requireAuth(req);
|
|
154
|
+
if (authError) return authError;
|
|
155
|
+
const entity = entityMap[resource];
|
|
156
|
+
if (!resource || !entity) {
|
|
157
|
+
return json({ error: "Invalid resource" }, { status: 400 });
|
|
158
|
+
}
|
|
159
|
+
const repo = dataSource.getRepository(entity);
|
|
160
|
+
const { searchParams } = new URL(req.url);
|
|
161
|
+
const page = Number(searchParams.get("page")) || 1;
|
|
162
|
+
const limit = Number(searchParams.get("limit")) || 10;
|
|
163
|
+
const skip = (page - 1) * limit;
|
|
164
|
+
const sortField = searchParams.get("sortField") || "createdAt";
|
|
165
|
+
const sortOrder = searchParams.get("sortOrder") === "desc" ? "DESC" : "ASC";
|
|
166
|
+
const search = searchParams.get("search");
|
|
167
|
+
const typeFilter = searchParams.get("type");
|
|
168
|
+
let where = {};
|
|
169
|
+
if (resource === "media") {
|
|
170
|
+
const mediaWhere = {};
|
|
171
|
+
if (search) mediaWhere.filename = ILike(`%${search}%`);
|
|
172
|
+
if (typeFilter) mediaWhere.mimeType = Like(`${typeFilter}/%`);
|
|
173
|
+
where = Object.keys(mediaWhere).length > 0 ? mediaWhere : {};
|
|
174
|
+
} else if (search) {
|
|
175
|
+
where = [{ name: ILike(`%${search}%`) }, { title: ILike(`%${search}%`) }];
|
|
176
|
+
}
|
|
177
|
+
const [data, total] = await repo.findAndCount({
|
|
178
|
+
skip,
|
|
179
|
+
take: limit,
|
|
180
|
+
order: { [sortField]: sortOrder },
|
|
181
|
+
where
|
|
182
|
+
});
|
|
183
|
+
return json({ total, page, limit, totalPages: Math.ceil(total / limit), data });
|
|
184
|
+
},
|
|
185
|
+
async POST(req, resource) {
|
|
186
|
+
const authError = await requireAuth(req);
|
|
187
|
+
if (authError) return authError;
|
|
188
|
+
const entity = entityMap[resource];
|
|
189
|
+
if (!resource || !entity) {
|
|
190
|
+
return json({ error: "Invalid resource" }, { status: 400 });
|
|
191
|
+
}
|
|
192
|
+
const body = await req.json();
|
|
193
|
+
if (!body || typeof body !== "object" || Object.keys(body).length === 0) {
|
|
194
|
+
return json({ error: "Invalid request payload" }, { status: 400 });
|
|
195
|
+
}
|
|
196
|
+
const repo = dataSource.getRepository(entity);
|
|
197
|
+
sanitizeBodyForEntity(repo, body);
|
|
198
|
+
const created = await repo.save(repo.create(body));
|
|
199
|
+
return json(created, { status: 201 });
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
function createCrudByIdHandler(dataSource, entityMap, options) {
|
|
204
|
+
const { requireAuth, json } = options;
|
|
205
|
+
return {
|
|
206
|
+
async GET(req, resource, id) {
|
|
207
|
+
const authError = await requireAuth(req);
|
|
208
|
+
if (authError) return authError;
|
|
209
|
+
const entity = entityMap[resource];
|
|
210
|
+
if (!entity) return json({ error: "Invalid resource" }, { status: 400 });
|
|
211
|
+
const repo = dataSource.getRepository(entity);
|
|
212
|
+
const item = await repo.findOne({ where: { id: Number(id) } });
|
|
213
|
+
return item ? json(item) : json({ message: "Not found" }, { status: 404 });
|
|
214
|
+
},
|
|
215
|
+
async PUT(req, resource, id) {
|
|
216
|
+
const authError = await requireAuth(req);
|
|
217
|
+
if (authError) return authError;
|
|
218
|
+
const entity = entityMap[resource];
|
|
219
|
+
if (!entity) return json({ error: "Invalid resource" }, { status: 400 });
|
|
220
|
+
const body = await req.json();
|
|
221
|
+
const repo = dataSource.getRepository(entity);
|
|
222
|
+
if (body && typeof body === "object") sanitizeBodyForEntity(repo, body);
|
|
223
|
+
await repo.update(Number(id), body);
|
|
224
|
+
const updated = await repo.findOne({ where: { id: Number(id) } });
|
|
225
|
+
return updated ? json(updated) : json({ message: "Not found" }, { status: 404 });
|
|
226
|
+
},
|
|
227
|
+
async DELETE(req, resource, id) {
|
|
228
|
+
const authError = await requireAuth(req);
|
|
229
|
+
if (authError) return authError;
|
|
230
|
+
const entity = entityMap[resource];
|
|
231
|
+
if (!entity) return json({ error: "Invalid resource" }, { status: 400 });
|
|
232
|
+
const repo = dataSource.getRepository(entity);
|
|
233
|
+
const result = await repo.delete(Number(id));
|
|
234
|
+
if (result.affected === 0) return json({ message: "Not found" }, { status: 404 });
|
|
235
|
+
return json({ message: "Deleted successfully" }, { status: 200 });
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// src/api/auth-handlers.ts
|
|
241
|
+
function createForgotPasswordHandler(config) {
|
|
242
|
+
const { dataSource, entityMap, json, baseUrl, sendEmail, resetExpiryHours = 1, afterCreateToken } = config;
|
|
243
|
+
return async function POST(request) {
|
|
244
|
+
try {
|
|
245
|
+
const body = await request.json().catch(() => ({}));
|
|
246
|
+
const email = typeof body?.email === "string" ? body.email.trim().toLowerCase() : "";
|
|
247
|
+
if (!email) return json({ error: "Email is required" }, { status: 400 });
|
|
248
|
+
const userRepo = dataSource.getRepository(entityMap.users);
|
|
249
|
+
const user = await userRepo.findOne({ where: { email }, select: ["email"] });
|
|
250
|
+
const msg = "If an account exists with this email, you will receive a reset link shortly.";
|
|
251
|
+
if (!user) return json({ message: msg }, { status: 200 });
|
|
252
|
+
const crypto = await import("crypto");
|
|
253
|
+
const token = crypto.randomBytes(32).toString("hex");
|
|
254
|
+
const expiresAt = new Date(Date.now() + resetExpiryHours * 60 * 60 * 1e3);
|
|
255
|
+
const tokenRepo = dataSource.getRepository(entityMap.password_reset_tokens);
|
|
256
|
+
await tokenRepo.save(tokenRepo.create({ email: user.email, token, expiresAt }));
|
|
257
|
+
const resetLink = `${baseUrl}/admin/reset-password?token=${token}`;
|
|
258
|
+
if (sendEmail) await sendEmail({ to: user.email, subject: "Password reset", html: `<a href="${resetLink}">Reset password</a>`, text: resetLink });
|
|
259
|
+
if (afterCreateToken) await afterCreateToken(user.email, resetLink);
|
|
260
|
+
return json({ message: msg }, { status: 200 });
|
|
261
|
+
} catch (err) {
|
|
262
|
+
return json({ error: "Something went wrong. Please try again." }, { status: 500 });
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
function createSetPasswordHandler(config) {
|
|
267
|
+
const { dataSource, entityMap, json, hashPassword, minPasswordLength = 6, beforeUpdate } = config;
|
|
268
|
+
return async function POST(request) {
|
|
269
|
+
try {
|
|
270
|
+
const body = await request.json().catch(() => ({}));
|
|
271
|
+
const { token, newPassword } = body;
|
|
272
|
+
if (!token || !newPassword) return json({ error: "Token and new password are required" }, { status: 400 });
|
|
273
|
+
if (newPassword.length < minPasswordLength) return json({ error: "Password must be at least 6 characters" }, { status: 400 });
|
|
274
|
+
const tokenRepo = dataSource.getRepository(entityMap.password_reset_tokens);
|
|
275
|
+
const record = await tokenRepo.findOne({ where: { token } });
|
|
276
|
+
if (!record || record.expiresAt < /* @__PURE__ */ new Date()) return json({ error: "Invalid or expired reset link. Please request a new one." }, { status: 400 });
|
|
277
|
+
const userRepo = dataSource.getRepository(entityMap.users);
|
|
278
|
+
const user = await userRepo.findOne({ where: { email: record.email }, select: ["id"] });
|
|
279
|
+
if (!user) return json({ error: "User not found" }, { status: 400 });
|
|
280
|
+
if (beforeUpdate) await beforeUpdate(record.email, user.id);
|
|
281
|
+
const hashedPassword = await hashPassword(newPassword);
|
|
282
|
+
await userRepo.update(user.id, { password: hashedPassword, updatedAt: /* @__PURE__ */ new Date() });
|
|
283
|
+
await tokenRepo.delete({ email: record.email });
|
|
284
|
+
return json({ message: "Password updated successfully. You can now sign in." });
|
|
285
|
+
} catch {
|
|
286
|
+
return json({ error: "Something went wrong. Please try again." }, { status: 500 });
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
function createInviteAcceptHandler(config) {
|
|
291
|
+
const { dataSource, entityMap, json, hashPassword, beforeActivate } = config;
|
|
292
|
+
return async function POST(request) {
|
|
293
|
+
try {
|
|
294
|
+
const body = await request.json().catch(() => ({}));
|
|
295
|
+
const { token, password } = body;
|
|
296
|
+
if (!token || !password) return json({ error: "Missing required fields: token, password" }, { status: 400 });
|
|
297
|
+
let email;
|
|
298
|
+
try {
|
|
299
|
+
email = Buffer.from(token, "base64").toString("utf8");
|
|
300
|
+
} catch {
|
|
301
|
+
return json({ error: "Invalid or expired invite token" }, { status: 400 });
|
|
302
|
+
}
|
|
303
|
+
const userRepo = dataSource.getRepository(entityMap.users);
|
|
304
|
+
const user = await userRepo.findOne({ where: { email }, select: ["id", "blocked"] });
|
|
305
|
+
if (!user) return json({ error: "User not found" }, { status: 400 });
|
|
306
|
+
if (!user.blocked) return json({ error: "User is already active" }, { status: 400 });
|
|
307
|
+
if (beforeActivate) await beforeActivate(email, user.id);
|
|
308
|
+
const hashedPassword = await hashPassword(password);
|
|
309
|
+
await userRepo.update(user.id, { password: hashedPassword, blocked: false });
|
|
310
|
+
return json({ message: "User account activated successfully" }, { status: 200 });
|
|
311
|
+
} catch (err) {
|
|
312
|
+
return json({ error: "Server Error" }, { status: 500 });
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
function createChangePasswordHandler(config) {
|
|
317
|
+
const { dataSource, entityMap, json, comparePassword, hashPassword, getSession, minPasswordLength = 6, beforeUpdate } = config;
|
|
318
|
+
return async function POST(request) {
|
|
319
|
+
try {
|
|
320
|
+
const session = await getSession();
|
|
321
|
+
if (!session?.user?.email) return json({ error: "Unauthorized" }, { status: 401 });
|
|
322
|
+
const body = await request.json().catch(() => ({}));
|
|
323
|
+
const { currentPassword, newPassword } = body;
|
|
324
|
+
if (!currentPassword || !newPassword) return json({ error: "Current password and new password are required" }, { status: 400 });
|
|
325
|
+
if (newPassword.length < minPasswordLength) return json({ error: "New password must be at least 6 characters long" }, { status: 400 });
|
|
326
|
+
const userRepo = dataSource.getRepository(entityMap.users);
|
|
327
|
+
const user = await userRepo.findOne({ where: { email: session.user.email }, select: ["password"] });
|
|
328
|
+
if (!user) return json({ error: "User not found" }, { status: 404 });
|
|
329
|
+
if (!user.password) return json({ error: "Current password is incorrect" }, { status: 400 });
|
|
330
|
+
const valid = await comparePassword(currentPassword, user.password);
|
|
331
|
+
if (!valid) return json({ error: "Current password is incorrect" }, { status: 400 });
|
|
332
|
+
if (beforeUpdate) await beforeUpdate(session.user.email);
|
|
333
|
+
const hashedPassword = await hashPassword(newPassword);
|
|
334
|
+
await userRepo.update({ email: session.user.email }, { password: hashedPassword, updatedAt: /* @__PURE__ */ new Date() });
|
|
335
|
+
return json({ message: "Password updated successfully" });
|
|
336
|
+
} catch {
|
|
337
|
+
return json({ error: "Internal server error" }, { status: 500 });
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
var USER_AUTH_PATHS = ["forgot-password", "invite", "set-password", "reset-password"];
|
|
342
|
+
function createUserAuthApiRouter(config) {
|
|
343
|
+
const forgot = createForgotPasswordHandler(config);
|
|
344
|
+
const setPass = createSetPasswordHandler(config);
|
|
345
|
+
const invite = createInviteAcceptHandler(config);
|
|
346
|
+
const changePass = config.getSession ? createChangePasswordHandler({
|
|
347
|
+
...config,
|
|
348
|
+
getSession: config.getSession,
|
|
349
|
+
beforeUpdate: config.beforeChangePasswordUpdate
|
|
350
|
+
}) : null;
|
|
351
|
+
return {
|
|
352
|
+
async POST(req, pathname) {
|
|
353
|
+
const path = pathname.replace(/\/$/, "");
|
|
354
|
+
if (!USER_AUTH_PATHS.includes(path)) {
|
|
355
|
+
return config.json({ error: "Not found" }, { status: 404 });
|
|
356
|
+
}
|
|
357
|
+
if (path === "forgot-password") return forgot(req);
|
|
358
|
+
if (path === "set-password") return setPass(req);
|
|
359
|
+
if (path === "invite") return invite(req);
|
|
360
|
+
if (path === "reset-password" && changePass) return changePass(req);
|
|
361
|
+
return config.json({ error: "Not found" }, { status: 404 });
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// src/api/cms-handlers.ts
|
|
367
|
+
import { MoreThanOrEqual, ILike as ILike2 } from "typeorm";
|
|
368
|
+
function createDashboardStatsHandler(config) {
|
|
369
|
+
const { dataSource, entityMap, json, requireAuth, requirePermission } = config;
|
|
370
|
+
return async function GET(req) {
|
|
371
|
+
const authErr = await requireAuth(req);
|
|
372
|
+
if (authErr) return authErr;
|
|
373
|
+
if (requirePermission) {
|
|
374
|
+
const permErr = await requirePermission(req, "view_dashboard");
|
|
375
|
+
if (permErr) return permErr;
|
|
376
|
+
}
|
|
377
|
+
try {
|
|
378
|
+
const sevenDaysAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1e3);
|
|
379
|
+
const repo = (name) => entityMap[name] ? dataSource.getRepository(entityMap[name]) : void 0;
|
|
380
|
+
const [contactsCount, formsCount, formSubmissionsCount, usersCount, blogsCount, recentContacts, recentSubmissions] = await Promise.all([
|
|
381
|
+
repo("contacts")?.count() ?? 0,
|
|
382
|
+
repo("forms")?.count({ where: { deleted: false } }) ?? 0,
|
|
383
|
+
repo("form_submissions")?.count() ?? 0,
|
|
384
|
+
repo("users")?.count({ where: { deleted: false } }) ?? 0,
|
|
385
|
+
repo("blogs")?.count({ where: { deleted: false } }) ?? 0,
|
|
386
|
+
repo("contacts")?.count({ where: { createdAt: MoreThanOrEqual(sevenDaysAgo) } }) ?? 0,
|
|
387
|
+
repo("form_submissions")?.count({ where: { createdAt: MoreThanOrEqual(sevenDaysAgo) } }) ?? 0
|
|
388
|
+
]);
|
|
389
|
+
return json({
|
|
390
|
+
contacts: { total: contactsCount, recent: recentContacts },
|
|
391
|
+
forms: { total: formsCount, submissions: formSubmissionsCount, recentSubmissions },
|
|
392
|
+
users: usersCount,
|
|
393
|
+
blogs: blogsCount
|
|
394
|
+
});
|
|
395
|
+
} catch (err) {
|
|
396
|
+
return json({ error: "Failed to fetch dashboard stats" }, { status: 500 });
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
function createAnalyticsHandlers(config) {
|
|
401
|
+
const { json, getAnalyticsData, getPropertyId, getPermissions } = config;
|
|
402
|
+
return {
|
|
403
|
+
async GET(req) {
|
|
404
|
+
if (!getAnalyticsData) return json({ error: "Analytics not configured" }, { status: 404 });
|
|
405
|
+
try {
|
|
406
|
+
const url = new URL(req.url);
|
|
407
|
+
const days = parseInt(url.searchParams.get("days") || "30", 10);
|
|
408
|
+
const data = await getAnalyticsData(days);
|
|
409
|
+
return json(data);
|
|
410
|
+
} catch (err) {
|
|
411
|
+
const msg = err instanceof Error ? err.message : "";
|
|
412
|
+
if (msg.includes("authentication credential")) return json({ error: "Google Analytics authentication failed." }, { status: 401 });
|
|
413
|
+
if (msg.includes("sufficient permissions")) return json({ error: "Service account does not have access." }, { status: 403 });
|
|
414
|
+
return json({ error: "Failed to fetch analytics data" }, { status: 500 });
|
|
415
|
+
}
|
|
416
|
+
},
|
|
417
|
+
propertyId: async () => {
|
|
418
|
+
const payload = getPropertyId ? getPropertyId() : { currentViewId: process.env.GOOGLE_ANALYTICS_VIEW_ID };
|
|
419
|
+
return json({ message: "Property ID Information", ...payload });
|
|
420
|
+
},
|
|
421
|
+
permissions: async () => {
|
|
422
|
+
const payload = getPermissions ? getPermissions() : {
|
|
423
|
+
serviceAccountEmail: process.env.GOOGLE_ANALYTICS_CLIENT_EMAIL,
|
|
424
|
+
currentViewId: process.env.GOOGLE_ANALYTICS_VIEW_ID
|
|
425
|
+
};
|
|
426
|
+
return json({ message: "Permission Troubleshooting Guide", ...payload });
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
function createUploadHandler(config) {
|
|
431
|
+
const { json, requireAuth, storage, localUploadDir = "public/uploads", allowedTypes, maxSizeBytes = 10 * 1024 * 1024 } = config;
|
|
432
|
+
const allowed = allowedTypes ?? ["image/jpeg", "image/png", "image/gif", "image/webp", "application/pdf", "text/plain"];
|
|
433
|
+
return async function POST(req) {
|
|
434
|
+
const authErr = await requireAuth(req);
|
|
435
|
+
if (authErr) return authErr;
|
|
436
|
+
try {
|
|
437
|
+
const formData = await req.formData();
|
|
438
|
+
const file = formData.get("file");
|
|
439
|
+
if (!file) return json({ error: "No file uploaded" }, { status: 400 });
|
|
440
|
+
if (!allowed.includes(file.type)) return json({ error: "File type not allowed" }, { status: 400 });
|
|
441
|
+
if (file.size > maxSizeBytes) return json({ error: "File size exceeds limit" }, { status: 400 });
|
|
442
|
+
const buffer = Buffer.from(await file.arrayBuffer());
|
|
443
|
+
const fileName = `${Date.now()}-${file.name}`;
|
|
444
|
+
const contentType = file.type || "application/octet-stream";
|
|
445
|
+
const raw = typeof storage === "function" ? storage() : storage;
|
|
446
|
+
const storageService = raw instanceof Promise ? await raw : raw;
|
|
447
|
+
if (storageService) {
|
|
448
|
+
const fileUrl = await storageService.upload(buffer, `uploads/${fileName}`, contentType);
|
|
449
|
+
return json({ filePath: fileUrl });
|
|
450
|
+
}
|
|
451
|
+
const fs = await import("fs/promises");
|
|
452
|
+
const path = await import("path");
|
|
453
|
+
const dir = path.join(process.cwd(), localUploadDir);
|
|
454
|
+
await fs.mkdir(dir, { recursive: true });
|
|
455
|
+
const filePath = path.join(dir, fileName);
|
|
456
|
+
await fs.writeFile(filePath, buffer);
|
|
457
|
+
return json({ filePath: `/${localUploadDir.replace(/^\/+/, "").replace(/\\/g, "/")}/${fileName}` });
|
|
458
|
+
} catch (err) {
|
|
459
|
+
return json({ error: "File upload failed" }, { status: 500 });
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
function createBlogBySlugHandler(config) {
|
|
464
|
+
const { dataSource, entityMap, json } = config;
|
|
465
|
+
return async function GET(_req, slug) {
|
|
466
|
+
try {
|
|
467
|
+
const blogRepo = dataSource.getRepository(entityMap.blogs);
|
|
468
|
+
const blog = await blogRepo.findOne({
|
|
469
|
+
where: { slug, published: true },
|
|
470
|
+
relations: ["author", "category", "tags", "seo"]
|
|
471
|
+
});
|
|
472
|
+
if (!blog) return json({ error: "Blog not found" }, { status: 404 });
|
|
473
|
+
return json(blog);
|
|
474
|
+
} catch {
|
|
475
|
+
return json({ error: "Server Error" }, { status: 500 });
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
function createFormBySlugHandler(config) {
|
|
480
|
+
const { dataSource, entityMap, json } = config;
|
|
481
|
+
return async function GET(_req, slug) {
|
|
482
|
+
try {
|
|
483
|
+
const formRepo = dataSource.getRepository(entityMap.forms);
|
|
484
|
+
const form = await formRepo.findOne({
|
|
485
|
+
where: { slug, published: true, deleted: false },
|
|
486
|
+
relations: ["fields"],
|
|
487
|
+
order: { fields: { order: "ASC" } }
|
|
488
|
+
});
|
|
489
|
+
if (!form) return json({ error: "Form not found" }, { status: 404 });
|
|
490
|
+
const out = form;
|
|
491
|
+
if (Array.isArray(out.fields)) out.fields = out.fields.filter((f) => !f.deleted);
|
|
492
|
+
return json(form);
|
|
493
|
+
} catch {
|
|
494
|
+
return json({ error: "Server Error" }, { status: 500 });
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
function normalizeFieldRow(f, formId) {
|
|
499
|
+
const order = typeof f.order === "number" ? f.order : Number(f.order) || 0;
|
|
500
|
+
const groupId = typeof f.groupId === "number" ? f.groupId : Number(f.groupId) || 1;
|
|
501
|
+
const columnWidth = typeof f.columnWidth === "number" ? f.columnWidth : Number(f.columnWidth) || 12;
|
|
502
|
+
return {
|
|
503
|
+
formId,
|
|
504
|
+
label: f.label != null ? String(f.label) : "",
|
|
505
|
+
type: f.type != null ? String(f.type) : "text",
|
|
506
|
+
placeholder: f.placeholder != null ? String(f.placeholder) : null,
|
|
507
|
+
options: f.options != null ? typeof f.options === "string" ? f.options : JSON.stringify(f.options) : null,
|
|
508
|
+
required: Boolean(f.required),
|
|
509
|
+
validation: f.validation != null ? typeof f.validation === "string" ? f.validation : JSON.stringify(f.validation) : null,
|
|
510
|
+
order,
|
|
511
|
+
groupId,
|
|
512
|
+
columnWidth
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
function createFormSaveHandlers(config) {
|
|
516
|
+
const { dataSource, entityMap, json, requireAuth } = config;
|
|
517
|
+
const formRepo = () => dataSource.getRepository(entityMap.forms);
|
|
518
|
+
const fieldRepo = () => dataSource.getRepository(entityMap.form_fields);
|
|
519
|
+
return {
|
|
520
|
+
async GET(req, id) {
|
|
521
|
+
const authErr = await requireAuth(req);
|
|
522
|
+
if (authErr) return authErr;
|
|
523
|
+
try {
|
|
524
|
+
const formId = Number(id);
|
|
525
|
+
if (!Number.isInteger(formId) || formId <= 0) return json({ error: "Invalid form id" }, { status: 400 });
|
|
526
|
+
const form = await formRepo().findOne({
|
|
527
|
+
where: { id: formId },
|
|
528
|
+
relations: ["fields"],
|
|
529
|
+
order: { fields: { order: "ASC" } }
|
|
530
|
+
});
|
|
531
|
+
if (!form) return json({ message: "Not found" }, { status: 404 });
|
|
532
|
+
const out = form;
|
|
533
|
+
if (Array.isArray(out.fields)) out.fields = out.fields.filter((f) => !f.deleted);
|
|
534
|
+
return json(form);
|
|
535
|
+
} catch {
|
|
536
|
+
return json({ error: "Server Error" }, { status: 500 });
|
|
537
|
+
}
|
|
538
|
+
},
|
|
539
|
+
async POST(req) {
|
|
540
|
+
const authErr = await requireAuth(req);
|
|
541
|
+
if (authErr) return authErr;
|
|
542
|
+
try {
|
|
543
|
+
const body = await req.json();
|
|
544
|
+
if (!body || typeof body !== "object") return json({ error: "Invalid request payload" }, { status: 400 });
|
|
545
|
+
const fields = Array.isArray(body.fields) ? body.fields : [];
|
|
546
|
+
const { fields: _f, ...formRow } = body;
|
|
547
|
+
const form = await formRepo().save(formRepo().create(formRow));
|
|
548
|
+
for (let i = 0; i < fields.length; i++) {
|
|
549
|
+
const row = normalizeFieldRow(fields[i], form.id);
|
|
550
|
+
row.order = i + 1;
|
|
551
|
+
await fieldRepo().save(fieldRepo().create(row));
|
|
552
|
+
}
|
|
553
|
+
const saved = await formRepo().findOne({ where: { id: form.id }, relations: ["fields"], order: { fields: { order: "ASC" } } });
|
|
554
|
+
return json(saved ?? form, { status: 201 });
|
|
555
|
+
} catch (e) {
|
|
556
|
+
return json({ error: "Server Error" }, { status: 500 });
|
|
557
|
+
}
|
|
558
|
+
},
|
|
559
|
+
async PUT(req, id) {
|
|
560
|
+
const authErr = await requireAuth(req);
|
|
561
|
+
if (authErr) return authErr;
|
|
562
|
+
try {
|
|
563
|
+
const formId = Number(id);
|
|
564
|
+
if (!Number.isInteger(formId) || formId <= 0) return json({ error: "Invalid form id" }, { status: 400 });
|
|
565
|
+
const body = await req.json();
|
|
566
|
+
if (!body || typeof body !== "object") return json({ error: "Invalid request payload" }, { status: 400 });
|
|
567
|
+
const existing = await formRepo().findOne({ where: { id: formId } });
|
|
568
|
+
if (!existing) return json({ message: "Not found" }, { status: 404 });
|
|
569
|
+
const fields = Array.isArray(body.fields) ? body.fields : [];
|
|
570
|
+
const formRow = {};
|
|
571
|
+
for (const key of ["name", "description", "campaign", "slug", "published"]) {
|
|
572
|
+
if (body[key] !== void 0) formRow[key] = body[key];
|
|
573
|
+
}
|
|
574
|
+
if (Object.keys(formRow).length > 0) await formRepo().update(formId, formRow);
|
|
575
|
+
await fieldRepo().delete({ formId });
|
|
576
|
+
for (let i = 0; i < fields.length; i++) {
|
|
577
|
+
const row = normalizeFieldRow(fields[i], formId);
|
|
578
|
+
row.order = i + 1;
|
|
579
|
+
await fieldRepo().save(fieldRepo().create(row));
|
|
580
|
+
}
|
|
581
|
+
const saved = await formRepo().findOne({ where: { id: formId }, relations: ["fields"], order: { fields: { order: "ASC" } } });
|
|
582
|
+
return saved ? json(saved) : json({ message: "Not found" }, { status: 404 });
|
|
583
|
+
} catch (e) {
|
|
584
|
+
return json({ error: "Server Error" }, { status: 500 });
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
function createFormSubmissionGetByIdHandler(config) {
|
|
590
|
+
const { dataSource, entityMap, json, requireAuth } = config;
|
|
591
|
+
return async function GET(req, id) {
|
|
592
|
+
const authErr = await requireAuth(req);
|
|
593
|
+
if (authErr) return authErr;
|
|
594
|
+
try {
|
|
595
|
+
const submissionId = Number(id);
|
|
596
|
+
if (!Number.isInteger(submissionId) || submissionId <= 0) return json({ error: "Invalid id" }, { status: 400 });
|
|
597
|
+
const repo = dataSource.getRepository(entityMap.form_submissions);
|
|
598
|
+
const submission = await repo.findOne({
|
|
599
|
+
where: { id: submissionId },
|
|
600
|
+
relations: ["form", "contact"]
|
|
601
|
+
});
|
|
602
|
+
if (!submission) return json({ message: "Not found" }, { status: 404 });
|
|
603
|
+
const form = submission;
|
|
604
|
+
if (form.form?.id) {
|
|
605
|
+
const formRepo = dataSource.getRepository(entityMap.forms);
|
|
606
|
+
const formWithFields = await formRepo.findOne({
|
|
607
|
+
where: { id: form.form.id },
|
|
608
|
+
relations: ["fields"],
|
|
609
|
+
order: { fields: { order: "ASC" } }
|
|
610
|
+
});
|
|
611
|
+
if (formWithFields) submission.form = formWithFields;
|
|
612
|
+
}
|
|
613
|
+
return json(submission);
|
|
614
|
+
} catch {
|
|
615
|
+
return json({ error: "Server Error" }, { status: 500 });
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
function createFormSubmissionListHandler(config) {
|
|
620
|
+
const { dataSource, entityMap, json, requireAuth } = config;
|
|
621
|
+
return async function GET(req) {
|
|
622
|
+
const authErr = await requireAuth(req);
|
|
623
|
+
if (authErr) return authErr;
|
|
624
|
+
try {
|
|
625
|
+
const repo = dataSource.getRepository(entityMap.form_submissions);
|
|
626
|
+
const { searchParams } = new URL(req.url);
|
|
627
|
+
const page = Number(searchParams.get("page")) || 1;
|
|
628
|
+
const limit = Math.min(100, Number(searchParams.get("limit")) || 10);
|
|
629
|
+
const skip = (page - 1) * limit;
|
|
630
|
+
const sortField = searchParams.get("sortField") || "createdAt";
|
|
631
|
+
const sortOrder = searchParams.get("sortOrder") === "desc" ? "DESC" : "ASC";
|
|
632
|
+
const [data, total] = await repo.findAndCount({
|
|
633
|
+
skip,
|
|
634
|
+
take: limit,
|
|
635
|
+
order: { [sortField]: sortOrder },
|
|
636
|
+
relations: ["form", "contact"]
|
|
637
|
+
});
|
|
638
|
+
return json({ total, page, limit, totalPages: Math.ceil(total / limit), data });
|
|
639
|
+
} catch {
|
|
640
|
+
return json({ error: "Server Error" }, { status: 500 });
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
function pickContactFromSubmission(fields, data) {
|
|
645
|
+
let email = null;
|
|
646
|
+
let name = null;
|
|
647
|
+
let phone = null;
|
|
648
|
+
for (const f of fields) {
|
|
649
|
+
const val = data[String(f.id)];
|
|
650
|
+
if (val == null || val === "") continue;
|
|
651
|
+
const str = String(val).trim();
|
|
652
|
+
if (f.type === "email" || f.label && f.label.toLowerCase().includes("email")) {
|
|
653
|
+
if (str && !email) email = str;
|
|
654
|
+
} else if (f.type === "phone" || f.label && f.label.toLowerCase().includes("phone")) {
|
|
655
|
+
if (str && !phone) phone = str;
|
|
656
|
+
} else if (f.label && f.label.toLowerCase().includes("name") && (f.type === "text" || !f.type)) {
|
|
657
|
+
if (str && !name) name = str;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
if (!email) return null;
|
|
661
|
+
return { name: name || email, email, phone: phone || null };
|
|
662
|
+
}
|
|
663
|
+
function createFormSubmissionHandler(config) {
|
|
664
|
+
const { dataSource, entityMap, json } = config;
|
|
665
|
+
return async function POST(req) {
|
|
666
|
+
try {
|
|
667
|
+
const body = await req.json();
|
|
668
|
+
if (!body || typeof body !== "object") {
|
|
669
|
+
return json({ error: "Invalid request payload" }, { status: 400 });
|
|
670
|
+
}
|
|
671
|
+
const formId = typeof body.formId === "number" ? body.formId : Number(body.formId);
|
|
672
|
+
if (!Number.isInteger(formId) || formId <= 0) {
|
|
673
|
+
return json({ error: "formId is required and must be a positive integer" }, { status: 400 });
|
|
674
|
+
}
|
|
675
|
+
const data = body.data;
|
|
676
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
677
|
+
return json({ error: "data is required and must be an object" }, { status: 400 });
|
|
678
|
+
}
|
|
679
|
+
const formRepo = dataSource.getRepository(entityMap.forms);
|
|
680
|
+
const form = await formRepo.findOne({
|
|
681
|
+
where: { id: formId, published: true, deleted: false },
|
|
682
|
+
relations: ["fields"]
|
|
683
|
+
});
|
|
684
|
+
if (!form) {
|
|
685
|
+
return json({ error: "Form not found" }, { status: 404 });
|
|
686
|
+
}
|
|
687
|
+
const fields = form.fields ?? [];
|
|
688
|
+
const activeFields = fields.filter((f) => !f.deleted);
|
|
689
|
+
let contactId = body.contactId != null && body.contactId !== "" ? typeof body.contactId === "number" ? body.contactId : Number(body.contactId) : null;
|
|
690
|
+
if (!contactId) {
|
|
691
|
+
const contactData = pickContactFromSubmission(activeFields, data);
|
|
692
|
+
if (contactData) {
|
|
693
|
+
const contactRepo = dataSource.getRepository(entityMap.contacts);
|
|
694
|
+
let contact = await contactRepo.findOne({ where: { email: contactData.email } });
|
|
695
|
+
if (!contact) {
|
|
696
|
+
contact = await contactRepo.save(
|
|
697
|
+
contactRepo.create({
|
|
698
|
+
name: contactData.name,
|
|
699
|
+
email: contactData.email,
|
|
700
|
+
phone: contactData.phone
|
|
701
|
+
})
|
|
702
|
+
);
|
|
703
|
+
}
|
|
704
|
+
contactId = contact.id;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
const ipAddress = req.headers.get("x-forwarded-for") ?? req.headers.get("x-real-ip") ?? null;
|
|
708
|
+
const userAgent = req.headers.get("user-agent") ?? null;
|
|
709
|
+
const submissionRepo = dataSource.getRepository(entityMap.form_submissions);
|
|
710
|
+
const created = await submissionRepo.save(
|
|
711
|
+
submissionRepo.create({
|
|
712
|
+
formId,
|
|
713
|
+
contactId: Number.isInteger(contactId) ? contactId : null,
|
|
714
|
+
data,
|
|
715
|
+
ipAddress: ipAddress?.slice(0, 255) ?? null,
|
|
716
|
+
userAgent: userAgent?.slice(0, 500) ?? null
|
|
717
|
+
})
|
|
718
|
+
);
|
|
719
|
+
return json(created, { status: 201 });
|
|
720
|
+
} catch {
|
|
721
|
+
return json({ error: "Server Error" }, { status: 500 });
|
|
722
|
+
}
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
function createUsersApiHandlers(config) {
|
|
726
|
+
const { dataSource, entityMap, json, requireAuth, baseUrl } = config;
|
|
727
|
+
const userRepo = () => dataSource.getRepository(entityMap.users);
|
|
728
|
+
return {
|
|
729
|
+
async list(req) {
|
|
730
|
+
const authErr = await requireAuth(req);
|
|
731
|
+
if (authErr) return authErr;
|
|
732
|
+
try {
|
|
733
|
+
const url = new URL(req.url);
|
|
734
|
+
const page = Math.max(1, parseInt(url.searchParams.get("page") || "1", 10));
|
|
735
|
+
const limit = Math.min(100, parseInt(url.searchParams.get("limit") || "10", 10));
|
|
736
|
+
const skip = (page - 1) * limit;
|
|
737
|
+
const sortField = url.searchParams.get("sortField") || "createdAt";
|
|
738
|
+
const sortOrder = url.searchParams.get("sortOrder") === "desc" ? "DESC" : "ASC";
|
|
739
|
+
const search = url.searchParams.get("search");
|
|
740
|
+
const where = search ? [{ name: ILike2(`%${search}%`) }, { email: ILike2(`%${search}%`) }] : {};
|
|
741
|
+
const [data, total] = await userRepo().findAndCount({
|
|
742
|
+
skip,
|
|
743
|
+
take: limit,
|
|
744
|
+
order: { [sortField]: sortOrder },
|
|
745
|
+
where,
|
|
746
|
+
relations: ["group"],
|
|
747
|
+
select: ["id", "name", "email", "blocked", "createdAt", "updatedAt", "groupId"]
|
|
748
|
+
});
|
|
749
|
+
return json({ total, page, limit, totalPages: Math.ceil(total / limit), data });
|
|
750
|
+
} catch {
|
|
751
|
+
return json({ error: "Server Error" }, { status: 500 });
|
|
752
|
+
}
|
|
753
|
+
},
|
|
754
|
+
async create(req) {
|
|
755
|
+
const authErr = await requireAuth(req);
|
|
756
|
+
if (authErr) return authErr;
|
|
757
|
+
try {
|
|
758
|
+
const body = await req.json();
|
|
759
|
+
if (!body?.name || !body?.email) return json({ error: "Name and email are required" }, { status: 400 });
|
|
760
|
+
const existing = await userRepo().findOne({ where: { email: body.email } });
|
|
761
|
+
if (existing) return json({ error: "User with this email already exists" }, { status: 400 });
|
|
762
|
+
const newUser = await userRepo().save(
|
|
763
|
+
userRepo().create({ name: body.name, email: body.email, password: null, blocked: true, groupId: body.groupId ?? null })
|
|
764
|
+
);
|
|
765
|
+
const emailToken = Buffer.from(newUser.email).toString("base64");
|
|
766
|
+
const inviteLink = `${baseUrl}/admin/invite?token=${emailToken}`;
|
|
767
|
+
return json({ message: "User created successfully (blocked until password is set)", user: newUser, inviteLink }, { status: 201 });
|
|
768
|
+
} catch {
|
|
769
|
+
return json({ error: "Server Error" }, { status: 500 });
|
|
770
|
+
}
|
|
771
|
+
},
|
|
772
|
+
async getById(_req, id) {
|
|
773
|
+
const authErr = await requireAuth(new Request(_req.url));
|
|
774
|
+
if (authErr) return authErr;
|
|
775
|
+
try {
|
|
776
|
+
const user = await userRepo().findOne({
|
|
777
|
+
where: { id: parseInt(id, 10) },
|
|
778
|
+
relations: ["group"],
|
|
779
|
+
select: ["id", "name", "email", "blocked", "createdAt", "updatedAt", "groupId"]
|
|
780
|
+
});
|
|
781
|
+
if (!user) return json({ error: "User not found" }, { status: 404 });
|
|
782
|
+
return json(user);
|
|
783
|
+
} catch {
|
|
784
|
+
return json({ error: "Server Error" }, { status: 500 });
|
|
785
|
+
}
|
|
786
|
+
},
|
|
787
|
+
async update(req, id) {
|
|
788
|
+
const authErr = await requireAuth(req);
|
|
789
|
+
if (authErr) return authErr;
|
|
790
|
+
try {
|
|
791
|
+
const body = await req.json();
|
|
792
|
+
const { password: _p, ...safe } = body;
|
|
793
|
+
await userRepo().update(parseInt(id, 10), safe);
|
|
794
|
+
const updated = await userRepo().findOne({
|
|
795
|
+
where: { id: parseInt(id, 10) },
|
|
796
|
+
relations: ["group"],
|
|
797
|
+
select: ["id", "name", "email", "blocked", "createdAt", "updatedAt", "groupId"]
|
|
798
|
+
});
|
|
799
|
+
return updated ? json(updated) : json({ error: "Not found" }, { status: 404 });
|
|
800
|
+
} catch {
|
|
801
|
+
return json({ error: "Server Error" }, { status: 500 });
|
|
802
|
+
}
|
|
803
|
+
},
|
|
804
|
+
async delete(_req, id) {
|
|
805
|
+
const authErr = await requireAuth(new Request(_req.url));
|
|
806
|
+
if (authErr) return authErr;
|
|
807
|
+
try {
|
|
808
|
+
const r = await userRepo().delete(parseInt(id, 10));
|
|
809
|
+
if (r.affected === 0) return json({ error: "User not found" }, { status: 404 });
|
|
810
|
+
return json({ message: "User deleted successfully" });
|
|
811
|
+
} catch {
|
|
812
|
+
return json({ error: "Server Error" }, { status: 500 });
|
|
813
|
+
}
|
|
814
|
+
},
|
|
815
|
+
async regenerateInvite(_req, id) {
|
|
816
|
+
const authErr = await requireAuth(new Request(_req.url));
|
|
817
|
+
if (authErr) return authErr;
|
|
818
|
+
try {
|
|
819
|
+
const user = await userRepo().findOne({ where: { id: parseInt(id, 10) }, select: ["email"] });
|
|
820
|
+
if (!user) return json({ error: "User not found" }, { status: 404 });
|
|
821
|
+
const emailToken = Buffer.from(user.email).toString("base64");
|
|
822
|
+
const inviteLink = `${baseUrl}/admin/invite?token=${emailToken}`;
|
|
823
|
+
return json({ message: "New invite link generated successfully", inviteLink });
|
|
824
|
+
} catch {
|
|
825
|
+
return json({ error: "Server Error" }, { status: 500 });
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
function createUserAvatarHandler(config) {
|
|
831
|
+
const { json, getSession, saveAvatar } = config;
|
|
832
|
+
return async function POST(req) {
|
|
833
|
+
const session = await getSession();
|
|
834
|
+
if (!session?.user?.email) return json({ error: "Unauthorized" }, { status: 401 });
|
|
835
|
+
try {
|
|
836
|
+
const formData = await req.formData();
|
|
837
|
+
const file = formData.get("avatar");
|
|
838
|
+
if (!file) return json({ error: "No file uploaded" }, { status: 400 });
|
|
839
|
+
if (!file.type.startsWith("image/")) return json({ error: "File must be an image" }, { status: 400 });
|
|
840
|
+
if (file.size > 5 * 1024 * 1024) return json({ error: "File size must be less than 5MB" }, { status: 400 });
|
|
841
|
+
const buffer = Buffer.from(await file.arrayBuffer());
|
|
842
|
+
const ext = file.name.split(".").pop() || "jpg";
|
|
843
|
+
const fileName = `avatar_${session.user.email}_${Date.now()}.${ext}`;
|
|
844
|
+
const avatarUrl = saveAvatar ? await saveAvatar(buffer, fileName) : await (async () => {
|
|
845
|
+
const fs = await import("fs/promises");
|
|
846
|
+
const path = await import("path");
|
|
847
|
+
const dir = path.join(process.cwd(), "public", "uploads", "avatars");
|
|
848
|
+
await fs.mkdir(dir, { recursive: true });
|
|
849
|
+
await fs.writeFile(path.join(dir, fileName), buffer);
|
|
850
|
+
return `/uploads/avatars/${fileName}`;
|
|
851
|
+
})();
|
|
852
|
+
return json({ message: "Avatar uploaded successfully", avatarUrl });
|
|
853
|
+
} catch {
|
|
854
|
+
return json({ error: "Internal server error" }, { status: 500 });
|
|
855
|
+
}
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
function createUserProfileHandler(config) {
|
|
859
|
+
const { dataSource, entityMap, json, getSession } = config;
|
|
860
|
+
return async function PUT(req) {
|
|
861
|
+
const session = await getSession();
|
|
862
|
+
if (!session?.user?.email) return json({ error: "Unauthorized" }, { status: 401 });
|
|
863
|
+
try {
|
|
864
|
+
const body = await req.json();
|
|
865
|
+
if (!body?.name) return json({ error: "Name is required" }, { status: 400 });
|
|
866
|
+
const userRepo = dataSource.getRepository(entityMap.users);
|
|
867
|
+
await userRepo.update({ email: session.user.email }, { name: body.name, updatedAt: /* @__PURE__ */ new Date() });
|
|
868
|
+
const updated = await userRepo.findOne({ where: { email: session.user.email }, select: ["id", "name", "email"] });
|
|
869
|
+
if (!updated) return json({ error: "Not found" }, { status: 404 });
|
|
870
|
+
return json({ message: "Profile updated successfully", user: { id: updated.id, name: updated.name, email: updated.email } });
|
|
871
|
+
} catch {
|
|
872
|
+
return json({ error: "Internal server error" }, { status: 500 });
|
|
873
|
+
}
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
function simpleEncrypt(text, key) {
|
|
877
|
+
const buf = Buffer.from(text, "utf8");
|
|
878
|
+
const keyBuf = Buffer.from(key.padEnd(32, "0").slice(0, 32), "utf8");
|
|
879
|
+
const out = Buffer.alloc(buf.length);
|
|
880
|
+
for (let i = 0; i < buf.length; i++) out[i] = buf[i] ^ keyBuf[i % keyBuf.length];
|
|
881
|
+
return out.toString("base64");
|
|
882
|
+
}
|
|
883
|
+
function simpleDecrypt(encoded, key) {
|
|
884
|
+
const buf = Buffer.from(encoded, "base64");
|
|
885
|
+
const keyBuf = Buffer.from(key.padEnd(32, "0").slice(0, 32), "utf8");
|
|
886
|
+
const out = Buffer.alloc(buf.length);
|
|
887
|
+
for (let i = 0; i < buf.length; i++) out[i] = buf[i] ^ keyBuf[i % keyBuf.length];
|
|
888
|
+
return out.toString("utf8");
|
|
889
|
+
}
|
|
890
|
+
function createSettingsApiHandlers(config) {
|
|
891
|
+
const { dataSource, entityMap, json, requireAuth, encryptionKey, publicGetGroups } = config;
|
|
892
|
+
const configRepo = () => dataSource.getRepository(entityMap.configs);
|
|
893
|
+
return {
|
|
894
|
+
async GET(req, group) {
|
|
895
|
+
const isPublicGroup = publicGetGroups?.includes(group);
|
|
896
|
+
const authErr = isPublicGroup ? null : await requireAuth(req);
|
|
897
|
+
const isAuthed = !authErr;
|
|
898
|
+
try {
|
|
899
|
+
const where = { settings: group, deleted: false };
|
|
900
|
+
if (!isAuthed && !isPublicGroup) where.type = "public";
|
|
901
|
+
const rows = await configRepo().find({ where });
|
|
902
|
+
const result = {};
|
|
903
|
+
for (const row of rows) {
|
|
904
|
+
const r = row;
|
|
905
|
+
let val = r.value;
|
|
906
|
+
if (r.encrypted && encryptionKey) {
|
|
907
|
+
try {
|
|
908
|
+
val = simpleDecrypt(val, encryptionKey);
|
|
909
|
+
} catch {
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
result[r.key] = val;
|
|
913
|
+
}
|
|
914
|
+
return json(result);
|
|
915
|
+
} catch {
|
|
916
|
+
return json({ error: "Failed to fetch settings" }, { status: 500 });
|
|
917
|
+
}
|
|
918
|
+
},
|
|
919
|
+
async PUT(req, group) {
|
|
920
|
+
const authErr = await requireAuth(req);
|
|
921
|
+
if (authErr) return authErr;
|
|
922
|
+
try {
|
|
923
|
+
const body = await req.json();
|
|
924
|
+
if (!body || typeof body !== "object") return json({ error: "Invalid payload" }, { status: 400 });
|
|
925
|
+
const repo = configRepo();
|
|
926
|
+
for (const [key, entry] of Object.entries(body)) {
|
|
927
|
+
const val = typeof entry === "string" ? entry : entry.value;
|
|
928
|
+
const type = typeof entry === "object" && entry.type || "private";
|
|
929
|
+
const encrypted = !!(typeof entry === "object" && entry.encrypted);
|
|
930
|
+
let storedValue = val;
|
|
931
|
+
if (encrypted && encryptionKey) {
|
|
932
|
+
storedValue = simpleEncrypt(val, encryptionKey);
|
|
933
|
+
}
|
|
934
|
+
const existing = await repo.findOne({ where: { settings: group, key } });
|
|
935
|
+
if (existing) {
|
|
936
|
+
await repo.update(existing.id, { value: storedValue, type, encrypted, updatedAt: /* @__PURE__ */ new Date() });
|
|
937
|
+
} else {
|
|
938
|
+
await repo.save(repo.create({ settings: group, key, value: storedValue, type, encrypted }));
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
return json({ message: "Settings saved" });
|
|
942
|
+
} catch {
|
|
943
|
+
return json({ error: "Failed to save settings" }, { status: 500 });
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
// src/api/cms-api-handler.ts
|
|
950
|
+
var DEFAULT_EXCLUDE = /* @__PURE__ */ new Set(["users", "password_reset_tokens", "user_groups", "permissions", "comments", "form_fields", "configs"]);
|
|
951
|
+
function createCmsApiHandler(config) {
|
|
952
|
+
const {
|
|
953
|
+
dataSource,
|
|
954
|
+
entityMap,
|
|
955
|
+
pathToModel = (s) => s,
|
|
956
|
+
crudResources = Object.keys(entityMap).filter((k) => !DEFAULT_EXCLUDE.has(k)),
|
|
957
|
+
getCms,
|
|
958
|
+
userAuth: userAuthConfig,
|
|
959
|
+
dashboard,
|
|
960
|
+
analytics: analyticsConfig,
|
|
961
|
+
upload,
|
|
962
|
+
blogBySlug,
|
|
963
|
+
formBySlug,
|
|
964
|
+
formSave: formSaveConfig,
|
|
965
|
+
formSubmission: formSubmissionConfig,
|
|
966
|
+
formSubmissionGetById: formSubmissionGetByIdConfig,
|
|
967
|
+
usersApi,
|
|
968
|
+
userAvatar,
|
|
969
|
+
userProfile,
|
|
970
|
+
settings: settingsConfig
|
|
971
|
+
} = config;
|
|
972
|
+
const analytics = analyticsConfig ?? (getCms ? {
|
|
973
|
+
json: config.json,
|
|
974
|
+
requireAuth: async () => null,
|
|
975
|
+
getAnalyticsData: async (days) => {
|
|
976
|
+
const cms = await getCms();
|
|
977
|
+
const a = cms.getPlugin("analytics");
|
|
978
|
+
if (!a?.getAnalyticsData) throw new Error("Analytics not configured");
|
|
979
|
+
return a.getAnalyticsData(days);
|
|
980
|
+
},
|
|
981
|
+
getPropertyId: () => ({ currentViewId: process.env.GOOGLE_ANALYTICS_VIEW_ID }),
|
|
982
|
+
getPermissions: () => ({
|
|
983
|
+
serviceAccountEmail: process.env.GOOGLE_ANALYTICS_CLIENT_EMAIL,
|
|
984
|
+
currentViewId: process.env.GOOGLE_ANALYTICS_VIEW_ID
|
|
985
|
+
})
|
|
986
|
+
} : void 0);
|
|
987
|
+
const userAuth = userAuthConfig && getCms && userAuthConfig.sendEmail === void 0 ? {
|
|
988
|
+
...userAuthConfig,
|
|
989
|
+
sendEmail: async (opts) => {
|
|
990
|
+
const cms = await getCms();
|
|
991
|
+
const email = cms.getPlugin("email");
|
|
992
|
+
if (!email?.send) return;
|
|
993
|
+
const { emailTemplates: emailTemplates2 } = await Promise.resolve().then(() => (init_email_service(), email_service_exports));
|
|
994
|
+
const { subject, html, text } = emailTemplates2.passwordReset({ resetLink: opts.text || opts.html });
|
|
995
|
+
await email.send({ subject, html, text, to: opts.to });
|
|
996
|
+
}
|
|
997
|
+
} : userAuthConfig;
|
|
998
|
+
const crudOpts = { requireAuth: config.requireAuth, json: config.json };
|
|
999
|
+
const crud = createCrudHandler(dataSource, entityMap, crudOpts);
|
|
1000
|
+
const crudById = createCrudByIdHandler(dataSource, entityMap, crudOpts);
|
|
1001
|
+
const userAuthRouter = userAuth ? createUserAuthApiRouter(userAuth) : null;
|
|
1002
|
+
const dashboardGet = dashboard ? createDashboardStatsHandler(dashboard) : null;
|
|
1003
|
+
const analyticsHandlers = analytics ? createAnalyticsHandlers(analytics) : null;
|
|
1004
|
+
const uploadPost = upload ? createUploadHandler(upload) : null;
|
|
1005
|
+
const blogBySlugGet = blogBySlug ? createBlogBySlugHandler(blogBySlug) : null;
|
|
1006
|
+
const formBySlugGet = formBySlug ? createFormBySlugHandler(formBySlug) : null;
|
|
1007
|
+
const formSaveHandlers = formSaveConfig ? createFormSaveHandlers(formSaveConfig) : null;
|
|
1008
|
+
const formSubmissionPost = formSubmissionConfig ? createFormSubmissionHandler(formSubmissionConfig) : null;
|
|
1009
|
+
const formSubmissionGetById = formSubmissionGetByIdConfig ? createFormSubmissionGetByIdHandler(formSubmissionGetByIdConfig) : null;
|
|
1010
|
+
const formSubmissionList = formSubmissionGetByIdConfig ? createFormSubmissionListHandler(formSubmissionGetByIdConfig) : null;
|
|
1011
|
+
const usersHandlers = usersApi ? createUsersApiHandlers(usersApi) : null;
|
|
1012
|
+
const avatarPost = userAvatar ? createUserAvatarHandler(userAvatar) : null;
|
|
1013
|
+
const profilePut = userProfile ? createUserProfileHandler(userProfile) : null;
|
|
1014
|
+
const settingsHandlers = settingsConfig ? createSettingsApiHandlers(settingsConfig) : null;
|
|
1015
|
+
function resolveResource(segment) {
|
|
1016
|
+
const model = pathToModel(segment);
|
|
1017
|
+
return crudResources.includes(model) ? model : segment;
|
|
1018
|
+
}
|
|
1019
|
+
return {
|
|
1020
|
+
async handle(method, path, req) {
|
|
1021
|
+
if (path[0] === "dashboard" && path[1] === "stats" && path.length === 2 && method === "GET" && dashboardGet) {
|
|
1022
|
+
return dashboardGet(req);
|
|
1023
|
+
}
|
|
1024
|
+
if (path[0] === "analytics" && analyticsHandlers) {
|
|
1025
|
+
if (path.length === 1 && method === "GET") return analyticsHandlers.GET(req);
|
|
1026
|
+
if (path.length === 2 && path[1] === "property-id" && method === "GET") return analyticsHandlers.propertyId();
|
|
1027
|
+
if (path.length === 2 && path[1] === "permissions" && method === "GET") return analyticsHandlers.permissions();
|
|
1028
|
+
}
|
|
1029
|
+
if (path[0] === "upload" && path.length === 1 && method === "POST" && uploadPost) return uploadPost(req);
|
|
1030
|
+
if (path[0] === "blogs" && path[1] === "slug" && path.length === 3 && method === "GET" && blogBySlugGet) {
|
|
1031
|
+
return blogBySlugGet(req, path[2]);
|
|
1032
|
+
}
|
|
1033
|
+
if (path[0] === "forms" && path[1] === "slug" && path.length === 3 && method === "GET" && formBySlugGet) {
|
|
1034
|
+
return formBySlugGet(req, path[2]);
|
|
1035
|
+
}
|
|
1036
|
+
if (path[0] === "form-submissions") {
|
|
1037
|
+
if (path.length === 1) {
|
|
1038
|
+
if (method === "GET" && formSubmissionList) return formSubmissionList(req);
|
|
1039
|
+
if (method === "POST" && formSubmissionPost) return formSubmissionPost(req);
|
|
1040
|
+
}
|
|
1041
|
+
if (path.length === 2 && method === "GET" && formSubmissionGetById) return formSubmissionGetById(req, path[1]);
|
|
1042
|
+
}
|
|
1043
|
+
if (path[0] === "forms" && formSaveHandlers) {
|
|
1044
|
+
if (path.length === 1 && method === "POST") return formSaveHandlers.POST(req);
|
|
1045
|
+
if (path.length === 2) {
|
|
1046
|
+
if (method === "GET") return formSaveHandlers.GET(req, path[1]);
|
|
1047
|
+
if (method === "PUT" || method === "PATCH") return formSaveHandlers.PUT(req, path[1]);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
if (path[0] === "users" && usersHandlers) {
|
|
1051
|
+
if (path.length === 1) {
|
|
1052
|
+
if (method === "GET") return usersHandlers.list(req);
|
|
1053
|
+
if (method === "POST") return usersHandlers.create(req);
|
|
1054
|
+
}
|
|
1055
|
+
if (path.length === 2) {
|
|
1056
|
+
if (path[1] === "avatar" && method === "POST" && avatarPost) return avatarPost(req);
|
|
1057
|
+
if (path[1] === "profile" && method === "PUT" && profilePut) return profilePut(req);
|
|
1058
|
+
const id = path[1];
|
|
1059
|
+
if (method === "GET") return usersHandlers.getById(req, id);
|
|
1060
|
+
if (method === "PUT" || method === "PATCH") return usersHandlers.update(req, id);
|
|
1061
|
+
if (method === "DELETE") return usersHandlers.delete(req, id);
|
|
1062
|
+
}
|
|
1063
|
+
if (path.length === 3 && path[2] === "regenerate-invite" && method === "POST") {
|
|
1064
|
+
return usersHandlers.regenerateInvite(req, path[1]);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
if (path[0] === "users" && path.length === 2 && userAuthRouter && method === "POST") {
|
|
1068
|
+
return userAuthRouter.POST(req, path[1]);
|
|
1069
|
+
}
|
|
1070
|
+
if (path[0] === "settings" && path.length === 2 && settingsHandlers) {
|
|
1071
|
+
if (method === "GET") return settingsHandlers.GET(req, path[1]);
|
|
1072
|
+
if (method === "PUT") return settingsHandlers.PUT(req, path[1]);
|
|
1073
|
+
}
|
|
1074
|
+
if (path.length === 0) return config.json({ error: "Not found" }, { status: 404 });
|
|
1075
|
+
const resource = resolveResource(path[0]);
|
|
1076
|
+
if (!crudResources.includes(resource)) return config.json({ error: "Invalid resource" }, { status: 400 });
|
|
1077
|
+
if (path.length === 1) {
|
|
1078
|
+
if (method === "GET") return crud.GET(req, resource);
|
|
1079
|
+
if (method === "POST") return crud.POST(req, resource);
|
|
1080
|
+
return config.json({ error: "Method not allowed" }, { status: 405 });
|
|
1081
|
+
}
|
|
1082
|
+
if (path.length === 2) {
|
|
1083
|
+
const id = path[1];
|
|
1084
|
+
if (method === "GET") return crudById.GET(req, resource, id);
|
|
1085
|
+
if (method === "PUT" || method === "PATCH") return crudById.PUT(req, resource, id);
|
|
1086
|
+
if (method === "DELETE") return crudById.DELETE(req, resource, id);
|
|
1087
|
+
return config.json({ error: "Method not allowed" }, { status: 405 });
|
|
1088
|
+
}
|
|
1089
|
+
return config.json({ error: "Not found" }, { status: 404 });
|
|
1090
|
+
}
|
|
1091
|
+
};
|
|
1092
|
+
}
|
|
1093
|
+
export {
|
|
1094
|
+
createAnalyticsHandlers,
|
|
1095
|
+
createBlogBySlugHandler,
|
|
1096
|
+
createChangePasswordHandler,
|
|
1097
|
+
createCmsApiHandler,
|
|
1098
|
+
createCrudByIdHandler,
|
|
1099
|
+
createCrudHandler,
|
|
1100
|
+
createDashboardStatsHandler,
|
|
1101
|
+
createForgotPasswordHandler,
|
|
1102
|
+
createFormBySlugHandler,
|
|
1103
|
+
createInviteAcceptHandler,
|
|
1104
|
+
createSetPasswordHandler,
|
|
1105
|
+
createSettingsApiHandlers,
|
|
1106
|
+
createUploadHandler,
|
|
1107
|
+
createUserAuthApiRouter,
|
|
1108
|
+
createUserAvatarHandler,
|
|
1109
|
+
createUserProfileHandler,
|
|
1110
|
+
createUsersApiHandlers
|
|
1111
|
+
};
|
|
1112
|
+
//# sourceMappingURL=api.js.map
|