Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/auth-react-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ morgan.token("body", function (req, res) {
});

morgan.token("res-body", function (req, res) {
return typeof res.__custombody__ ? res.__custombody__ : JSON.stringify(res.__custombody__);
return typeof res.__custombody__ === "string" ? res.__custombody__ : JSON.stringify(res.__custombody__);
});

app.use(urlencodedParser);
Expand Down
126 changes: 126 additions & 0 deletions test/test-server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/test-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"dependencies": {
"debug": "^4.3.5",
"express": "^4.19.2",
"morgan": "^1.10.0",
"nock": "^13.5.4",
"typescript": "^5.4.5"
},
Expand Down
13 changes: 12 additions & 1 deletion test/test-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import { resetOverrideLogs, logOverrideEvent, getOverrideLogs } from "./override
import Dashboard from "../../../recipe/dashboard";
import DashboardRecipe from "../../../lib/build/recipe/dashboard/recipe";
import { TypeInput as WebauthnTypeInput } from "../../../lib/build/recipe/webauthn/types";

import morgan from "morgan";
const { logDebugMessage } = logger("com.supertokens:node-test-server");

const API_PORT = Number(process.env.API_PORT || 3030);
Expand Down Expand Up @@ -163,6 +163,7 @@ function initST(config: any) {
"Session.getCookieNameForTokenType",
getCookieNameForTokenType
),
getTokenTransferMethod: () => config.getTokenTransferMethod ?? "any",
override: {
apis: overrideBuilderWithLogging("Session.override.apis", config?.override?.apis),
functions: overrideBuilderWithLogging(
Expand Down Expand Up @@ -387,13 +388,23 @@ function initST(config: any) {
supertokens.init(init);
}

morgan.token("body", function (req, res) {
return JSON.stringify(req.body);
});

morgan.token("res-body", function (req, res) {
return typeof res.__custombody__ === "string" ? res.__custombody__ : JSON.stringify(res.__custombody__);
});

const app = express();
app.use(express.json());
app.use((req, res, next) => {
logDebugMessage(req.method, req.path);
next();
});
app.use(middleware());
app.use(morgan("[:date[iso]] :url :method :body", { immediate: true }));
app.use(morgan("[:date[iso]] :url :method :status :response-time ms - :res[content-length] :res-body"));

app.get("/test/ping", async (req, res, next) => {
res.json({ ok: true });
Expand Down
Loading