@goweekdays/core 0.0.8 → 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 +12 -0
- package/dist/index.d.ts +9 -2
- package/dist/index.js +157 -106
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +157 -106
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -989,14 +989,19 @@ declare function usePaymentMethodRepo(): {
|
|
|
989
989
|
};
|
|
990
990
|
|
|
991
991
|
declare function usePaymentMethodService(): {
|
|
992
|
-
linkEWallet: ({ user, mobile_number, type, success_return_url, failure_return_url, cancel_return_url, }?: {
|
|
992
|
+
linkEWallet: ({ user, mobile_number, type, success_return_url, failure_return_url, cancel_return_url, metadata, }?: {
|
|
993
993
|
user?: string | undefined;
|
|
994
994
|
mobile_number?: string | undefined;
|
|
995
995
|
type?: string | undefined;
|
|
996
996
|
success_return_url?: string | undefined;
|
|
997
997
|
failure_return_url?: string | undefined;
|
|
998
998
|
cancel_return_url?: string | undefined;
|
|
999
|
-
|
|
999
|
+
metadata?: {} | undefined;
|
|
1000
|
+
}) => Promise<{
|
|
1001
|
+
paymentMethod: any;
|
|
1002
|
+
customer: any;
|
|
1003
|
+
actions: any;
|
|
1004
|
+
}>;
|
|
1000
1005
|
linkCard: ({ user, type, success_return_url, failure_return_url, card_number, expiry_month, expiry_year, cvv, cardholder_name, currency, }?: {
|
|
1001
1006
|
user?: string | undefined;
|
|
1002
1007
|
type?: string | undefined;
|
|
@@ -1051,6 +1056,7 @@ declare function useOrgRepo(): {
|
|
|
1051
1056
|
value: string;
|
|
1052
1057
|
}, session?: ClientSession) => Promise<string>;
|
|
1053
1058
|
deleteById: (_id: string | ObjectId) => Promise<string>;
|
|
1059
|
+
getByName: (name: string) => Promise<TOrg>;
|
|
1054
1060
|
};
|
|
1055
1061
|
|
|
1056
1062
|
declare function useOrgService(): {
|
|
@@ -1064,6 +1070,7 @@ declare function useOrgService(): {
|
|
|
1064
1070
|
declare function useOrgController(): {
|
|
1065
1071
|
createOrg: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
1066
1072
|
getOrgsByUserId: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
1073
|
+
getByName: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
1067
1074
|
};
|
|
1068
1075
|
|
|
1069
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
|
|
|
@@ -19535,8 +19551,43 @@ function useSubscriptionService() {
|
|
|
19535
19551
|
}
|
|
19536
19552
|
|
|
19537
19553
|
// src/controllers/subscription.controller.ts
|
|
19538
|
-
var
|
|
19554
|
+
var import_joi12 = __toESM(require("joi"));
|
|
19539
19555
|
var import_utils62 = require("@goweekdays/utils");
|
|
19556
|
+
|
|
19557
|
+
// src/validations/subscription.schema.ts
|
|
19558
|
+
var import_joi11 = __toESM(require("joi"));
|
|
19559
|
+
function useSubscriptionSchema() {
|
|
19560
|
+
const schema = import_joi11.default.object({
|
|
19561
|
+
user: import_joi11.default.string().required(),
|
|
19562
|
+
amount: import_joi11.default.number().required(),
|
|
19563
|
+
customer_id: import_joi11.default.string().required(),
|
|
19564
|
+
payment_method_id: import_joi11.default.string().required(),
|
|
19565
|
+
currency: import_joi11.default.string().optional().allow("", null),
|
|
19566
|
+
organization: import_joi11.default.object({
|
|
19567
|
+
name: import_joi11.default.string().required(),
|
|
19568
|
+
description: import_joi11.default.string().optional().allow("", null),
|
|
19569
|
+
type: import_joi11.default.string().allow("personal", "business").required(),
|
|
19570
|
+
email: import_joi11.default.string().email().required(),
|
|
19571
|
+
contact: import_joi11.default.string().required(),
|
|
19572
|
+
busInst: import_joi11.default.string().optional().allow(null, "")
|
|
19573
|
+
}).required(),
|
|
19574
|
+
billingAddress: import_joi11.default.object({
|
|
19575
|
+
type: import_joi11.default.string().required(),
|
|
19576
|
+
country: import_joi11.default.string().required(),
|
|
19577
|
+
address: import_joi11.default.string().required(),
|
|
19578
|
+
continuedAddress: import_joi11.default.string().optional().allow(null, ""),
|
|
19579
|
+
city: import_joi11.default.string().required(),
|
|
19580
|
+
province: import_joi11.default.string().required(),
|
|
19581
|
+
postalCode: import_joi11.default.string().required(),
|
|
19582
|
+
taxId: import_joi11.default.string().optional().allow(null, "")
|
|
19583
|
+
}).required()
|
|
19584
|
+
});
|
|
19585
|
+
return {
|
|
19586
|
+
schema
|
|
19587
|
+
};
|
|
19588
|
+
}
|
|
19589
|
+
|
|
19590
|
+
// src/controllers/subscription.controller.ts
|
|
19540
19591
|
function useSubscriptionController() {
|
|
19541
19592
|
const { add: _add, getSubscriptions: _getSubscriptions } = useSubscriptionRepo();
|
|
19542
19593
|
const {
|
|
@@ -19547,9 +19598,9 @@ function useSubscriptionController() {
|
|
|
19547
19598
|
} = useSubscriptionService();
|
|
19548
19599
|
async function add(req, res, next) {
|
|
19549
19600
|
const value = req.body;
|
|
19550
|
-
const validation =
|
|
19551
|
-
user:
|
|
19552
|
-
subscriptionId:
|
|
19601
|
+
const validation = import_joi12.default.object({
|
|
19602
|
+
user: import_joi12.default.string().required(),
|
|
19603
|
+
subscriptionId: import_joi12.default.string().required()
|
|
19553
19604
|
});
|
|
19554
19605
|
const { error } = validation.validate(value);
|
|
19555
19606
|
if (error) {
|
|
@@ -19566,7 +19617,7 @@ function useSubscriptionController() {
|
|
|
19566
19617
|
}
|
|
19567
19618
|
async function getByUserId(req, res, next) {
|
|
19568
19619
|
const id = req.params.id;
|
|
19569
|
-
const validation =
|
|
19620
|
+
const validation = import_joi12.default.string().required();
|
|
19570
19621
|
const { error } = validation.validate(id);
|
|
19571
19622
|
if (error) {
|
|
19572
19623
|
next(new import_utils62.BadRequestError(error.message));
|
|
@@ -19583,10 +19634,10 @@ function useSubscriptionController() {
|
|
|
19583
19634
|
const status = req.query.status ?? "";
|
|
19584
19635
|
const search = req.query.search ?? "";
|
|
19585
19636
|
const page = Number(req.query.page) ?? 1;
|
|
19586
|
-
const validation =
|
|
19587
|
-
status:
|
|
19588
|
-
search:
|
|
19589
|
-
page:
|
|
19637
|
+
const validation = import_joi12.default.object({
|
|
19638
|
+
status: import_joi12.default.string().required(),
|
|
19639
|
+
search: import_joi12.default.string().optional().allow("", null),
|
|
19640
|
+
page: import_joi12.default.number().required()
|
|
19590
19641
|
});
|
|
19591
19642
|
const { error } = validation.validate({ status, search, page });
|
|
19592
19643
|
if (error) {
|
|
@@ -19602,7 +19653,7 @@ function useSubscriptionController() {
|
|
|
19602
19653
|
}
|
|
19603
19654
|
async function getSubscriptionStatus(req, res, next) {
|
|
19604
19655
|
const id = req.params.id;
|
|
19605
|
-
const validation =
|
|
19656
|
+
const validation = import_joi12.default.string().required();
|
|
19606
19657
|
const { error } = validation.validate(id);
|
|
19607
19658
|
if (error) {
|
|
19608
19659
|
next(new import_utils62.BadRequestError(error.message));
|
|
@@ -19621,12 +19672,12 @@ function useSubscriptionController() {
|
|
|
19621
19672
|
const customer_id = req.body.customer_id ?? "";
|
|
19622
19673
|
const currency = req.body.currency ?? "PHP";
|
|
19623
19674
|
const user = req.headers["user"];
|
|
19624
|
-
const validation =
|
|
19625
|
-
user:
|
|
19626
|
-
amount:
|
|
19627
|
-
customer_id:
|
|
19628
|
-
payment_method_id:
|
|
19629
|
-
currency:
|
|
19675
|
+
const validation = import_joi12.default.object({
|
|
19676
|
+
user: import_joi12.default.string().required(),
|
|
19677
|
+
amount: import_joi12.default.number().required(),
|
|
19678
|
+
customer_id: import_joi12.default.string().required(),
|
|
19679
|
+
payment_method_id: import_joi12.default.string().required(),
|
|
19680
|
+
currency: import_joi12.default.string().optional().allow("", null)
|
|
19630
19681
|
});
|
|
19631
19682
|
const { error } = validation.validate({
|
|
19632
19683
|
user,
|
|
@@ -19654,35 +19705,11 @@ function useSubscriptionController() {
|
|
|
19654
19705
|
return;
|
|
19655
19706
|
}
|
|
19656
19707
|
}
|
|
19708
|
+
const { schema: subscriptionSchema } = useSubscriptionSchema();
|
|
19657
19709
|
async function createOrgSubscription(req, res, next) {
|
|
19658
19710
|
const value = req.body;
|
|
19659
19711
|
value.user = req.headers["user"];
|
|
19660
|
-
const
|
|
19661
|
-
user: import_joi11.default.string().required(),
|
|
19662
|
-
amount: import_joi11.default.number().required(),
|
|
19663
|
-
customer_id: import_joi11.default.string().required(),
|
|
19664
|
-
payment_method_id: import_joi11.default.string().required(),
|
|
19665
|
-
currency: import_joi11.default.string().optional().allow("", null),
|
|
19666
|
-
organization: import_joi11.default.object({
|
|
19667
|
-
name: import_joi11.default.string().required(),
|
|
19668
|
-
description: import_joi11.default.string().optional().allow("", null),
|
|
19669
|
-
type: import_joi11.default.string().allow("personal", "business").required(),
|
|
19670
|
-
email: import_joi11.default.string().email().required(),
|
|
19671
|
-
contact: import_joi11.default.string().required(),
|
|
19672
|
-
busInst: import_joi11.default.string().optional().allow(null, "")
|
|
19673
|
-
}).required(),
|
|
19674
|
-
billingAddress: import_joi11.default.object({
|
|
19675
|
-
type: import_joi11.default.string().required(),
|
|
19676
|
-
country: import_joi11.default.string().required(),
|
|
19677
|
-
address: import_joi11.default.string().required(),
|
|
19678
|
-
continuedAddress: import_joi11.default.string().optional().allow(null, ""),
|
|
19679
|
-
city: import_joi11.default.string().required(),
|
|
19680
|
-
province: import_joi11.default.string().required(),
|
|
19681
|
-
postalCode: import_joi11.default.string().required(),
|
|
19682
|
-
taxId: import_joi11.default.string().optional().allow(null, "")
|
|
19683
|
-
}).required()
|
|
19684
|
-
});
|
|
19685
|
-
const { error } = validation.validate(value);
|
|
19712
|
+
const { error } = subscriptionSchema.validate(value);
|
|
19686
19713
|
if (error) {
|
|
19687
19714
|
next(new import_utils62.BadRequestError(error.message));
|
|
19688
19715
|
return;
|
|
@@ -19756,7 +19783,8 @@ function usePaymentMethodService() {
|
|
|
19756
19783
|
type = "GCASH",
|
|
19757
19784
|
success_return_url = "",
|
|
19758
19785
|
failure_return_url = "",
|
|
19759
|
-
cancel_return_url = ""
|
|
19786
|
+
cancel_return_url = "",
|
|
19787
|
+
metadata = {}
|
|
19760
19788
|
} = {}) {
|
|
19761
19789
|
const session = import_utils63.useAtlas.getClient()?.startSession();
|
|
19762
19790
|
session?.startTransaction();
|
|
@@ -19774,7 +19802,7 @@ function usePaymentMethodService() {
|
|
|
19774
19802
|
given_names: _user.firstName,
|
|
19775
19803
|
surname: _user.lastName
|
|
19776
19804
|
});
|
|
19777
|
-
const
|
|
19805
|
+
const paymentMethod = await linkPaymentMethodEWallet({
|
|
19778
19806
|
customerId: customer.id,
|
|
19779
19807
|
type,
|
|
19780
19808
|
success_return_url,
|
|
@@ -19786,17 +19814,20 @@ function usePaymentMethodService() {
|
|
|
19786
19814
|
user: _user._id,
|
|
19787
19815
|
type,
|
|
19788
19816
|
status: "active",
|
|
19789
|
-
paymentId:
|
|
19817
|
+
paymentId: paymentMethod.id,
|
|
19790
19818
|
customerId: customer.id,
|
|
19791
|
-
name:
|
|
19819
|
+
name: paymentMethod.type,
|
|
19792
19820
|
number: mobile_number
|
|
19793
19821
|
},
|
|
19794
19822
|
session
|
|
19795
19823
|
);
|
|
19796
19824
|
await session?.commitTransaction();
|
|
19797
|
-
return
|
|
19825
|
+
return {
|
|
19826
|
+
paymentMethod: paymentMethod.id,
|
|
19827
|
+
customer: customer.id,
|
|
19828
|
+
actions: paymentMethod.actions
|
|
19829
|
+
};
|
|
19798
19830
|
} catch (error) {
|
|
19799
|
-
console.log(error);
|
|
19800
19831
|
await session?.abortTransaction();
|
|
19801
19832
|
throw error;
|
|
19802
19833
|
} finally {
|
|
@@ -19863,7 +19894,7 @@ function usePaymentMethodService() {
|
|
|
19863
19894
|
}
|
|
19864
19895
|
|
|
19865
19896
|
// src/controllers/payment-method.controller.ts
|
|
19866
|
-
var
|
|
19897
|
+
var import_joi13 = __toESM(require("joi"));
|
|
19867
19898
|
var import_utils64 = require("@goweekdays/utils");
|
|
19868
19899
|
function usePaymentMethodController() {
|
|
19869
19900
|
const { linkEWallet: _linkEWallet, linkCard: _linkCard } = usePaymentMethodService();
|
|
@@ -19874,13 +19905,13 @@ function usePaymentMethodController() {
|
|
|
19874
19905
|
const success_return_url = req.body.success_return_url ?? "";
|
|
19875
19906
|
const failure_return_url = req.body.failure_return_url ?? "";
|
|
19876
19907
|
const cancel_return_url = req.body.cancel_return_url ?? "";
|
|
19877
|
-
const validation =
|
|
19878
|
-
user:
|
|
19879
|
-
mobile_number:
|
|
19880
|
-
type:
|
|
19881
|
-
success_return_url:
|
|
19882
|
-
failure_return_url:
|
|
19883
|
-
cancel_return_url:
|
|
19908
|
+
const validation = import_joi13.default.object({
|
|
19909
|
+
user: import_joi13.default.string().hex().required(),
|
|
19910
|
+
mobile_number: import_joi13.default.string().required(),
|
|
19911
|
+
type: import_joi13.default.string().valid("GCASH", "PAYMAYA").required(),
|
|
19912
|
+
success_return_url: import_joi13.default.string().uri().required(),
|
|
19913
|
+
failure_return_url: import_joi13.default.string().uri().required(),
|
|
19914
|
+
cancel_return_url: import_joi13.default.string().uri().required()
|
|
19884
19915
|
});
|
|
19885
19916
|
const { error } = validation.validate({
|
|
19886
19917
|
user,
|
|
@@ -19919,17 +19950,17 @@ function usePaymentMethodController() {
|
|
|
19919
19950
|
const failure_return_url = req.body.failure_return_url ?? "";
|
|
19920
19951
|
const cardType = req.body.cardType ?? "";
|
|
19921
19952
|
const user = req.headers["user"] ?? "";
|
|
19922
|
-
const validation =
|
|
19923
|
-
cardNumber:
|
|
19924
|
-
expiryMonth:
|
|
19925
|
-
expiryYear:
|
|
19926
|
-
cvv:
|
|
19927
|
-
cardholderName:
|
|
19928
|
-
currency:
|
|
19929
|
-
success_return_url:
|
|
19930
|
-
failure_return_url:
|
|
19931
|
-
cardType:
|
|
19932
|
-
user:
|
|
19953
|
+
const validation = import_joi13.default.object({
|
|
19954
|
+
cardNumber: import_joi13.default.string().required(),
|
|
19955
|
+
expiryMonth: import_joi13.default.string().required(),
|
|
19956
|
+
expiryYear: import_joi13.default.string().required(),
|
|
19957
|
+
cvv: import_joi13.default.string().required(),
|
|
19958
|
+
cardholderName: import_joi13.default.string().required(),
|
|
19959
|
+
currency: import_joi13.default.string().optional().allow("", null),
|
|
19960
|
+
success_return_url: import_joi13.default.string().uri().required(),
|
|
19961
|
+
failure_return_url: import_joi13.default.string().uri().required(),
|
|
19962
|
+
cardType: import_joi13.default.string().required(),
|
|
19963
|
+
user: import_joi13.default.string().hex().required()
|
|
19933
19964
|
});
|
|
19934
19965
|
const { error } = validation.validate({
|
|
19935
19966
|
user,
|
|
@@ -19984,22 +20015,22 @@ function usePaymentMethodController() {
|
|
|
19984
20015
|
|
|
19985
20016
|
// src/controllers/address.controller.ts
|
|
19986
20017
|
var import_utils65 = require("@goweekdays/utils");
|
|
19987
|
-
var
|
|
20018
|
+
var import_joi14 = __toESM(require("joi"));
|
|
19988
20019
|
function useAddressController() {
|
|
19989
20020
|
const { add: _add, getByUserId: _getByUserId } = useAddressRepo();
|
|
19990
20021
|
async function add(req, res, next) {
|
|
19991
20022
|
const value = req.body;
|
|
19992
|
-
const validation =
|
|
19993
|
-
type:
|
|
19994
|
-
user:
|
|
19995
|
-
org:
|
|
19996
|
-
country:
|
|
19997
|
-
address:
|
|
19998
|
-
continuedAddress:
|
|
19999
|
-
city:
|
|
20000
|
-
province:
|
|
20001
|
-
postalCode:
|
|
20002
|
-
taxId:
|
|
20023
|
+
const validation = import_joi14.default.object({
|
|
20024
|
+
type: import_joi14.default.string().required(),
|
|
20025
|
+
user: import_joi14.default.string().hex().optional().allow("", null),
|
|
20026
|
+
org: import_joi14.default.string().hex().optional().allow("", null),
|
|
20027
|
+
country: import_joi14.default.string().required(),
|
|
20028
|
+
address: import_joi14.default.string().required(),
|
|
20029
|
+
continuedAddress: import_joi14.default.string().optional().allow("", null),
|
|
20030
|
+
city: import_joi14.default.string().required(),
|
|
20031
|
+
province: import_joi14.default.string().required(),
|
|
20032
|
+
postalCode: import_joi14.default.string().required(),
|
|
20033
|
+
taxId: import_joi14.default.string().optional().allow("", null)
|
|
20003
20034
|
});
|
|
20004
20035
|
const { error } = validation.validate(value);
|
|
20005
20036
|
if (error) {
|
|
@@ -20016,7 +20047,7 @@ function useAddressController() {
|
|
|
20016
20047
|
}
|
|
20017
20048
|
async function getByUserId(req, res, next) {
|
|
20018
20049
|
const user = req.params.user;
|
|
20019
|
-
const validation =
|
|
20050
|
+
const validation = import_joi14.default.string().hex().required();
|
|
20020
20051
|
const { error } = validation.validate(user);
|
|
20021
20052
|
if (error) {
|
|
20022
20053
|
next(new import_utils65.BadRequestError(error.message));
|
|
@@ -20047,19 +20078,19 @@ var import_utils67 = require("@goweekdays/utils");
|
|
|
20047
20078
|
|
|
20048
20079
|
// src/models/member.model.ts
|
|
20049
20080
|
var import_utils66 = require("@goweekdays/utils");
|
|
20050
|
-
var
|
|
20081
|
+
var import_joi15 = __toESM(require("joi"));
|
|
20051
20082
|
var import_mongodb27 = require("mongodb");
|
|
20052
20083
|
function MMember(value) {
|
|
20053
|
-
const schema =
|
|
20054
|
-
_id:
|
|
20055
|
-
org:
|
|
20056
|
-
name:
|
|
20057
|
-
user:
|
|
20058
|
-
role:
|
|
20059
|
-
status:
|
|
20060
|
-
createdAt:
|
|
20061
|
-
updatedAt:
|
|
20062
|
-
deletedAt:
|
|
20084
|
+
const schema = import_joi15.default.object({
|
|
20085
|
+
_id: import_joi15.default.string().hex().optional().allow("", null),
|
|
20086
|
+
org: import_joi15.default.string().hex().required(),
|
|
20087
|
+
name: import_joi15.default.string().required(),
|
|
20088
|
+
user: import_joi15.default.string().hex().required(),
|
|
20089
|
+
role: import_joi15.default.string().hex().required(),
|
|
20090
|
+
status: import_joi15.default.string().optional().allow("", null),
|
|
20091
|
+
createdAt: import_joi15.default.string().optional().allow("", null),
|
|
20092
|
+
updatedAt: import_joi15.default.string().optional().allow("", null),
|
|
20093
|
+
deletedAt: import_joi15.default.string().optional().allow("", null)
|
|
20063
20094
|
});
|
|
20064
20095
|
const { error } = schema.validate(value);
|
|
20065
20096
|
if (error) {
|
|
@@ -20314,19 +20345,20 @@ function useOrgService() {
|
|
|
20314
20345
|
|
|
20315
20346
|
// src/controllers/organization.controller.ts
|
|
20316
20347
|
var import_utils69 = require("@goweekdays/utils");
|
|
20317
|
-
var
|
|
20348
|
+
var import_joi16 = __toESM(require("joi"));
|
|
20318
20349
|
function useOrgController() {
|
|
20319
20350
|
const { createOrg: _createOrg } = useOrgService();
|
|
20320
20351
|
const { getOrgsByUserId: _getOrgsByUserId } = useMemberRepo();
|
|
20352
|
+
const { getByName: _getByName } = useOrgRepo();
|
|
20321
20353
|
async function createOrg(req, res, next) {
|
|
20322
20354
|
const value = req.body;
|
|
20323
|
-
const validation =
|
|
20324
|
-
name:
|
|
20325
|
-
type:
|
|
20326
|
-
email:
|
|
20327
|
-
contact:
|
|
20328
|
-
description:
|
|
20329
|
-
user:
|
|
20355
|
+
const validation = import_joi16.default.object({
|
|
20356
|
+
name: import_joi16.default.string().required(),
|
|
20357
|
+
type: import_joi16.default.string().required(),
|
|
20358
|
+
email: import_joi16.default.string().email().required(),
|
|
20359
|
+
contact: import_joi16.default.string().required(),
|
|
20360
|
+
description: import_joi16.default.string().required(),
|
|
20361
|
+
user: import_joi16.default.string().hex().required()
|
|
20330
20362
|
});
|
|
20331
20363
|
const { error } = validation.validate(value);
|
|
20332
20364
|
if (error) {
|
|
@@ -20346,11 +20378,11 @@ function useOrgController() {
|
|
|
20346
20378
|
const limit = Number(req.query.limit) ?? 10;
|
|
20347
20379
|
const search = req.query.search ?? "";
|
|
20348
20380
|
const user = req.headers["user"];
|
|
20349
|
-
const validation =
|
|
20350
|
-
user:
|
|
20351
|
-
page:
|
|
20352
|
-
limit:
|
|
20353
|
-
search:
|
|
20381
|
+
const validation = import_joi16.default.object({
|
|
20382
|
+
user: import_joi16.default.string().hex().required(),
|
|
20383
|
+
page: import_joi16.default.number().min(1).optional().allow("", null),
|
|
20384
|
+
limit: import_joi16.default.number().min(1).optional().allow("", null),
|
|
20385
|
+
search: import_joi16.default.string().optional().allow("", null)
|
|
20354
20386
|
});
|
|
20355
20387
|
const { error } = validation.validate({ user, page, limit, search });
|
|
20356
20388
|
if (error) {
|
|
@@ -20365,9 +20397,28 @@ function useOrgController() {
|
|
|
20365
20397
|
next(error2);
|
|
20366
20398
|
}
|
|
20367
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
|
+
}
|
|
20368
20418
|
return {
|
|
20369
20419
|
createOrg,
|
|
20370
|
-
getOrgsByUserId
|
|
20420
|
+
getOrgsByUserId,
|
|
20421
|
+
getByName
|
|
20371
20422
|
};
|
|
20372
20423
|
}
|
|
20373
20424
|
// Annotate the CommonJS export names for ESM import in node:
|