@shuvi/platform-web 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,5 @@
1
1
  import { ShuviRequest, ShuviResponse, ShuviRequestHandler } from '@shuvi/service';
2
2
  export interface IApiReq {
3
- cookies: {
4
- [key: string]: string;
5
- };
6
3
  body?: {
7
4
  [key: string]: any;
8
5
  };
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- import { IncomingMessage } from 'http';
3
1
  import { ShuviRequest, ShuviResponse } from '@shuvi/service';
4
2
  import { IApiRequestHandler, IApiResponse } from '../../../../shared';
5
3
  export { IApiRequestHandler };
@@ -9,13 +7,6 @@ export declare function apiRouteHandler(req: ShuviRequest, res: ShuviResponse, r
9
7
  * @param req request object
10
8
  */
11
9
  export declare function parseBody(req: ShuviRequest, limit: string | number): Promise<any>;
12
- /**
13
- * Parse cookies from `req` header
14
- * @param req request object
15
- */
16
- export declare function getCookieParser(req: IncomingMessage): {
17
- [key: string]: string;
18
- };
19
10
  /**
20
11
  *
21
12
  * @param res ServerResponse object
@@ -35,10 +35,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.ApiError = exports.sendJson = exports.sendData = exports.redirect = exports.sendStatusCode = exports.getCookieParser = exports.parseBody = exports.apiRouteHandler = void 0;
38
+ exports.ApiError = exports.sendJson = exports.sendData = exports.redirect = exports.sendStatusCode = exports.parseBody = exports.apiRouteHandler = void 0;
39
39
  const stream_1 = require("stream");
40
40
  const querystring = __importStar(require("querystring"));
41
- const cookie = __importStar(require("cookie"));
42
41
  const getRawBody = require('raw-body');
43
42
  const contentType = __importStar(require("content-type"));
44
43
  const logger_1 = __importDefault(require("@shuvi/utils/lib/logger"));
@@ -46,10 +45,7 @@ function apiRouteHandler(req, res, resolver, apiRoutesConfig) {
46
45
  return __awaiter(this, void 0, void 0, function* () {
47
46
  try {
48
47
  const { bodyParser } = apiRoutesConfig || {};
49
- const apiReq = {
50
- // Parsing of cookies
51
- cookies: getCookieParser(req)
52
- };
48
+ const apiReq = {};
53
49
  // Parsing of body
54
50
  if (bodyParser && !apiReq.body) {
55
51
  apiReq.body = yield parseBody(req, bodyParser && bodyParser.sizeLimit ? bodyParser.sizeLimit : '1mb');
@@ -135,18 +131,6 @@ function parseJson(str) {
135
131
  throw new ApiError(400, 'Invalid JSON');
136
132
  }
137
133
  }
138
- /**
139
- * Parse cookies from `req` header
140
- * @param req request object
141
- */
142
- function getCookieParser(req) {
143
- const header = req.headers.cookie;
144
- if (!header) {
145
- return {};
146
- }
147
- return cookie.parse(Array.isArray(header) ? header.join(';') : header);
148
- }
149
- exports.getCookieParser = getCookieParser;
150
134
  /**
151
135
  *
152
136
  * @param res ServerResponse object
@@ -1,8 +1,5 @@
1
1
  import { ShuviRequest, ShuviResponse, ShuviRequestHandler } from '@shuvi/service';
2
2
  export interface IApiReq {
3
- cookies: {
4
- [key: string]: string;
5
- };
6
3
  body?: {
7
4
  [key: string]: any;
8
5
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuvi/platform-web",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/shuvijs/shuvi.git",
@@ -51,7 +51,7 @@
51
51
  ]
52
52
  },
53
53
  "./shuvi-type-extensions-node": {
54
- "types": "./shuvi-type-extensions-node.d.js",
54
+ "types": "./shuvi-type-extensions-node.d.ts",
55
55
  "default": "./shuvi-type-extensions-node.js"
56
56
  },
57
57
  "./shuvi-type-extensions-runtime": "./shuvi-type-extensions-runtime.d.ts",
@@ -72,20 +72,19 @@
72
72
  },
73
73
  "dependencies": {
74
74
  "@next/react-refresh-utils": "12.1.6",
75
- "@shuvi/error-overlay": "1.0.0",
76
- "@shuvi/hook": "1.0.0",
77
- "@shuvi/platform-shared": "1.0.0",
75
+ "@shuvi/error-overlay": "1.0.1",
76
+ "@shuvi/hook": "1.0.1",
77
+ "@shuvi/platform-shared": "1.0.1",
78
78
  "@shuvi/redox": "0.0.7",
79
79
  "@shuvi/redox-react": "0.0.7",
80
- "@shuvi/router": "1.0.0",
81
- "@shuvi/router-react": "1.0.0",
82
- "@shuvi/runtime": "1.0.0",
83
- "@shuvi/service": "1.0.0",
84
- "@shuvi/shared": "1.0.0",
85
- "@shuvi/toolpack": "1.0.0",
86
- "@shuvi/utils": "1.0.0",
80
+ "@shuvi/router": "1.0.1",
81
+ "@shuvi/router-react": "1.0.1",
82
+ "@shuvi/runtime": "1.0.1",
83
+ "@shuvi/service": "1.0.1",
84
+ "@shuvi/shared": "1.0.1",
85
+ "@shuvi/toolpack": "1.0.1",
86
+ "@shuvi/utils": "1.0.1",
87
87
  "content-type": "1.0.4",
88
- "cookie": "0.4.1",
89
88
  "core-js": "3.6.5",
90
89
  "ejs": "3.1.5",
91
90
  "fs-extra": "9.0.1",
@@ -100,12 +99,11 @@
100
99
  "whatwg-fetch": "3.0.0"
101
100
  },
102
101
  "peerDependencies": {
103
- "@shuvi/service": "1.0.0"
102
+ "@shuvi/service": "1.0.1"
104
103
  },
105
104
  "devDependencies": {
106
105
  "@testing-library/react": "^13.2.0",
107
106
  "@types/content-type": "^1.1.5",
108
- "@types/cookie": "^0.4.1",
109
107
  "@types/ejs": "^3.1.0",
110
108
  "@types/raw-body": "^2.3.0",
111
109
  "@types/react": "18.0.9",