@goweekdays/core 2.1.4 → 2.2.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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +8 -3
- package/dist/index.js +118 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +122 -48
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -319,6 +319,7 @@ declare function useMemberRepo(): {
|
|
|
319
319
|
createTextIndex: () => Promise<void>;
|
|
320
320
|
add: (value: TMember, session?: ClientSession) => Promise<string>;
|
|
321
321
|
getById: (_id: string | ObjectId) => Promise<TMember | null>;
|
|
322
|
+
getByRole: (role: string | ObjectId) => Promise<TMember | null>;
|
|
322
323
|
getAll: ({ search, limit, page, user, org, type, status }?: {
|
|
323
324
|
search: string;
|
|
324
325
|
limit: number;
|
|
@@ -505,14 +506,18 @@ declare function useRoleRepo(): {
|
|
|
505
506
|
pageRange: string;
|
|
506
507
|
} | TRole[]>;
|
|
507
508
|
getRoleByUserId: (value: ObjectId | string) => Promise<TRole | null>;
|
|
508
|
-
|
|
509
|
+
getById: (_id: ObjectId | string) => Promise<mongodb.WithId<bson.Document> | TRole | null>;
|
|
509
510
|
getRoleByName: (name: string) => Promise<mongodb.WithId<bson.Document> | TRole | null>;
|
|
510
511
|
updateRole: (_id: string | ObjectId, value: TMiniRole, session?: ClientSession) => Promise<string>;
|
|
511
|
-
|
|
512
|
+
deleteById: (_id: ObjectId | string, session?: ClientSession) => Promise<string>;
|
|
512
513
|
updatePermissionsById: (_id: string | ObjectId, permissions: TRole["permissions"], session?: ClientSession) => Promise<string>;
|
|
513
514
|
delCachedData: () => void;
|
|
514
515
|
};
|
|
515
516
|
|
|
517
|
+
declare function useRoleService(): {
|
|
518
|
+
deleteById: (id: string) => Promise<void>;
|
|
519
|
+
};
|
|
520
|
+
|
|
516
521
|
declare function useRoleController(): {
|
|
517
522
|
createRole: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
518
523
|
getRoles: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
@@ -965,4 +970,4 @@ declare const XENDIT_SECRET_KEY: string;
|
|
|
965
970
|
declare const XENDIT_BASE_URL: string;
|
|
966
971
|
declare const DOMAIN: string;
|
|
967
972
|
|
|
968
|
-
export { ACCESS_TOKEN_EXPIRY, ACCESS_TOKEN_SECRET, APP_ACCOUNT, APP_MAIN, DEFAULT_USER_EMAIL, DEFAULT_USER_FIRST_NAME, DEFAULT_USER_LAST_NAME, DEFAULT_USER_PASSWORD, DOMAIN, MAILER_EMAIL, MAILER_PASSWORD, MAILER_TRANSPORT_HOST, MAILER_TRANSPORT_PORT, MAILER_TRANSPORT_SECURE, MAddress, MBuilding, MBuildingUnit, MFile, MMember, MONGO_DB, MONGO_URI, MOrg, MUser, MUserRole, MVerification, OrgTypes, PAYPAL_API_URL, PAYPAL_CLIENT_ID, PAYPAL_CLIENT_SECRET, PORT, REDIS_HOST, REDIS_PASSWORD, REDIS_PORT, REFRESH_TOKEN_EXPIRY, REFRESH_TOKEN_SECRET, SECRET_KEY, SPACES_ACCESS_KEY, SPACES_BUCKET, SPACES_ENDPOINT, SPACES_REGION, SPACES_SECRET_KEY, TAddress, TApp, TBuilding, TBuildingUnit, TCounter, TFile, TMember, TMiniRole, TOrg, TPSGC, TPermission, TPermissionGroup, TRole, TUser, TUserRole, TVerification, TVerificationMetadata, VERIFICATION_FORGET_PASSWORD_DURATION, VERIFICATION_USER_INVITE_DURATION, XENDIT_BASE_URL, XENDIT_SECRET_KEY, addressSchema, isDev, modelApp, modelPSGC, modelPermission, modelPermissionGroup, modelRole, schemaApp, schemaAppUpdate, schemaBuilding, schemaBuildingUnit, schemaOrg, schemaPSGC, schemaPermission, schemaPermissionGroup, schemaPermissionGroupUpdate, schemaPermissionUpdate, schemaRole, schemaUpdateOptions, transactionSchema, useAddressController, useAddressRepo, useAppController, useAppRepo, useAppService, useAuthController, useAuthService, useBuildingController, useBuildingRepo, useBuildingService, useBuildingUnitController, useBuildingUnitRepo, useBuildingUnitService, useCounterModel, useCounterRepo, useFileController, useFileRepo, useFileService, useGitHubService, useMemberController, useMemberRepo, useOrgController, useOrgRepo, useOrgService, usePSGCController, usePSGCRepo, usePermissionController, usePermissionGroupController, usePermissionGroupRepo, usePermissionGroupService, usePermissionRepo, usePermissionService, useRoleController, useRoleRepo, useUserController, useUserRepo, useUserService, useUtilController, useVerificationController, useVerificationRepo, useVerificationService };
|
|
973
|
+
export { ACCESS_TOKEN_EXPIRY, ACCESS_TOKEN_SECRET, APP_ACCOUNT, APP_MAIN, DEFAULT_USER_EMAIL, DEFAULT_USER_FIRST_NAME, DEFAULT_USER_LAST_NAME, DEFAULT_USER_PASSWORD, DOMAIN, MAILER_EMAIL, MAILER_PASSWORD, MAILER_TRANSPORT_HOST, MAILER_TRANSPORT_PORT, MAILER_TRANSPORT_SECURE, MAddress, MBuilding, MBuildingUnit, MFile, MMember, MONGO_DB, MONGO_URI, MOrg, MUser, MUserRole, MVerification, OrgTypes, PAYPAL_API_URL, PAYPAL_CLIENT_ID, PAYPAL_CLIENT_SECRET, PORT, REDIS_HOST, REDIS_PASSWORD, REDIS_PORT, REFRESH_TOKEN_EXPIRY, REFRESH_TOKEN_SECRET, SECRET_KEY, SPACES_ACCESS_KEY, SPACES_BUCKET, SPACES_ENDPOINT, SPACES_REGION, SPACES_SECRET_KEY, TAddress, TApp, TBuilding, TBuildingUnit, TCounter, TFile, TMember, TMiniRole, TOrg, TPSGC, TPermission, TPermissionGroup, TRole, TUser, TUserRole, TVerification, TVerificationMetadata, VERIFICATION_FORGET_PASSWORD_DURATION, VERIFICATION_USER_INVITE_DURATION, XENDIT_BASE_URL, XENDIT_SECRET_KEY, addressSchema, isDev, modelApp, modelPSGC, modelPermission, modelPermissionGroup, modelRole, schemaApp, schemaAppUpdate, schemaBuilding, schemaBuildingUnit, schemaOrg, schemaPSGC, schemaPermission, schemaPermissionGroup, schemaPermissionGroupUpdate, schemaPermissionUpdate, schemaRole, schemaUpdateOptions, transactionSchema, useAddressController, useAddressRepo, useAppController, useAppRepo, useAppService, useAuthController, useAuthService, useBuildingController, useBuildingRepo, useBuildingService, useBuildingUnitController, useBuildingUnitRepo, useBuildingUnitService, useCounterModel, useCounterRepo, useFileController, useFileRepo, useFileService, useGitHubService, useMemberController, useMemberRepo, useOrgController, useOrgRepo, useOrgService, usePSGCController, usePSGCRepo, usePermissionController, usePermissionGroupController, usePermissionGroupRepo, usePermissionGroupService, usePermissionRepo, usePermissionService, useRoleController, useRoleRepo, useRoleService, useUserController, useUserRepo, useUserService, useUtilController, useVerificationController, useVerificationRepo, useVerificationService };
|
package/dist/index.js
CHANGED
|
@@ -129,6 +129,7 @@ __export(src_exports, {
|
|
|
129
129
|
usePermissionService: () => usePermissionService,
|
|
130
130
|
useRoleController: () => useRoleController,
|
|
131
131
|
useRoleRepo: () => useRoleRepo,
|
|
132
|
+
useRoleService: () => useRoleService,
|
|
132
133
|
useUserController: () => useUserController,
|
|
133
134
|
useUserRepo: () => useUserRepo,
|
|
134
135
|
useUserService: () => useUserService,
|
|
@@ -1579,6 +1580,43 @@ function useMemberRepo() {
|
|
|
1579
1580
|
);
|
|
1580
1581
|
}
|
|
1581
1582
|
}
|
|
1583
|
+
async function getByRole(role) {
|
|
1584
|
+
try {
|
|
1585
|
+
role = new import_mongodb9.ObjectId(role);
|
|
1586
|
+
} catch (error) {
|
|
1587
|
+
throw new import_utils10.BadRequestError("Invalid role ID.");
|
|
1588
|
+
}
|
|
1589
|
+
try {
|
|
1590
|
+
const cacheKey = (0, import_utils10.makeCacheKey)(namespace_collection, {
|
|
1591
|
+
role: role.toString()
|
|
1592
|
+
});
|
|
1593
|
+
const cached = await getCache(cacheKey);
|
|
1594
|
+
if (cached) {
|
|
1595
|
+
import_utils10.logger.log({
|
|
1596
|
+
level: "info",
|
|
1597
|
+
message: `Cache hit for getById member: ${cacheKey}`
|
|
1598
|
+
});
|
|
1599
|
+
return cached;
|
|
1600
|
+
}
|
|
1601
|
+
const data = await collection.findOne({ role });
|
|
1602
|
+
setCache(cacheKey, data, 300).then(() => {
|
|
1603
|
+
import_utils10.logger.log({
|
|
1604
|
+
level: "info",
|
|
1605
|
+
message: `Cache set for member by role: ${cacheKey}`
|
|
1606
|
+
});
|
|
1607
|
+
}).catch((err) => {
|
|
1608
|
+
import_utils10.logger.log({
|
|
1609
|
+
level: "error",
|
|
1610
|
+
message: `Failed to set cache for member by role: ${err.message}`
|
|
1611
|
+
});
|
|
1612
|
+
});
|
|
1613
|
+
return data;
|
|
1614
|
+
} catch (error) {
|
|
1615
|
+
throw new import_utils10.InternalServerError(
|
|
1616
|
+
"Internal server error, failed to retrieve member."
|
|
1617
|
+
);
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1582
1620
|
async function getByUserId(user) {
|
|
1583
1621
|
try {
|
|
1584
1622
|
user = new import_mongodb9.ObjectId(user);
|
|
@@ -2029,6 +2067,7 @@ function useMemberRepo() {
|
|
|
2029
2067
|
createTextIndex,
|
|
2030
2068
|
add,
|
|
2031
2069
|
getById,
|
|
2070
|
+
getByRole,
|
|
2032
2071
|
getAll,
|
|
2033
2072
|
getOrgsByUserId,
|
|
2034
2073
|
updateStatusByUserId,
|
|
@@ -2531,7 +2570,7 @@ function useRoleRepo() {
|
|
|
2531
2570
|
throw new import_utils12.InternalServerError("Failed to retrieve role by user ID.");
|
|
2532
2571
|
}
|
|
2533
2572
|
}
|
|
2534
|
-
async function
|
|
2573
|
+
async function getById(_id) {
|
|
2535
2574
|
try {
|
|
2536
2575
|
_id = new import_mongodb11.ObjectId(_id);
|
|
2537
2576
|
} catch (error) {
|
|
@@ -2545,7 +2584,7 @@ function useRoleRepo() {
|
|
|
2545
2584
|
if (cached) {
|
|
2546
2585
|
import_utils12.logger.log({
|
|
2547
2586
|
level: "info",
|
|
2548
|
-
message: `Cache hit for
|
|
2587
|
+
message: `Cache hit for getById role: ${cacheKey}`
|
|
2549
2588
|
});
|
|
2550
2589
|
return cached;
|
|
2551
2590
|
}
|
|
@@ -2728,7 +2767,7 @@ function useRoleRepo() {
|
|
|
2728
2767
|
throw new import_utils12.InternalServerError("Failed to update role permissions.");
|
|
2729
2768
|
}
|
|
2730
2769
|
}
|
|
2731
|
-
async function
|
|
2770
|
+
async function deleteById(_id, session) {
|
|
2732
2771
|
try {
|
|
2733
2772
|
_id = new import_mongodb11.ObjectId(_id);
|
|
2734
2773
|
} catch (error) {
|
|
@@ -2754,10 +2793,10 @@ function useRoleRepo() {
|
|
|
2754
2793
|
addRole,
|
|
2755
2794
|
getRoles,
|
|
2756
2795
|
getRoleByUserId,
|
|
2757
|
-
|
|
2796
|
+
getById,
|
|
2758
2797
|
getRoleByName,
|
|
2759
2798
|
updateRole,
|
|
2760
|
-
|
|
2799
|
+
deleteById,
|
|
2761
2800
|
updatePermissionsById,
|
|
2762
2801
|
delCachedData
|
|
2763
2802
|
};
|
|
@@ -3968,6 +4007,12 @@ function useAppService() {
|
|
|
3968
4007
|
description: "Administrative application.",
|
|
3969
4008
|
type: "default"
|
|
3970
4009
|
},
|
|
4010
|
+
{
|
|
4011
|
+
code: "org",
|
|
4012
|
+
name: "Organization",
|
|
4013
|
+
description: "Organization application.",
|
|
4014
|
+
type: "standard"
|
|
4015
|
+
},
|
|
3971
4016
|
{
|
|
3972
4017
|
code: "marketplace",
|
|
3973
4018
|
name: "Marketplace",
|
|
@@ -7307,7 +7352,7 @@ function useOrgService() {
|
|
|
7307
7352
|
try {
|
|
7308
7353
|
const org = await addOrg(value, session);
|
|
7309
7354
|
const allPermissions = await getAllPermission({
|
|
7310
|
-
app:
|
|
7355
|
+
app: "org",
|
|
7311
7356
|
limit: 100
|
|
7312
7357
|
});
|
|
7313
7358
|
let permissions = [];
|
|
@@ -7956,24 +8001,49 @@ function usePSGCController() {
|
|
|
7956
8001
|
};
|
|
7957
8002
|
}
|
|
7958
8003
|
|
|
8004
|
+
// src/resources/role/role.service.ts
|
|
8005
|
+
var import_utils45 = require("@goweekdays/utils");
|
|
8006
|
+
function useRoleService() {
|
|
8007
|
+
const { getByRole } = useMemberRepo();
|
|
8008
|
+
const { deleteById: _deleteById } = useRoleRepo();
|
|
8009
|
+
async function deleteById(id) {
|
|
8010
|
+
try {
|
|
8011
|
+
const role = await getByRole(id);
|
|
8012
|
+
if (role) {
|
|
8013
|
+
throw new import_utils45.BadRequestError("Cannot delete role assigned to members.");
|
|
8014
|
+
}
|
|
8015
|
+
await _deleteById(id);
|
|
8016
|
+
} catch (error) {
|
|
8017
|
+
if (error instanceof import_utils45.AppError) {
|
|
8018
|
+
throw error;
|
|
8019
|
+
} else {
|
|
8020
|
+
throw new import_utils45.InternalServerError("Failed to delete role.");
|
|
8021
|
+
}
|
|
8022
|
+
}
|
|
8023
|
+
}
|
|
8024
|
+
return {
|
|
8025
|
+
deleteById
|
|
8026
|
+
};
|
|
8027
|
+
}
|
|
8028
|
+
|
|
7959
8029
|
// src/resources/role/role.controller.ts
|
|
7960
8030
|
var import_joi25 = __toESM(require("joi"));
|
|
7961
|
-
var
|
|
8031
|
+
var import_utils46 = require("@goweekdays/utils");
|
|
7962
8032
|
function useRoleController() {
|
|
7963
8033
|
const {
|
|
7964
8034
|
addRole: _createRole,
|
|
7965
|
-
|
|
8035
|
+
getById,
|
|
7966
8036
|
getRoleByUserId: _getRoleByUserId,
|
|
7967
8037
|
getRoles: _getRoles,
|
|
7968
8038
|
updateRole: _updateRole,
|
|
7969
|
-
deleteRole: _deleteRole,
|
|
7970
8039
|
updatePermissionsById: _updatePermissionsById
|
|
7971
8040
|
} = useRoleRepo();
|
|
8041
|
+
const { deleteById: _deleteById } = useRoleService();
|
|
7972
8042
|
async function createRole(req, res, next) {
|
|
7973
8043
|
const payload = req.body;
|
|
7974
8044
|
const { error } = schemaRole.validate(payload);
|
|
7975
8045
|
if (error) {
|
|
7976
|
-
next(new
|
|
8046
|
+
next(new import_utils46.BadRequestError(error.message));
|
|
7977
8047
|
return;
|
|
7978
8048
|
}
|
|
7979
8049
|
try {
|
|
@@ -7999,7 +8069,7 @@ function useRoleController() {
|
|
|
7999
8069
|
});
|
|
8000
8070
|
const { error } = validation.validate({ search, page, limit, type, id });
|
|
8001
8071
|
if (error) {
|
|
8002
|
-
next(new
|
|
8072
|
+
next(new import_utils46.BadRequestError(error.message));
|
|
8003
8073
|
return;
|
|
8004
8074
|
}
|
|
8005
8075
|
try {
|
|
@@ -8017,7 +8087,7 @@ function useRoleController() {
|
|
|
8017
8087
|
});
|
|
8018
8088
|
const { error } = validation.validate({ userId });
|
|
8019
8089
|
if (error) {
|
|
8020
|
-
next(new
|
|
8090
|
+
next(new import_utils46.BadRequestError(error.message));
|
|
8021
8091
|
return;
|
|
8022
8092
|
}
|
|
8023
8093
|
try {
|
|
@@ -8035,11 +8105,11 @@ function useRoleController() {
|
|
|
8035
8105
|
});
|
|
8036
8106
|
const { error } = validation.validate({ _id });
|
|
8037
8107
|
if (error) {
|
|
8038
|
-
next(new
|
|
8108
|
+
next(new import_utils46.BadRequestError(error.message));
|
|
8039
8109
|
return;
|
|
8040
8110
|
}
|
|
8041
8111
|
try {
|
|
8042
|
-
const data = await
|
|
8112
|
+
const data = await getById(_id);
|
|
8043
8113
|
res.json(data);
|
|
8044
8114
|
return;
|
|
8045
8115
|
} catch (error2) {
|
|
@@ -8057,7 +8127,7 @@ function useRoleController() {
|
|
|
8057
8127
|
});
|
|
8058
8128
|
const { error } = validation.validate({ _id, name, permissions });
|
|
8059
8129
|
if (error) {
|
|
8060
|
-
next(new
|
|
8130
|
+
next(new import_utils46.BadRequestError(error.message));
|
|
8061
8131
|
return;
|
|
8062
8132
|
}
|
|
8063
8133
|
try {
|
|
@@ -8077,7 +8147,7 @@ function useRoleController() {
|
|
|
8077
8147
|
});
|
|
8078
8148
|
const { error } = validation.validate({ _id, permissions });
|
|
8079
8149
|
if (error) {
|
|
8080
|
-
next(new
|
|
8150
|
+
next(new import_utils46.BadRequestError(error.message));
|
|
8081
8151
|
return;
|
|
8082
8152
|
}
|
|
8083
8153
|
try {
|
|
@@ -8095,11 +8165,11 @@ function useRoleController() {
|
|
|
8095
8165
|
});
|
|
8096
8166
|
const { error } = validation.validate({ _id });
|
|
8097
8167
|
if (error) {
|
|
8098
|
-
next(new
|
|
8168
|
+
next(new import_utils46.BadRequestError(error.message));
|
|
8099
8169
|
return;
|
|
8100
8170
|
}
|
|
8101
8171
|
try {
|
|
8102
|
-
const message = await
|
|
8172
|
+
const message = await _deleteById(_id);
|
|
8103
8173
|
res.json({ message });
|
|
8104
8174
|
return;
|
|
8105
8175
|
} catch (error2) {
|
|
@@ -8118,7 +8188,7 @@ function useRoleController() {
|
|
|
8118
8188
|
}
|
|
8119
8189
|
|
|
8120
8190
|
// src/resources/utils/github.service.ts
|
|
8121
|
-
var
|
|
8191
|
+
var import_utils47 = require("@goweekdays/utils");
|
|
8122
8192
|
var import_rest = require("@octokit/rest");
|
|
8123
8193
|
var import_libsodium_wrappers = __toESM(require("libsodium-wrappers"));
|
|
8124
8194
|
function useGitHubService() {
|
|
@@ -8132,23 +8202,23 @@ function useGitHubService() {
|
|
|
8132
8202
|
try {
|
|
8133
8203
|
const { data: repoData } = await octokit.repos.get({ owner, repo });
|
|
8134
8204
|
if (!repoData.permissions?.admin) {
|
|
8135
|
-
throw new
|
|
8205
|
+
throw new import_utils47.BadRequestError(
|
|
8136
8206
|
"You do not have admin access to this repository."
|
|
8137
8207
|
);
|
|
8138
8208
|
}
|
|
8139
8209
|
} catch (error) {
|
|
8140
8210
|
if (error.status === 404) {
|
|
8141
|
-
throw new
|
|
8211
|
+
throw new import_utils47.BadRequestError(
|
|
8142
8212
|
"Repository not found or you don't have access to it."
|
|
8143
8213
|
);
|
|
8144
8214
|
} else if (error.status === 401) {
|
|
8145
|
-
throw new
|
|
8215
|
+
throw new import_utils47.BadRequestError(
|
|
8146
8216
|
"Invalid GitHub token or insufficient permissions."
|
|
8147
8217
|
);
|
|
8148
8218
|
} else if (error.message.includes("admin access")) {
|
|
8149
8219
|
throw error;
|
|
8150
8220
|
} else {
|
|
8151
|
-
throw new
|
|
8221
|
+
throw new import_utils47.BadRequestError(
|
|
8152
8222
|
`Failed to check repository permissions: ${error.message}`
|
|
8153
8223
|
);
|
|
8154
8224
|
}
|
|
@@ -8197,7 +8267,7 @@ function useGitHubService() {
|
|
|
8197
8267
|
key_id: publicKeyRes.key_id
|
|
8198
8268
|
});
|
|
8199
8269
|
} catch (encryptionError) {
|
|
8200
|
-
throw new
|
|
8270
|
+
throw new import_utils47.BadRequestError(
|
|
8201
8271
|
`Failed to encrypt secret '${key}': ${encryptionError.message}`
|
|
8202
8272
|
);
|
|
8203
8273
|
}
|
|
@@ -8227,22 +8297,22 @@ function useGitHubService() {
|
|
|
8227
8297
|
}
|
|
8228
8298
|
return `Successfully set ${lines.length} ${type} variables/secrets in environment '${environment}'`;
|
|
8229
8299
|
} catch (error) {
|
|
8230
|
-
if (error instanceof
|
|
8300
|
+
if (error instanceof import_utils47.AppError)
|
|
8231
8301
|
throw error;
|
|
8232
8302
|
if (error.status === 422) {
|
|
8233
|
-
throw new
|
|
8303
|
+
throw new import_utils47.BadRequestError(
|
|
8234
8304
|
`GitHub API validation error: ${error.message}`
|
|
8235
8305
|
);
|
|
8236
8306
|
} else if (error.status === 404) {
|
|
8237
|
-
throw new
|
|
8307
|
+
throw new import_utils47.BadRequestError("Environment or repository not found.");
|
|
8238
8308
|
} else if (error.status === 403) {
|
|
8239
|
-
throw new
|
|
8309
|
+
throw new import_utils47.BadRequestError(
|
|
8240
8310
|
"Forbidden: Insufficient permissions or rate limit exceeded."
|
|
8241
8311
|
);
|
|
8242
8312
|
} else if (error.message.includes("admin access") || error.message.includes("permissions")) {
|
|
8243
8313
|
throw error;
|
|
8244
8314
|
} else {
|
|
8245
|
-
throw new
|
|
8315
|
+
throw new import_utils47.BadRequestError(
|
|
8246
8316
|
`Failed to set GitHub variables: ${error.message}`
|
|
8247
8317
|
);
|
|
8248
8318
|
}
|
|
@@ -8255,7 +8325,7 @@ function useGitHubService() {
|
|
|
8255
8325
|
|
|
8256
8326
|
// src/resources/utils/util.controller.ts
|
|
8257
8327
|
var import_joi26 = __toESM(require("joi"));
|
|
8258
|
-
var
|
|
8328
|
+
var import_utils48 = require("@goweekdays/utils");
|
|
8259
8329
|
function useUtilController() {
|
|
8260
8330
|
async function healthCheck(req, res, next) {
|
|
8261
8331
|
try {
|
|
@@ -8271,8 +8341,8 @@ function useUtilController() {
|
|
|
8271
8341
|
}
|
|
8272
8342
|
});
|
|
8273
8343
|
} catch (error) {
|
|
8274
|
-
|
|
8275
|
-
next(new
|
|
8344
|
+
import_utils48.logger.error("Health check failed", { error: error.message });
|
|
8345
|
+
next(new import_utils48.InternalServerError("Health check failed"));
|
|
8276
8346
|
}
|
|
8277
8347
|
}
|
|
8278
8348
|
async function setGitHubVariables(req, res, next) {
|
|
@@ -8309,13 +8379,13 @@ function useUtilController() {
|
|
|
8309
8379
|
keyValues
|
|
8310
8380
|
});
|
|
8311
8381
|
if (error) {
|
|
8312
|
-
next(new
|
|
8382
|
+
next(new import_utils48.BadRequestError(error.message));
|
|
8313
8383
|
return;
|
|
8314
8384
|
}
|
|
8315
8385
|
const repoUrlPattern = /github\.com[:\/]([^\/]+)\/(.+)\.git$/;
|
|
8316
8386
|
if (!repoUrlPattern.test(repoUrl)) {
|
|
8317
8387
|
next(
|
|
8318
|
-
new
|
|
8388
|
+
new import_utils48.BadRequestError(
|
|
8319
8389
|
"Invalid GitHub repository URL format. Expected format: https://github.com/owner/repo.git"
|
|
8320
8390
|
)
|
|
8321
8391
|
);
|
|
@@ -8327,7 +8397,7 @@ function useUtilController() {
|
|
|
8327
8397
|
);
|
|
8328
8398
|
if (invalidLines.length > 0) {
|
|
8329
8399
|
next(
|
|
8330
|
-
new
|
|
8400
|
+
new import_utils48.BadRequestError(
|
|
8331
8401
|
"Invalid key-value format. Each pair should be in format: KEY=value. Pairs should be separated by semicolons."
|
|
8332
8402
|
)
|
|
8333
8403
|
);
|
|
@@ -8341,7 +8411,7 @@ function useUtilController() {
|
|
|
8341
8411
|
type,
|
|
8342
8412
|
keyValues
|
|
8343
8413
|
});
|
|
8344
|
-
|
|
8414
|
+
import_utils48.logger.info(`GitHub variables set successfully`, {
|
|
8345
8415
|
repoUrl,
|
|
8346
8416
|
environment,
|
|
8347
8417
|
type,
|
|
@@ -8358,15 +8428,15 @@ function useUtilController() {
|
|
|
8358
8428
|
}
|
|
8359
8429
|
});
|
|
8360
8430
|
} catch (error) {
|
|
8361
|
-
|
|
8431
|
+
import_utils48.logger.error("Failed to set GitHub variables", {
|
|
8362
8432
|
error: error.message,
|
|
8363
8433
|
stack: error.stack
|
|
8364
8434
|
});
|
|
8365
|
-
if (error instanceof
|
|
8435
|
+
if (error instanceof import_utils48.AppError) {
|
|
8366
8436
|
next(error);
|
|
8367
8437
|
} else {
|
|
8368
8438
|
next(
|
|
8369
|
-
new
|
|
8439
|
+
new import_utils48.InternalServerError(
|
|
8370
8440
|
`Failed to set GitHub variables: ${error.message}`
|
|
8371
8441
|
)
|
|
8372
8442
|
);
|
|
@@ -8403,7 +8473,7 @@ var transactionSchema = import_joi27.default.object({
|
|
|
8403
8473
|
});
|
|
8404
8474
|
|
|
8405
8475
|
// src/resources/verification/verification.controller.ts
|
|
8406
|
-
var
|
|
8476
|
+
var import_utils49 = require("@goweekdays/utils");
|
|
8407
8477
|
var import_joi28 = __toESM(require("joi"));
|
|
8408
8478
|
function useVerificationController() {
|
|
8409
8479
|
const {
|
|
@@ -8424,7 +8494,7 @@ function useVerificationController() {
|
|
|
8424
8494
|
});
|
|
8425
8495
|
const { error } = validation.validate(req.body);
|
|
8426
8496
|
if (error) {
|
|
8427
|
-
next(new
|
|
8497
|
+
next(new import_utils49.BadRequestError(error.message));
|
|
8428
8498
|
return;
|
|
8429
8499
|
}
|
|
8430
8500
|
const email = req.body.email ?? "";
|
|
@@ -8455,7 +8525,7 @@ function useVerificationController() {
|
|
|
8455
8525
|
const validation = import_joi28.default.string().email().required();
|
|
8456
8526
|
const { error } = validation.validate(email);
|
|
8457
8527
|
if (error) {
|
|
8458
|
-
next(new
|
|
8528
|
+
next(new import_utils49.BadRequestError(error.message));
|
|
8459
8529
|
return;
|
|
8460
8530
|
}
|
|
8461
8531
|
try {
|
|
@@ -8465,10 +8535,10 @@ function useVerificationController() {
|
|
|
8465
8535
|
});
|
|
8466
8536
|
return;
|
|
8467
8537
|
} catch (error2) {
|
|
8468
|
-
if (error2 instanceof
|
|
8538
|
+
if (error2 instanceof import_utils49.AppError) {
|
|
8469
8539
|
next(error2);
|
|
8470
8540
|
} else {
|
|
8471
|
-
next(new
|
|
8541
|
+
next(new import_utils49.InternalServerError("An unexpected error occurred"));
|
|
8472
8542
|
}
|
|
8473
8543
|
}
|
|
8474
8544
|
}
|
|
@@ -8483,7 +8553,7 @@ function useVerificationController() {
|
|
|
8483
8553
|
});
|
|
8484
8554
|
const { error } = validation.validate(req.query);
|
|
8485
8555
|
if (error) {
|
|
8486
|
-
next(new
|
|
8556
|
+
next(new import_utils49.BadRequestError(error.message));
|
|
8487
8557
|
return;
|
|
8488
8558
|
}
|
|
8489
8559
|
const status = req.query.status ?? "";
|
|
@@ -8517,7 +8587,7 @@ function useVerificationController() {
|
|
|
8517
8587
|
const validation = import_joi28.default.string().hex().required();
|
|
8518
8588
|
const { error } = validation.validate(id);
|
|
8519
8589
|
if (error) {
|
|
8520
|
-
next(new
|
|
8590
|
+
next(new import_utils49.BadRequestError(error.message));
|
|
8521
8591
|
return;
|
|
8522
8592
|
}
|
|
8523
8593
|
try {
|
|
@@ -8533,7 +8603,7 @@ function useVerificationController() {
|
|
|
8533
8603
|
const validation = import_joi28.default.string().hex().required();
|
|
8534
8604
|
const { error } = validation.validate(otpId);
|
|
8535
8605
|
if (error) {
|
|
8536
|
-
next(new
|
|
8606
|
+
next(new import_utils49.BadRequestError(error.message));
|
|
8537
8607
|
return;
|
|
8538
8608
|
}
|
|
8539
8609
|
try {
|
|
@@ -8654,6 +8724,7 @@ function useVerificationController() {
|
|
|
8654
8724
|
usePermissionService,
|
|
8655
8725
|
useRoleController,
|
|
8656
8726
|
useRoleRepo,
|
|
8727
|
+
useRoleService,
|
|
8657
8728
|
useUserController,
|
|
8658
8729
|
useUserRepo,
|
|
8659
8730
|
useUserService,
|