@starklabs/backend-core 1.2.7 → 1.2.8
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.
|
@@ -4,6 +4,7 @@ const buildSchema = (definition) => {
|
|
|
4
4
|
const schemaObject = {};
|
|
5
5
|
|
|
6
6
|
for (const key in definition) {
|
|
7
|
+
|
|
7
8
|
const value = definition[key];
|
|
8
9
|
|
|
9
10
|
// CASE 1: primitive shorthand (String, Number, etc.)
|
|
@@ -32,4 +33,4 @@ const buildSchema = (definition) => {
|
|
|
32
33
|
return new mongoose.Schema(schemaObject, { timestamps: true });
|
|
33
34
|
};
|
|
34
35
|
|
|
35
|
-
export default buildSchema;
|
|
36
|
+
export default buildSchema;
|
|
@@ -215,6 +215,25 @@ const requiredImage = z
|
|
|
215
215
|
.refine((file) => file.mimetype.startsWith("image/"), {
|
|
216
216
|
message: "Only image files are allowed",
|
|
217
217
|
});
|
|
218
|
+
|
|
219
|
+
const object = (shape) => {
|
|
220
|
+
// convert plain helper-based shape into real z.object()
|
|
221
|
+
const parsedShape = {};
|
|
222
|
+
|
|
223
|
+
for (const key in shape) {
|
|
224
|
+
const value = shape[key];
|
|
225
|
+
|
|
226
|
+
// if already a Zod schema, keep it
|
|
227
|
+
if (value && value._def) {
|
|
228
|
+
parsedShape[key] = value;
|
|
229
|
+
} else {
|
|
230
|
+
throw new Error(`Invalid schema at key "${key}". Expected a Zod schema.`);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return z.object(parsedShape);
|
|
235
|
+
};
|
|
236
|
+
|
|
218
237
|
/**
|
|
219
238
|
* =========================
|
|
220
239
|
* EXPORT ALL
|
|
@@ -244,4 +263,5 @@ export default {
|
|
|
244
263
|
provider,
|
|
245
264
|
role,
|
|
246
265
|
requiredImage,
|
|
266
|
+
object,
|
|
247
267
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starklabs/backend-core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"description": "A comprehensive backend authentication library featuring MongoDB integration, JWT-based authentication, encryption/decryption using libsodium, and utilities for error handling and logging. Supports both ES modules and CommonJS. Requires MONGODB_URI, DB_NAME, MASTER_KEY, and JWT_SECRET environment variables.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"auth-mongo",
|