Skip to content

Commit

Permalink
Merge branch 'main' into chore/biome
Browse files Browse the repository at this point in the history
  • Loading branch information
paciops committed Sep 13, 2024
2 parents 8f2a906 + 17a4345 commit bcb00f7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
14 changes: 9 additions & 5 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ export type MiddleWareConfig = {
showErrorDetail?: boolean;
};

export type AppOptions = {
express?: () => Express;
jsonParserLimit?: string | number;
};

/**
* Systemic component that creates and configures an Express app
* @param options optionally a function that creates a basic Express app can be passed into the component
*/
export function app(options?: { express?: () => Express }): CallbackComponent<
Express,
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
{ config?: AppConfig; logger?: any }
>;
export function app(
options?: AppOptions,
// biome-ignore lint/suspicious/noExplicitAny: no assumption on the logger
): CallbackComponent<Express, { config?: AppConfig; logger?: any }>;

/**
* Starts the Express server
Expand Down
8 changes: 6 additions & 2 deletions lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const debug = require("debug")("systemic-express:app");
const bodyParser = require("body-parser");
const { errorMiddleware } = require("./errorMiddleware");

// default value from body-parser lib
const defaultJsonParserLimit = "100kb";

module.exports = (options) => {
const express = get(options, "express") || require("express");
let config;
Expand All @@ -21,8 +24,9 @@ module.exports = (options) => {
}

function start(cb) {
const jsonParserLimit = options?.jsonParserLimit || defaultJsonParserLimit;
const app = express();
const jsonParser = bodyParser.json();
const jsonParser = bodyParser.json({ limit: jsonParserLimit });

app.locals.logger = logger;
app.use(jsonParser);
Expand All @@ -36,7 +40,7 @@ module.exports = (options) => {
cb(null, app);
}

function statusMiddleware(_, res, __) {
function statusMiddleware(_req, res, _next) {
res.json({ status: "Success", environment: process.env.IL_ENV });
}
return {
Expand Down

0 comments on commit bcb00f7

Please sign in to comment.