@goweekdays/core 0.0.9 → 0.0.10
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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +38 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1056,6 +1056,7 @@ declare function useOrgRepo(): {
|
|
|
1056
1056
|
value: string;
|
|
1057
1057
|
}, session?: ClientSession) => Promise<string>;
|
|
1058
1058
|
deleteById: (_id: string | ObjectId) => Promise<string>;
|
|
1059
|
+
getByName: (name: string) => Promise<TOrg>;
|
|
1059
1060
|
};
|
|
1060
1061
|
|
|
1061
1062
|
declare function useOrgService(): {
|
|
@@ -1069,6 +1070,7 @@ declare function useOrgService(): {
|
|
|
1069
1070
|
declare function useOrgController(): {
|
|
1070
1071
|
createOrg: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
1071
1072
|
getOrgsByUserId: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
1073
|
+
getByName: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
1072
1074
|
};
|
|
1073
1075
|
|
|
1074
1076
|
type TMember = {
|
package/dist/index.js
CHANGED
|
@@ -19289,6 +19289,21 @@ function useOrgRepo() {
|
|
|
19289
19289
|
}
|
|
19290
19290
|
}
|
|
19291
19291
|
}
|
|
19292
|
+
async function getByName(name) {
|
|
19293
|
+
try {
|
|
19294
|
+
const result = await collection.findOne({ name });
|
|
19295
|
+
if (!result) {
|
|
19296
|
+
throw new import_utils58.BadRequestError("Organization not found.");
|
|
19297
|
+
}
|
|
19298
|
+
return result;
|
|
19299
|
+
} catch (error) {
|
|
19300
|
+
if (error instanceof import_utils58.AppError) {
|
|
19301
|
+
throw error;
|
|
19302
|
+
} else {
|
|
19303
|
+
throw new import_utils58.InternalServerError("Failed to get organization.");
|
|
19304
|
+
}
|
|
19305
|
+
}
|
|
19306
|
+
}
|
|
19292
19307
|
async function updateFieldById({ _id, field, value } = {}, session) {
|
|
19293
19308
|
const allowedFields = ["name", "description"];
|
|
19294
19309
|
if (!allowedFields.includes(field)) {
|
|
@@ -19337,7 +19352,8 @@ function useOrgRepo() {
|
|
|
19337
19352
|
getOrgs,
|
|
19338
19353
|
getById,
|
|
19339
19354
|
updateFieldById,
|
|
19340
|
-
deleteById
|
|
19355
|
+
deleteById,
|
|
19356
|
+
getByName
|
|
19341
19357
|
};
|
|
19342
19358
|
}
|
|
19343
19359
|
|
|
@@ -20333,6 +20349,7 @@ var import_joi16 = __toESM(require("joi"));
|
|
|
20333
20349
|
function useOrgController() {
|
|
20334
20350
|
const { createOrg: _createOrg } = useOrgService();
|
|
20335
20351
|
const { getOrgsByUserId: _getOrgsByUserId } = useMemberRepo();
|
|
20352
|
+
const { getByName: _getByName } = useOrgRepo();
|
|
20336
20353
|
async function createOrg(req, res, next) {
|
|
20337
20354
|
const value = req.body;
|
|
20338
20355
|
const validation = import_joi16.default.object({
|
|
@@ -20380,9 +20397,28 @@ function useOrgController() {
|
|
|
20380
20397
|
next(error2);
|
|
20381
20398
|
}
|
|
20382
20399
|
}
|
|
20400
|
+
async function getByName(req, res, next) {
|
|
20401
|
+
const name = req.params.name;
|
|
20402
|
+
const validation = import_joi16.default.object({
|
|
20403
|
+
name: import_joi16.default.string().required()
|
|
20404
|
+
});
|
|
20405
|
+
const { error } = validation.validate({ name });
|
|
20406
|
+
if (error) {
|
|
20407
|
+
next(new import_utils69.BadRequestError(error.message));
|
|
20408
|
+
return;
|
|
20409
|
+
}
|
|
20410
|
+
try {
|
|
20411
|
+
const org = await _getByName(name);
|
|
20412
|
+
res.json(org);
|
|
20413
|
+
return;
|
|
20414
|
+
} catch (error2) {
|
|
20415
|
+
next(error2);
|
|
20416
|
+
}
|
|
20417
|
+
}
|
|
20383
20418
|
return {
|
|
20384
20419
|
createOrg,
|
|
20385
|
-
getOrgsByUserId
|
|
20420
|
+
getOrgsByUserId,
|
|
20421
|
+
getByName
|
|
20386
20422
|
};
|
|
20387
20423
|
}
|
|
20388
20424
|
// Annotate the CommonJS export names for ESM import in node:
|