Skip to content

Commit

Permalink
Added: Some Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyvishal committed Jun 24, 2024
1 parent d82678e commit 6862187
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import cors from "cors";
import { Exception } from "./models/exception.model";
import {
BecknErrorDataType,
BecknErrorType,
BecknErrorType
} from "./schemas/becknError.schema";
import { LookupCache } from "./utils/cache/lookup.cache.utils";
import { RequestCache } from "./utils/cache/request.cache.utils";
Expand All @@ -18,7 +18,7 @@ const app = Express();

app.use(
Express.json({
limit: "200kb",
limit: "200kb"
})
);

Expand All @@ -30,9 +30,14 @@ const initializeExpress = async (successCallback: Function) => {
path: "/process"
})
);
app.get("/status", async (req: Request, res: Response, next: NextFunction) => {
res.status(200).send('Added logic to cache OpenAPI validator spec on app load');
});
app.get(
"/status",
async (req: Request, res: Response, next: NextFunction) => {
res
.status(200)
.send("Added logic to cache OpenAPI validator spec on app load");
}
);

// Enabling Cors
app.options(
Expand All @@ -41,13 +46,13 @@ const initializeExpress = async (successCallback: Function) => {
origin: "*",
optionsSuccessStatus: 200,
credentials: true,
methods: ["GET", "PUT", "POST", "PATCH", "DELETE", "OPTIONS"],
methods: ["GET", "PUT", "POST", "PATCH", "DELETE", "OPTIONS"]
})
);
app.use(
cors({
origin: "*",
methods: ["GET", "PUT", "POST", "PATCH", "DELETE", "OPTIONS"],
methods: ["GET", "PUT", "POST", "PATCH", "DELETE", "OPTIONS"]
})
);

Expand All @@ -56,10 +61,10 @@ const initializeExpress = async (successCallback: Function) => {
Express.json({
verify: (req: Request, res: Response, buf: Buffer) => {
res.locals = {
rawBody: buf.toString(),
rawBody: buf.toString()
};
},
limit: "200kb",
limit: "200kb"
})
);

Expand Down Expand Up @@ -89,24 +94,24 @@ const initializeExpress = async (successCallback: Function) => {
code: err.code,
message: err.message,
data: err.errorData,
type: BecknErrorType.domainError,
type: BecknErrorType.domainError
} as BecknErrorDataType;
res.status(err.code).json({
message: {
ack: {
status: "NACK",
},
status: "NACK"
}
},
error: errorData,
error: errorData
});
} else {
res.status(err.code || 500).json({
message: {
ack: {
status: "NACK",
},
status: "NACK"
}
},
error: err,
error: err
});
}
});
Expand All @@ -133,12 +138,12 @@ const main = async () => {
logger.info("Mode: " + getConfig().app.mode.toLocaleUpperCase());
logger.info(
"Gateway Type: " +
getConfig().app.gateway.mode.toLocaleUpperCase().substring(0, 1) +
getConfig().app.gateway.mode.toLocaleUpperCase().substring(1)
getConfig().app.gateway.mode.toLocaleUpperCase().substring(0, 1) +
getConfig().app.gateway.mode.toLocaleUpperCase().substring(1)
);
await OpenApiValidatorMiddleware.getInstance().initOpenApiMiddleware();
console.log('Open API Validator Initialized');
});
OpenApiValidatorMiddleware.getInstance().initOpenApiMiddleware();
console.log("Open API Validator Initialized");
} catch (err) {
if (err instanceof Exception) {
logger.error(err.toString());
Expand Down

0 comments on commit 6862187

Please sign in to comment.