lumen-framework 3.0.1 → 3.0.3

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.
@@ -2,7 +2,7 @@
2
2
  * @private
3
3
  */
4
4
  declare class NotAcceptableError extends TypeError {
5
- constructor(contentType: string);
5
+ constructor(accept: string);
6
6
  }
7
7
  declare const _default: new (...args: Array<any>) => NotAcceptableError & import("../../server/interfaces").Server$Error;
8
8
  export default _default;
@@ -1,5 +1,7 @@
1
1
  export * from './constants';
2
2
  export * from './errors';
3
3
  export { default as isJSONAPI } from './utils/is-jsonapi';
4
- export { default as hasMediaType } from './utils/has-media-type';
4
+ export { default as hasMediaTypeParams } from './utils/has-media-type-params';
5
+ export { parseAccept, parseMediaType } from './utils/media-type';
6
+ export type { MediaType } from './utils/media-type';
5
7
  export type { JSONAPI$versions, JSONAPI$Document, JSONAPI$ErrorObject, JSONAPI$DocumentLinks, JSONAPI$ResourceObject, JSONAPI$IdentifierObject, JSONAPI$RelationshipObject } from './interfaces';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Whether a media type (e.g. a `Content-Type` value) carries parameters.
3
+ *
4
+ * @private
5
+ */
6
+ export default function hasMediaTypeParams(value: string): boolean;
@@ -1,4 +1,6 @@
1
1
  /**
2
+ * Whether a media type is the JSON:API media type, ignoring parameters.
3
+ *
2
4
  * @private
3
5
  */
4
6
  export default function isJSONAPI(value: string): boolean;
@@ -0,0 +1,19 @@
1
+ export type MediaType = {
2
+ type: string;
3
+ params: Array<string>;
4
+ };
5
+ /**
6
+ * Parse a single media type, e.g. a `Content-Type` header value.
7
+ *
8
+ * @private
9
+ */
10
+ export declare function parseMediaType(value: string): MediaType;
11
+ /**
12
+ * Parse an `Accept` header into its media ranges.
13
+ *
14
+ * Per RFC 7231 §5.3.2 the `q` weight (and any accept-extension after it) is
15
+ * not a media type parameter, so it is not reported in `params`.
16
+ *
17
+ * @private
18
+ */
19
+ export declare function parseAccept(value: string): Array<MediaType>;
@@ -1,4 +1,8 @@
1
1
  /**
2
+ * JSON:API 1.0: respond 406 if the Accept header contains the JSON:API media
3
+ * type and *all* instances of it are modified with media type parameters.
4
+ * An Accept header without the JSON:API media type is left alone.
5
+ *
2
6
  * @private
3
7
  */
4
- export default function validateAccept(contentType?: string): true;
8
+ export default function validateAccept(accept?: string): true;
@@ -1,4 +1,8 @@
1
1
  /**
2
+ * JSON:API 1.0: respond 415 if the Content-Type is the JSON:API media type
3
+ * with any media type parameters. A missing or different Content-Type is
4
+ * also answered with 415, since that is the only type the server accepts.
5
+ *
2
6
  * @private
3
7
  */
4
8
  export default function validateContentType(contentType?: string): true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lumen-framework",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "Build scalable, Node.js-powered REST APIs with almost no code.",
5
5
  "keywords": [
6
6
  "mvc",
@@ -1,4 +0,0 @@
1
- /**
2
- * @private
3
- */
4
- export default function hasMediaType(value: string): boolean;