Skip to content

Commit

Permalink
chore(dev-ex): make moesif optional for local dev (#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
jatinsandilya authored Oct 30, 2023
1 parent 9362592 commit 9eb2fe9
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions packages/backend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,22 @@ const testv2Router = (_req: Request, res: Response) => {
res.send({ data: 'v2 hit' });
};

// 2. Set the options, the only required field is applicationId
const moesifMiddleware = moesif({
applicationId: config.MOESIF_APPLICATION_ID!,
debug: process.env.NODE_ENV !== 'production', // enable debug mode.
logBody: true,
// Optional hook to link API calls to users
identifyUser: function (req: any, _: any) {
return req.headers['x-revert-t-id'] ? req.headers['x-revert-t-id'] : undefined;
},
identifyCompany: function (_: any, res: any) {
return res.locals?.account?.id;
},
});

app.use(moesifMiddleware);
if (config.MOESIF_APPLICATION_ID) {
// Set the options, the only required field is applicationId
const moesifMiddleware = moesif({
applicationId: config.MOESIF_APPLICATION_ID!,
debug: process.env.NODE_ENV !== 'production', // enable debug mode.
logBody: true,
// Optional hook to link API calls to users
identifyUser: function (req: any, _: any) {
return req.headers['x-revert-t-id'] ? req.headers['x-revert-t-id'] : undefined;
},
identifyCompany: function (_: any, res: any) {
return res.locals?.account?.id;
},
});
app.use(moesifMiddleware);
}

app.use(
'/',
Expand Down

1 comment on commit 9eb2fe9

@vercel
Copy link

@vercel vercel bot commented on 9eb2fe9 Oct 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

revert-client – ./

revert-client-git-main-revertdev.vercel.app
revert-client-revertdev.vercel.app
app.revert.dev

Please sign in to comment.