routup 0.1.4 → 0.2.0

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,5 +1,4 @@
1
1
  export * from './mount-path';
2
- export * from './body';
3
2
  export * from './env';
4
3
  export * from './header';
5
4
  export * from './header-accept';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/index.ts"],"names":[],"mappings":"AAOA,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/index.ts"],"names":[],"mappings":"AAOA,cAAc,cAAc,CAAC;AAC7B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
@@ -21,7 +21,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  __exportStar(require("./mount-path"), exports);
24
- __exportStar(require("./body"), exports);
25
24
  __exportStar(require("./env"), exports);
26
25
  __exportStar(require("./header"), exports);
27
26
  __exportStar(require("./header-accept"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/request/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,+CAA6B;AAC7B,yCAAuB;AACvB,wCAAsB;AACtB,2CAAyB;AACzB,kDAAgC;AAChC,0DAAwC;AACxC,2DAAyC;AACzC,2DAAyC;AACzC,wDAAsC;AACtC,+CAA6B;AAC7B,2CAAyB;AACzB,yCAAuB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/request/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,+CAA6B;AAC7B,wCAAsB;AACtB,2CAAyB;AACzB,kDAAgC;AAChC,0DAAwC;AACxC,2DAAyC;AACzC,2DAAyC;AACzC,wDAAsC;AACtC,+CAA6B;AAC7B,2CAAyB;AACzB,yCAAuB"}
@@ -1,4 +1,3 @@
1
- export * from './body';
2
1
  export * from './cache';
3
2
  export * from './header';
4
3
  export * from './header-attachment';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/index.ts"],"names":[],"mappings":"AAOA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/index.ts"],"names":[],"mappings":"AAOA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
@@ -20,7 +20,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
20
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- __exportStar(require("./body"), exports);
24
23
  __exportStar(require("./cache"), exports);
25
24
  __exportStar(require("./header"), exports);
26
25
  __exportStar(require("./header-attachment"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/response/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,yCAAuB;AACvB,0CAAwB;AACxB,2CAAyB;AACzB,sDAAoC;AACpC,wDAAsC;AACtC,yCAAuB;AACvB,8CAA4B;AAC5B,gDAA8B;AAC9B,gDAA8B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/response/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,0CAAwB;AACxB,2CAAyB;AACzB,sDAAoC;AACpC,wDAAsC;AACtC,yCAAuB;AACvB,8CAA4B;AAC5B,gDAA8B;AAC9B,gDAA8B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "routup",
3
- "version": "0.1.4",
3
+ "version": "0.2.0",
4
4
  "description": "Routup is a minimalistic http based routing framework.",
5
5
  "main": "./dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -52,5 +52,5 @@
52
52
  "path-to-regexp": "^6.2.1",
53
53
  "smob": "^0.0.6"
54
54
  },
55
- "gitHead": "5444f2afa2efa299780fafdf33645963d90cd6a9"
55
+ "gitHead": "437eab266f760bd855b06baee914e738c185433c"
56
56
  }
@@ -1,5 +0,0 @@
1
- /// <reference types="node" />
2
- import { IncomingMessage } from 'http';
3
- export declare function useRequestBody(req: IncomingMessage): unknown | undefined;
4
- export declare function setRequestBody(req: IncomingMessage, body: unknown): void;
5
- //# sourceMappingURL=body.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"body.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/body.ts"],"names":[],"mappings":";AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAIvC,wBAAgB,cAAc,CAAC,GAAG,EAAE,eAAe,GAAI,OAAO,GAAG,SAAS,CAUzE;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,QAEjE"}
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setRequestBody = exports.useRequestBody = void 0;
4
- const BodySymbol = Symbol.for('ReqBody');
5
- function useRequestBody(req) {
6
- if ('body' in req) {
7
- return req.body;
8
- }
9
- if (BodySymbol in req) {
10
- return req[BodySymbol];
11
- }
12
- return undefined;
13
- }
14
- exports.useRequestBody = useRequestBody;
15
- function setRequestBody(req, body) {
16
- req[BodySymbol] = body;
17
- }
18
- exports.setRequestBody = setRequestBody;
19
- //# sourceMappingURL=body.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"body.js","sourceRoot":"","sources":["../../../src/helpers/request/body.ts"],"names":[],"mappings":";;;AAQA,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAEzC,SAAgB,cAAc,CAAC,GAAoB;IAC/C,IAAI,MAAM,IAAI,GAAG,EAAE;QACf,OAAQ,GAAW,CAAC,IAAI,CAAC;KAC5B;IAED,IAAI,UAAU,IAAI,GAAG,EAAE;QACnB,OAAQ,GAAW,CAAC,UAAU,CAAC,CAAC;KACnC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAVD,wCAUC;AAED,SAAgB,cAAc,CAAC,GAAoB,EAAE,IAAa;IAC7D,GAAW,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;AACpC,CAAC;AAFD,wCAEC"}
@@ -1,7 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { ServerResponse } from 'http';
4
- export declare function useResponseBody(res: ServerResponse): Buffer | undefined;
5
- export declare function setResponseBody(res: ServerResponse, body: Buffer): void;
6
- export declare function useResponseBodyFormatted(res: ServerResponse): unknown;
7
- //# sourceMappingURL=body.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"body.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/body.ts"],"names":[],"mappings":";;AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAKtC,wBAAgB,eAAe,CAAC,GAAG,EAAE,cAAc,GAAI,MAAM,GAAG,SAAS,CAMxE;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,QAEhE;AAGD,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,cAAc,GAAI,OAAO,CAyBtE"}
@@ -1,48 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.useResponseBodyFormatted = exports.setResponseBody = exports.useResponseBody = void 0;
10
- const constants_1 = require("../../constants");
11
- const BodySymbol = Symbol.for('ResBody');
12
- function useResponseBody(res) {
13
- if (BodySymbol in res) {
14
- return res[BodySymbol];
15
- }
16
- return undefined;
17
- }
18
- exports.useResponseBody = useResponseBody;
19
- function setResponseBody(res, body) {
20
- res[BodySymbol] = body;
21
- }
22
- exports.setResponseBody = setResponseBody;
23
- /* istanbul ignore next */
24
- function useResponseBodyFormatted(res) {
25
- const body = useResponseBody(res);
26
- if (typeof body === 'undefined') {
27
- return undefined;
28
- }
29
- let contentType = res.getHeader(constants_1.HeaderName.CONTENT_TYPE);
30
- if (!contentType) {
31
- return contentType;
32
- }
33
- if (Array.isArray(contentType)) {
34
- contentType = contentType.shift();
35
- }
36
- else {
37
- contentType = `${contentType}`.split('; ').shift();
38
- }
39
- switch (contentType) {
40
- case 'application/json':
41
- return JSON.parse(body.toString('utf-8'));
42
- case 'text/html':
43
- return body.toString('utf-8');
44
- }
45
- return body;
46
- }
47
- exports.useResponseBodyFormatted = useResponseBodyFormatted;
48
- //# sourceMappingURL=body.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"body.js","sourceRoot":"","sources":["../../../src/helpers/response/body.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,+CAA6C;AAE7C,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAEzC,SAAgB,eAAe,CAAC,GAAmB;IAC/C,IAAI,UAAU,IAAI,GAAG,EAAE;QACnB,OAAQ,GAAW,CAAC,UAAU,CAAC,CAAC;KACnC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAND,0CAMC;AAED,SAAgB,eAAe,CAAC,GAAmB,EAAE,IAAY;IAC5D,GAAW,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;AACpC,CAAC;AAFD,0CAEC;AAED,0BAA0B;AAC1B,SAAgB,wBAAwB,CAAC,GAAmB;IACxD,MAAM,IAAI,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,OAAO,IAAI,KAAK,WAAW,EAAE;QAC7B,OAAO,SAAS,CAAC;KACpB;IAED,IAAI,WAAW,GAAG,GAAG,CAAC,SAAS,CAAC,sBAAU,CAAC,YAAY,CAAC,CAAC;IACzD,IAAI,CAAC,WAAW,EAAE;QACd,OAAO,WAAW,CAAC;KACtB;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;QAC5B,WAAW,GAAG,WAAW,CAAC,KAAK,EAAE,CAAC;KACrC;SAAM;QACH,WAAW,GAAG,GAAG,WAAW,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;KACtD;IAED,QAAQ,WAAW,EAAE;QACjB,KAAK,kBAAkB;YACnB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QAC9C,KAAK,WAAW;YACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;KACrC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAzBD,4DAyBC"}