Skip to content

Commit

Permalink
fix: resolve cookie dependency import issue. #29
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Dec 2, 2024
1 parent 9ade8dd commit 23020a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 7 additions & 4 deletions core/src/Driver.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import express, { Express, Request, Response, NextFunction } from 'express';
import { DataSource } from 'typeorm';
import { TypeormStore } from 'connect-typeorm';
import cookie from 'cookie';
import { parse as cookieParse } from 'cookie';
import multerFn, { DiskStorageOptions, Options } from 'multer';
import bodyParser from 'body-parser';
import compression from 'compression';
Expand Down Expand Up @@ -43,7 +43,10 @@ export abstract class Driver {
* Special function used to get currently authorized user.
*/
public currentUserChecker?: TypeNexusOptions['currentUserChecker'];
constructor(portOrOptions: number | TypeNexusOptions = 3000, public options: TypeNexusOptions = {}) {
constructor(
portOrOptions: number | TypeNexusOptions = 3000,
public options: TypeNexusOptions = {},
) {
if (typeof portOrOptions === 'object') {
this.options = portOrOptions;
}
Expand Down Expand Up @@ -343,12 +346,12 @@ export abstract class Driver {

case 'cookie':
if (!request.headers?.cookie) return;
const cookies = cookie.parse(request.headers.cookie);
const cookies = cookieParse(request.headers.cookie);
return cookies[param.name];

case 'cookies':
if (!request.headers?.cookie) return {};
return cookie.parse(request.headers.cookie);
return cookieParse(request.headers.cookie);
}
}
/**
Expand Down
1 change: 0 additions & 1 deletion examples/base/test/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ describe('API request test case', () => {
.set('Accept', 'text/html')
.expect('Content-Type', /html/)
.expect(200)
console.log('req.text:', req.text)
expect(req.text).toEqual('<html>Test</html>');
});
});
Expand Down

0 comments on commit 23020a8

Please sign in to comment.