@opencrvs/mosip 1.7.0-alpha.15 → 1.7.0-alpha.16
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/build/events.d.ts +16 -0
- package/build/events.js +42 -5
- package/package.json +1 -1
- package/src/events.ts +50 -4
package/build/events.d.ts
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import type * as Hapi from "@hapi/hapi";
|
|
2
|
+
/**
|
|
3
|
+
* Replaces event registration handler in country config
|
|
4
|
+
*/
|
|
2
5
|
export declare const mosipRegistrationHandler: ({ url }: {
|
|
3
6
|
url: string;
|
|
4
7
|
}) => (request: Hapi.Request, h: Hapi.ResponseToolkit) => Promise<Hapi.ResponseObject>;
|
|
8
|
+
/**
|
|
9
|
+
* Replaces `/events/{event}/actions/sent-notification-for-review` handler in country config
|
|
10
|
+
*/
|
|
11
|
+
export declare const mosipRegistrationForReviewHandler: ({ url }: {
|
|
12
|
+
url: string;
|
|
13
|
+
}) => (request: Hapi.Request, h: Hapi.ResponseToolkit) => Promise<Hapi.ResponseObject>;
|
|
14
|
+
/**
|
|
15
|
+
* Replaces `/events/{event}/actions/sent-for-approval` handler in country config
|
|
16
|
+
* Currently the same as `/events/{event}/actions/sent-notification-for-review`
|
|
17
|
+
*/
|
|
18
|
+
export declare const mosipRegistrationForApprovalHandler: ({ url }: {
|
|
19
|
+
url: string;
|
|
20
|
+
}) => (request: Hapi.Request, h: Hapi.ResponseToolkit) => Promise<Hapi.ResponseObject>;
|
package/build/events.js
CHANGED
|
@@ -3,19 +3,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.mosipRegistrationHandler = void 0;
|
|
6
|
+
exports.mosipRegistrationForApprovalHandler = exports.mosipRegistrationForReviewHandler = exports.mosipRegistrationHandler = void 0;
|
|
7
7
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
8
|
+
/**
|
|
9
|
+
* Replaces event registration handler in country config
|
|
10
|
+
*/
|
|
8
11
|
const mosipRegistrationHandler = ({ url }) => (async (request, h) => {
|
|
9
|
-
const
|
|
10
|
-
const response = await (0, node_fetch_1.default)(
|
|
12
|
+
const MOSIP_API_REGISTRATION_EVENT_URL = new URL("./events/registration", url);
|
|
13
|
+
const response = await (0, node_fetch_1.default)(MOSIP_API_REGISTRATION_EVENT_URL, {
|
|
11
14
|
method: "POST",
|
|
12
15
|
body: JSON.stringify(request.payload),
|
|
13
|
-
headers:
|
|
16
|
+
headers: {
|
|
17
|
+
...request.headers,
|
|
18
|
+
"content-type": "application/json",
|
|
19
|
+
},
|
|
14
20
|
});
|
|
15
21
|
if (!response.ok) {
|
|
16
22
|
return h
|
|
17
23
|
.response({
|
|
18
|
-
error: "OpenCRVS-MOSIP
|
|
24
|
+
error: "OpenCRVS-MOSIP event registration route did not return a 200",
|
|
19
25
|
response: await response.text(),
|
|
20
26
|
})
|
|
21
27
|
.code(500);
|
|
@@ -23,3 +29,34 @@ const mosipRegistrationHandler = ({ url }) => (async (request, h) => {
|
|
|
23
29
|
return h.response({ success: true }).code(200);
|
|
24
30
|
});
|
|
25
31
|
exports.mosipRegistrationHandler = mosipRegistrationHandler;
|
|
32
|
+
/**
|
|
33
|
+
* Replaces `/events/{event}/actions/sent-notification-for-review` handler in country config
|
|
34
|
+
*/
|
|
35
|
+
const mosipRegistrationForReviewHandler = ({ url }) => (async (request, h) => {
|
|
36
|
+
// Corresponds to `packages/mosip-api` /events/review -route
|
|
37
|
+
const MOSIP_API_REVIEW_EVENT_URL = new URL("./events/review", url);
|
|
38
|
+
console.info(request.headers);
|
|
39
|
+
const response = await (0, node_fetch_1.default)(MOSIP_API_REVIEW_EVENT_URL, {
|
|
40
|
+
method: "POST",
|
|
41
|
+
body: JSON.stringify(request.payload),
|
|
42
|
+
headers: {
|
|
43
|
+
...request.headers,
|
|
44
|
+
"content-type": "application/json",
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
if (!response.ok) {
|
|
48
|
+
return h
|
|
49
|
+
.response({
|
|
50
|
+
error: "OpenCRVS-MOSIP event review route did not return a 200",
|
|
51
|
+
response: await response.text(),
|
|
52
|
+
})
|
|
53
|
+
.code(500);
|
|
54
|
+
}
|
|
55
|
+
return h.response({ success: true }).code(200);
|
|
56
|
+
});
|
|
57
|
+
exports.mosipRegistrationForReviewHandler = mosipRegistrationForReviewHandler;
|
|
58
|
+
/**
|
|
59
|
+
* Replaces `/events/{event}/actions/sent-for-approval` handler in country config
|
|
60
|
+
* Currently the same as `/events/{event}/actions/sent-notification-for-review`
|
|
61
|
+
*/
|
|
62
|
+
exports.mosipRegistrationForApprovalHandler = exports.mosipRegistrationForReviewHandler;
|
package/package.json
CHANGED
package/src/events.ts
CHANGED
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
import type * as Hapi from "@hapi/hapi";
|
|
2
2
|
import fetch from "node-fetch";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Replaces event registration handler in country config
|
|
6
|
+
*/
|
|
4
7
|
export const mosipRegistrationHandler = ({ url }: { url: string }) =>
|
|
5
8
|
(async (request: Hapi.Request, h: Hapi.ResponseToolkit) => {
|
|
6
|
-
const
|
|
9
|
+
const MOSIP_API_REGISTRATION_EVENT_URL = new URL(
|
|
10
|
+
"./events/registration",
|
|
11
|
+
url,
|
|
12
|
+
);
|
|
7
13
|
|
|
8
|
-
const response = await fetch(
|
|
14
|
+
const response = await fetch(MOSIP_API_REGISTRATION_EVENT_URL, {
|
|
9
15
|
method: "POST",
|
|
10
16
|
body: JSON.stringify(request.payload),
|
|
11
|
-
headers:
|
|
17
|
+
headers: {
|
|
18
|
+
...request.headers,
|
|
19
|
+
"content-type": "application/json",
|
|
20
|
+
},
|
|
12
21
|
});
|
|
13
22
|
|
|
14
23
|
if (!response.ok) {
|
|
15
24
|
return h
|
|
16
25
|
.response({
|
|
17
|
-
error: "OpenCRVS-MOSIP
|
|
26
|
+
error: "OpenCRVS-MOSIP event registration route did not return a 200",
|
|
18
27
|
response: await response.text(),
|
|
19
28
|
})
|
|
20
29
|
.code(500);
|
|
@@ -22,3 +31,40 @@ export const mosipRegistrationHandler = ({ url }: { url: string }) =>
|
|
|
22
31
|
|
|
23
32
|
return h.response({ success: true }).code(200);
|
|
24
33
|
}) satisfies Hapi.ServerRoute["handler"];
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Replaces `/events/{event}/actions/sent-notification-for-review` handler in country config
|
|
37
|
+
*/
|
|
38
|
+
export const mosipRegistrationForReviewHandler = ({ url }: { url: string }) =>
|
|
39
|
+
(async (request: Hapi.Request, h: Hapi.ResponseToolkit) => {
|
|
40
|
+
// Corresponds to `packages/mosip-api` /events/review -route
|
|
41
|
+
const MOSIP_API_REVIEW_EVENT_URL = new URL("./events/review", url);
|
|
42
|
+
|
|
43
|
+
console.info(request.headers);
|
|
44
|
+
|
|
45
|
+
const response = await fetch(MOSIP_API_REVIEW_EVENT_URL, {
|
|
46
|
+
method: "POST",
|
|
47
|
+
body: JSON.stringify(request.payload),
|
|
48
|
+
headers: {
|
|
49
|
+
...request.headers,
|
|
50
|
+
"content-type": "application/json",
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if (!response.ok) {
|
|
55
|
+
return h
|
|
56
|
+
.response({
|
|
57
|
+
error: "OpenCRVS-MOSIP event review route did not return a 200",
|
|
58
|
+
response: await response.text(),
|
|
59
|
+
})
|
|
60
|
+
.code(500);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return h.response({ success: true }).code(200);
|
|
64
|
+
}) satisfies Hapi.ServerRoute["handler"];
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Replaces `/events/{event}/actions/sent-for-approval` handler in country config
|
|
68
|
+
* Currently the same as `/events/{event}/actions/sent-notification-for-review`
|
|
69
|
+
*/
|
|
70
|
+
export const mosipRegistrationForApprovalHandler = mosipRegistrationForReviewHandler
|