Skip to content

Commit 68b0a8d

Browse files
committed
feat: Implement KeycloakService for managing Keycloak clients and tokens
- Added KeycloakService to handle client creation and token fetching. - Introduced KeycloakError for better error handling specific to Keycloak operations. - Integrated KeycloakService into ToolsService for untrust client functionality. - Enhanced OasConversionService and OasDereferenceService with improved error logging. - Refactored OasInputService to utilize RemoteSpecificationService for fetching specifications. - Created PostmanConversionService for converting OpenAPI specifications to Postman collections. - Added ZipService for creating ZIP files from entries. - Introduced utility functions for sanitizing file names. - Updated error handling and logging across various services.
1 parent a0b7159 commit 68b0a8d

22 files changed

Lines changed: 5637 additions & 583 deletions
Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,37 @@
1-
name: Go CI/CD
1+
name: Node CI/CD
22

3-
on: push
3+
on:
4+
push:
5+
pull_request:
46

57
jobs:
68
lint:
79
name: Lint
810
runs-on: ubuntu-latest
911
steps:
1012
- uses: actions/checkout@v4
11-
- name: Setup Go
12-
uses: actions/setup-go@v5
13-
with:
14-
go-version: '1.24'
15-
- name: Install golangci-lint
16-
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
17-
- name: Run golangci-lint
18-
run: golangci-lint run --timeout 5m
19-
20-
test:
21-
name: Test
22-
runs-on: ubuntu-latest
23-
needs: lint
24-
steps:
25-
- uses: actions/checkout@v4
26-
- name: Setup Go
27-
uses: actions/setup-go@v5
13+
14+
- name: Setup Node.js
15+
uses: actions/setup-node@v4
2816
with:
29-
go-version: '1.21'
30-
- name: Run tests
31-
run: go test -coverprofile coverage.out ./...
17+
node-version: 20
18+
cache: npm
19+
20+
- name: Install dependencies
21+
run: npm install --ignore-scripts
22+
23+
- name: Run lint
24+
run: npm run lint
3225

3326
build-and-push:
3427
name: Build & Push Docker Image
3528
runs-on: ubuntu-latest
36-
needs: test
29+
needs: lint
3730
permissions:
3831
packages: write
3932
steps:
4033
- uses: actions/checkout@v4
34+
4135
- name: Login to GitHub Container Registry
4236
uses: docker/login-action@v3
4337
with:

api/openapi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"content": {
3232
"application/json": {
3333
"schema": {
34-
"$ref": "#/components/schemas/ArazzoInput"
34+
"$ref": "#/components/schemas/OASInput"
3535
}
3636
}
3737
}

api/openapi.yaml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ paths:
2727
content:
2828
application/json:
2929
schema:
30-
$ref: "#/components/schemas/ArazzoInput"
30+
$ref: "#/components/schemas/OASInput"
3131
responses:
3232
"200":
3333
content:
@@ -285,16 +285,6 @@ components:
285285
API-Version:
286286
$ref: "#/headers/API-Version"
287287
schemas:
288-
ArazzoInput:
289-
example:
290-
arazzoBody: arazzoBody
291-
arazzoUrl: arazzoUrl
292-
properties:
293-
arazzoBody:
294-
type: string
295-
arazzoUrl:
296-
type: string
297-
type: object
298288
OASInput:
299289
example:
300290
oasUrl: oasUrl

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/1.7.2/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.3.4/schema.json",
33
"formatter": {
44
"indentStyle": "space",
55
"indentWidth": 2,

controllers/Controller.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const fs = require("node:fs");
22
const path = require("node:path");
33
const config = require("../config");
44
const Service = require("../services/Service");
5+
const logger = require("../logger");
56

67
class Controller {
78
static getStatusText(status) {
@@ -77,6 +78,13 @@ class Controller {
7778
problem.invalidParams = invalidParams;
7879
}
7980

81+
logger.error(`Request failed (${status} ${Controller.getStatusText(status)}): ${reason}`, {
82+
detail,
83+
invalidParams,
84+
errorMessage: error?.message,
85+
stack: error?.stack,
86+
});
87+
8088
response.status(status).json(problem);
8189
}
8290

@@ -126,23 +134,23 @@ class Controller {
126134
return params;
127135
}
128136
const result = { ...params };
129-
if (!Object.prototype.hasOwnProperty.call(result, bodyName)) {
137+
if (!Object.hasOwn(result, bodyName)) {
130138
result[bodyName] = value;
131139
}
132-
if (!Object.prototype.hasOwnProperty.call(result, "body")) {
140+
if (!Object.hasOwn(result, "body")) {
133141
result.body = value;
134142
}
135143
const sanitizedName = Service.sanitizeOperationId(bodyName);
136-
if (sanitizedName && !Object.prototype.hasOwnProperty.call(result, sanitizedName)) {
144+
if (sanitizedName && !Object.hasOwn(result, sanitizedName)) {
137145
result[sanitizedName] = value;
138146
}
139147
const lowerCaseName = bodyName.charAt(0).toLowerCase() + bodyName.slice(1);
140-
if (lowerCaseName && !Object.prototype.hasOwnProperty.call(result, lowerCaseName)) {
148+
if (lowerCaseName && !Object.hasOwn(result, lowerCaseName)) {
141149
result[lowerCaseName] = value;
142150
}
143151
if (value && typeof value === "object" && !Array.isArray(value)) {
144152
Object.keys(value).forEach((key) => {
145-
if (!Object.prototype.hasOwnProperty.call(result, key)) {
153+
if (!Object.hasOwn(result, key)) {
146154
result[key] = value[key];
147155
}
148156
});
@@ -181,7 +189,7 @@ class Controller {
181189
}
182190
const declaredProperties = schemaDefinition?.properties ? Object.keys(schemaDefinition.properties) : [];
183191
const allowAdditional = (() => {
184-
if (schemaDefinition && Object.prototype.hasOwnProperty.call(schemaDefinition, "additionalProperties")) {
192+
if (schemaDefinition && Object.hasOwn(schemaDefinition, "additionalProperties")) {
185193
return schemaDefinition.additionalProperties !== false;
186194
}
187195
return false;

expressServer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class ExpressServer {
8282
this.port = port;
8383
this.app = express();
8484
try {
85-
this.schema = jsYaml.safeLoad(fs.readFileSync(openApiYaml));
85+
this.schema = jsYaml.load(fs.readFileSync(openApiYaml, "utf8"));
8686
if (this.schema?.components) {
8787
const { components } = this.schema;
8888
const componentMirrors = [
@@ -136,11 +136,11 @@ class ExpressServer {
136136
this.app.use(express.json());
137137
this.app.use(express.urlencoded({ extended: false }));
138138
this.app.use(cookieParser());
139-
this.app.use((req, res, next) => {
139+
this.app.use((_req, res, next) => {
140140
res.set("API-Version", this.schema.info.version);
141141
next();
142142
});
143-
this.app.get("/openapi.json", (req, res) => res.json(this.schema));
143+
this.app.get("/openapi.json", (_req, res) => res.json(this.schema));
144144
this.app.get("/login-redirect", (req, res) => {
145145
res.status(200);
146146
res.json(req.query);
@@ -235,7 +235,7 @@ class ExpressServer {
235235

236236
launch() {
237237
// eslint-disable-next-line no-unused-vars
238-
this.app.use((err, req, res, next) => {
238+
this.app.use((err, req, res, _next) => {
239239
// format errors using RFC 7807 Problem Details format
240240
const status = err.status || 500;
241241
const problemDetails = {

0 commit comments

Comments
 (0)