Skip to content

Commit 55fa7fa

Browse files
authored
feat: remove logging
- to prepare for the beta phase, logging is reduced
1 parent 1c5aeaf commit 55fa7fa

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

src/index.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ let redirect_uri;
6363

6464
app.get('/login', async (req, res) => {
6565
const params = req.query;
66-
logger.debug('req.headers', req.headers);
67-
logger.debug('req: ', req.protocol, req.hostname, req.baseUrl, req.url, req.originalUrl, req.path, req.query);
6866

6967
const proto = req.headers['x-forwarded-proto'] || req.protocol;
7068
const host = req.headers['x-forwarded-host'] || req.headers.host;
@@ -107,15 +105,11 @@ app.get('/callback', async (req, res) => {
107105

108106
client.callback(redirect_uri.toString(), params, { code_verifier: client.code_verifier })
109107
.then(tokenSet => {
110-
111-
logger.debug('tokenSet', tokenSet);
112108
const user = jwt.decode(tokenSet.id_token);
113-
114109
const token = tokenSet.id_token;
115110

116111
res.cookie('token', token, { maxAge: 86400000, httpOnly: true, secure: true, sameSite: 'none' });
117112
const return_url = req.cookies.return_url || "/";
118-
logger.debug('return_url', return_url);
119113
res.redirect(return_url);
120114
})
121115
.catch(err => {
@@ -161,7 +155,6 @@ const checkAuth = (req, res, next) => {
161155
if (!token && req.headers.authorization) {
162156
token = req.headers.authorization.split(' ')[1];
163157
}
164-
logger.debug('token', token);
165158

166159
if (!token) {
167160
return res.status(401).json({ message: 'Token not found' });
@@ -240,8 +233,6 @@ function logResponseBody(req, res, next) {
240233

241234
res.write = function (chunk) {
242235
chunks.push(Buffer.from(chunk));
243-
console.log('chunk', chunk.toString('utf8'));
244-
console.log('remote headers', res.getHeaders());
245236
oldWrite.apply(res, arguments);
246237
};
247238

@@ -250,19 +241,16 @@ function logResponseBody(req, res, next) {
250241
chunks.push(Buffer.from(chunk));
251242

252243
let body = Buffer.concat(chunks).toString('utf8');
253-
logger.debug(req.path, body);
254-
255244
oldEnd.apply(res, arguments);
256245
};
257246

258247
res.on('data', () => {
259-
logger.debug('remote headers', res.getHeaders());
248+
260249
});
261250

251+
/** Logs the request to the database */
262252
res.on('finish', () => {
263-
logger.debug(`request url = ${req.originalUrl}`);
264253
const headers = res.getHeaders();
265-
logger.debug("headers: ", headers);
266254

267255
const request = {
268256
user: req.user,
@@ -300,12 +288,10 @@ const doProxy = (req, res) => {
300288
proxyReqOptDecorator: function (proxyReqOpts, srcReq) {
301289
proxyReqOpts.headers['authorization'] = `Bearer ${API_KEY}`;
302290
proxyReqOpts.headers['OpenAI-Beta'] = 'assistants=v2';
303-
console.log('proxyReqOpts', proxyReqOpts.headers);
304291
return proxyReqOpts;
305292
},
306293
proxyReqBodyDecorator: function (bodyContent, srcReq) {
307294
if (!srcReq.body || srcReq.method === 'GET') {
308-
logger.debug('no body content in GET request');
309295
return "";
310296
}
311297

@@ -318,7 +304,6 @@ const doProxy = (req, res) => {
318304
parseReqBody: false,
319305
proxyReqPathResolver: function (req) {
320306
const path = req.baseUrl.replace(PREFIX, '/v1');
321-
logger.debug('path: ', req.baseUrl, path);
322307
return path;
323308
},
324309
proxyErrorHandler: function (err, res, next) {
@@ -332,7 +317,6 @@ const doProxy = (req, res) => {
332317
proxyReqOptDecorator: function (proxyReqOpts, srcReq) {
333318
proxyReqOpts.headers['authorization'] = `Bearer ${API_KEY}`;
334319
proxyReqOpts.headers['OpenAI-Beta'] = 'assistants=v2';
335-
console.log('proxyReqOpts', proxyReqOpts.headers);
336320
return proxyReqOpts;
337321
},
338322
})

0 commit comments

Comments
 (0)