Skip to content

Commit 4028a49

Browse files
committed
chore: further-refactor, working swagger
1 parent 476140c commit 4028a49

21 files changed

Lines changed: 89 additions & 619 deletions

e2e/mock-api-v2/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"scripts": {
99
"build": "pnpm nx nxBuild",
1010
"lint": "pnpm nx nxLint",
11-
"serve": "node dist/e2e/mock-api-v2/src/main.js",
12-
"serve:dev": "nodemon dist/e2e/mock-api-v2/src/main.js",
11+
"serve": "node dist/src/main.js",
12+
"serve:dev": "nodemon dist/src/main.js",
1313
"test": "pnpm nx nxTest"
1414
},
1515
"dependencies": {
@@ -28,7 +28,7 @@
2828
"executor": "@nx/js:tsc",
2929
"outputs": ["{options.outputPath}"],
3030
"options": {
31-
"outputPath": "e2e/mock-api-v2/dist",
31+
"outputPath": "./dist",
3232
"main": "e2e/mock-api-v2/src/main.ts",
3333
"tsConfig": "e2e/mock-api-v2/tsconfig.app.json",
3434
"generatePackageJson": true

e2e/mock-api-v2/src/example-server.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
/*
2-
* Copyright (c) 2025 Ping Identity Corporation. All rights reserved.
3-
*
4-
* This software may be modified and distributed under the terms
5-
* of the MIT license. See the LICENSE file for details.
6-
*/
7-
import { toCookieHeader } from '@effect/platform/Cookies';
8-
import { Effect } from 'effect';
9-
import { RouterBuilder } from 'effect-http';
10-
11-
import { CookieService } from '../services/cookie.service.js';
12-
import { CustomHtmlTemplate } from '../services/custom-html-template.service.js';
13-
import { apiSpec } from '../spec.js';
14-
15-
const customHtmlHandler = RouterBuilder.handler(
16-
apiSpec,
17-
'PingOneCustomHtml',
18-
({ headers, query, body }) =>
19-
Effect.gen(function* () {
20-
const { handleCustomHtmlTemplate } = yield* CustomHtmlTemplate;
21-
const response = yield* handleCustomHtmlTemplate<typeof headers, typeof query>(
22-
headers,
23-
query,
24-
body,
25-
);
26-
27-
const { writeCookie } = yield* CookieService;
28-
29-
const cookie = yield* writeCookie(headers, response.interactionToken);
30-
31-
return {
32-
status: 200 as const,
33-
body: response,
34-
headers: {
35-
'Set-Cookie': toCookieHeader(cookie),
36-
},
37-
};
38-
}),
39-
);
40-
41-
export { customHtmlHandler };
1+
// /*
2+
// * Copyright (c) 2025 Ping Identity Corporation. All rights reserved.
3+
// *
4+
// * This software may be modified and distributed under the terms
5+
// * of the MIT license. See the LICENSE file for details.
6+
// */
7+
// import { toCookieHeader } from '@effect/platform/Cookies';
8+
// import { Effect } from 'effect';
9+
// import { RouterBuilder } from 'effect-http';
10+
//
11+
// import { CookieService } from '../services/cookie.service.js';
12+
// import { CustomHtmlTemplate } from '../services/custom-html-template.service.js';
13+
// import { apiSpec } from '../spec.js';
14+
//
15+
// const customHtmlHandler = RouterBuilder.handler(
16+
// apiSpec,
17+
// 'PingOneCustomHtml',
18+
// ({ headers, query, body }) =>
19+
// Effect.gen(function* () {
20+
// const { handleCustomHtmlTemplate } = yield* CustomHtmlTemplate;
21+
// const response = yield* handleCustomHtmlTemplate<typeof headers, typeof query>(
22+
// headers,
23+
// query,
24+
// body,
25+
// );
26+
//
27+
// const { writeCookie } = yield* CookieService;
28+
//
29+
// const cookie = yield* writeCookie(headers, response.interactionToken);
30+
//
31+
// return {
32+
// status: 200 as const,
33+
// body: response,
34+
// headers: {
35+
// 'Set-Cookie': toCookieHeader(cookie),
36+
// },
37+
// };
38+
// }),
39+
// );
40+
//
41+
// export { customHtmlHandler };

e2e/mock-api-v2/src/handlers/token.handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Tokens } from '../services/tokens.service.js';
99
import { HttpApiBuilder } from '@effect/platform';
1010
import { Effect } from 'effect';
1111

12-
const tokenHandler = HttpApiBuilder.group(MockApi, 'Tokens', (handlers) =>
12+
const TokensHandler = HttpApiBuilder.group(MockApi, 'Tokens', (handlers) =>
1313
handlers.handle('Tokens', () =>
1414
Effect.gen(function* () {
1515
const { getTokens } = yield* Tokens;
@@ -20,4 +20,4 @@ const tokenHandler = HttpApiBuilder.group(MockApi, 'Tokens', (handlers) =>
2020
),
2121
);
2222

23-
export { tokenHandler };
23+
export { TokensHandler };

e2e/mock-api-v2/src/handlers/userinfo.handler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ import { HttpApiBuilder } from '@effect/platform';
1212
/**
1313
* TODO: Need to implement an Authorization middleware
1414
*/
15-
const userInfoHandler = HttpApiBuilder.group(MockApi, 'Protected Requests', (handlers) =>
15+
const UserInfoMockHandler = HttpApiBuilder.group(MockApi, 'Protected Requests', (handlers) =>
1616
handlers.handle('UserInfo', () =>
1717
Effect.gen(function* () {
1818
const { getUserInfo } = yield* UserInfo;
1919

20-
const response = yield* getUserInfo();
20+
const response = yield* getUserInfo;
2121

2222
return response;
2323
}),
2424
),
2525
);
2626

27-
export { userInfoHandler };
27+
export { UserInfoMockHandler };

e2e/mock-api-v2/src/helpers/match.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
* This software may be modified and distributed under the terms
55
* of the MIT license. See the LICENSE file for details.
66
*/
7-
import { Schema } from '@effect/schema';
8-
import { Effect, Match } from 'effect';
7+
import { Effect, Match, Schema } from 'effect';
98

109
import { InvalidUsernamePassword, InvalidProtectNode } from '../errors/index.js';
1110
import { PingOneCustomHtmlRequestBody } from '../schemas/custom-html-template/custom-html-template-request.schema.js';

e2e/mock-api-v2/src/main.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,25 @@ import { OpenidConfigMock } from './handlers/open-id-configuration.handler.js';
1414
import { IncrementStepIndexMock } from './middleware/CookieMiddleware.js';
1515
import { AuthorizeHandlerMock } from './handlers/authorize.handler.js';
1616
import { AuthorizeMock } from './services/authorize.service.js';
17+
import { TokensMock } from './services/tokens.service.js';
18+
import { TokensHandler } from './handlers/token.handler.js';
19+
import { UserInfoMockHandler } from './handlers/userinfo.handler.js';
20+
import { UserInfoMockService } from './services/userinfo.service.js';
1721

1822
const APIMock = HttpApiBuilder.api(MockApi).pipe(
1923
Layer.provide(HealthCheckLive),
2024
Layer.provide(OpenidConfigMock),
2125
Layer.provide(AuthorizeHandlerMock),
26+
Layer.provide(TokensHandler),
27+
Layer.provide(UserInfoMockHandler),
2228
);
2329

2430
const ServerMock = HttpApiBuilder.serve(HttpMiddleware.logger).pipe(
2531
Layer.provide(HttpApiSwagger.layer()),
2632
Layer.provide(APIMock),
2733
Layer.provide(AuthorizeMock),
34+
Layer.provide(TokensMock),
35+
Layer.provide(UserInfoMockService),
2836
Layer.provide(IncrementStepIndexMock),
2937
// Layer.provide(AuthorizationLive),
3038
Layer.provide(HttpApiBuilder.middlewareCors()),

e2e/mock-api-v2/src/schemas/return-success-response-redirect.schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This software may be modified and distributed under the terms
55
* of the MIT license. See the LICENSE file for details.
66
*/
7-
import { Schema } from '@effect/schema';
7+
import { Schema } from 'effect';
88

99
const _SuccessResponseRedirect = Schema.Struct({
1010
interactionId: Schema.String,

e2e/mock-api-v2/src/services/cookie.service.ts

Lines changed: 0 additions & 58 deletions
This file was deleted.

e2e/mock-api-v2/src/services/mock-env-helpers/tests/index.test.ts

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)