Socket
Socket
Sign inDemoInstall

next-aws-cloudfront

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-aws-cloudfront - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0-alpha.0

48

__tests__/next-aws-cloudfront.response.test.js

@@ -24,3 +24,3 @@ const zlib = require("zlib");

it("statusCode statusCode=200", () => {
expect.assertions(1);
expect.assertions(2);

@@ -39,5 +39,23 @@ const { res, responsePromise } = create({

expect(response.status).toEqual(200);
expect(response.statusDescription).toEqual("OK");
});
});
it("statusCode statusCode=200 by default", () => {
expect.assertions(1);
const { res, responsePromise } = create({
request: {
uri: "/",
headers: {}
}
});
res.end();
return responsePromise.then(response => {
expect(response.status).toEqual(200);
});
});
it("writeHead headers", () => {

@@ -270,2 +288,4 @@ expect.assertions(1);

it(`res.write('ok')`, () => {
expect.assertions(2);
const { res, responsePromise } = create({

@@ -283,2 +303,3 @@ request: {

expect(response.body).toEqual("b2s=");
expect(response.bodyEncoding).toEqual("base64");
});

@@ -288,2 +309,4 @@ });

it(`res.end('ok')`, () => {
expect.assertions(1);
const { res, responsePromise } = create({

@@ -304,2 +327,4 @@ request: {

it(`gzips`, () => {
expect.assertions(2);
const gzipSpy = jest.spyOn(zlib, "gzipSync");

@@ -333,2 +358,23 @@ gzipSpy.mockReturnValueOnce(Buffer.from("ok-gzipped"));

});
it("response does not have a body if only statusCode is set", () => {
expect.assertions(4);
const { res, responsePromise } = create({
request: {
path: "/",
headers: {}
}
});
res.statusCode = 204;
res.end();
return responsePromise.then(response => {
expect(response.body).not.toBeDefined();
expect(response.bodyEncoding).not.toBeDefined();
expect(response.status).toEqual(204);
expect(response.statusDescription).toEqual("No Content");
});
});
});

37

CHANGELOG.md

@@ -6,32 +6,24 @@ # Change Log

# [1.2.0](https://github.com/danielcondemarin/serverless-next.js/compare/next-aws-cloudfront@1.2.0-alpha.1...next-aws-cloudfront@1.2.0) (2020-06-05)
# [1.3.0-alpha.0](https://github.com/danielcondemarin/serverless-next.js/compare/next-aws-cloudfront@1.2.0...next-aws-cloudfront@1.3.0-alpha.0) (2020-06-12)
**Note:** Version bump only for package next-aws-cloudfront
### Features
- **next-aws-lambda,next-aws-cloudfront:** fix status code and body bugs ([#437](https://github.com/danielcondemarin/serverless-next.js/issues/437)) ([7291f83](https://github.com/danielcondemarin/serverless-next.js/commit/7291f83f58eaa09733e3ce2df494afc2c0e04f9a))
# [1.2.0](https://github.com/danielcondemarin/serverless-next.js/compare/next-aws-cloudfront@1.2.0-alpha.1...next-aws-cloudfront@1.2.0) (2020-06-05)
**Note:** Version bump only for package next-aws-cloudfront
# [1.2.0-alpha.1](https://github.com/danielcondemarin/serverless-next.js/compare/next-aws-cloudfront@1.2.0-alpha.0...next-aws-cloudfront@1.2.0-alpha.1) (2020-05-31)
### Features
* **lambda-at-edge:** autogenerate serverless config ([#418](https://github.com/danielcondemarin/serverless-next.js/issues/418)) ([0f9a176](https://github.com/danielcondemarin/serverless-next.js/commit/0f9a176f65207d31d0b66a11d6fbceafe27fade5))
- **lambda-at-edge:** autogenerate serverless config ([#418](https://github.com/danielcondemarin/serverless-next.js/issues/418)) ([0f9a176](https://github.com/danielcondemarin/serverless-next.js/commit/0f9a176f65207d31d0b66a11d6fbceafe27fade5))
# [1.2.0-alpha.0](https://github.com/danielcondemarin/serverless-next.js/compare/next-aws-cloudfront@1.1.1...next-aws-cloudfront@1.2.0-alpha.0) (2020-05-15)
### Features
* **serverless-component:** implement getStaticProps / getStaticPaths [fallback: false] ([#390](https://github.com/danielcondemarin/serverless-next.js/issues/390)) ([5185649](https://github.com/danielcondemarin/serverless-next.js/commit/518564944435767759fae8ae5978baf3afc49d7a))
- **serverless-component:** implement getStaticProps / getStaticPaths [fallback: false](<[#390](https://github.com/danielcondemarin/serverless-next.js/issues/390)>) ([5185649](https://github.com/danielcondemarin/serverless-next.js/commit/518564944435767759fae8ae5978baf3afc49d7a))
## [1.1.1](https://github.com/danielcondemarin/serverless-next.js/compare/next-aws-cloudfront@1.1.0...next-aws-cloudfront@1.1.1) (2020-05-06)

@@ -41,6 +33,2 @@

# [1.1.0](https://github.com/danielcondemarin/serverless-next.js/compare/next-aws-cloudfront@1.1.0-alpha.0...next-aws-cloudfront@1.1.0) (2020-04-25)

@@ -50,19 +38,10 @@

# [1.1.0-alpha.0](https://github.com/danielcondemarin/serverless-next.js/compare/next-aws-cloudfront@1.0.1...next-aws-cloudfront@1.1.0-alpha.0) (2020-04-23)
### Features
* **lambda-at-edge:** create new package with Lambda@Edge builder and handlers ([94f0a29](https://github.com/danielcondemarin/serverless-next.js/commit/94f0a29f0654f51d60653c8218c15802b2abb476))
- **lambda-at-edge:** create new package with Lambda@Edge builder and handlers ([94f0a29](https://github.com/danielcondemarin/serverless-next.js/commit/94f0a29f0654f51d60653c8218c15802b2abb476))
## 1.0.1 (2020-04-13)
**Note:** Version bump only for package next-aws-cloudfront

@@ -36,2 +36,59 @@ const Stream = require("stream");

const HttpStatusCodes = {
202: "Accepted",
502: "Bad Gateway",
400: "Bad Request",
409: "Conflict",
100: "Continue",
201: "Created",
417: "Expectation Failed",
424: "Failed Dependency",
403: "Forbidden",
504: "Gateway Timeout",
410: "Gone",
505: "HTTP Version Not Supported",
418: "I'm a teapot",
419: "Insufficient Space on Resource",
507: "Insufficient Storage",
500: "Server Error",
411: "Length Required",
423: "Locked",
420: "Method Failure",
405: "Method Not Allowed",
301: "Moved Permanently",
302: "Moved Temporarily",
207: "Multi-Status",
300: "Multiple Choices",
511: "Network Authentication Required",
204: "No Content",
203: "Non Authoritative Information",
406: "Not Acceptable",
404: "Not Found",
501: "Not Implemented",
304: "Not Modified",
200: "OK",
206: "Partial Content",
402: "Payment Required",
308: "Permanent Redirect",
412: "Precondition Failed",
428: "Precondition Required",
102: "Processing",
407: "Proxy Authentication Required",
431: "Request Header Fields Too Large",
408: "Request Timeout",
413: "Request Entity Too Large",
414: "Request-URI Too Long",
416: "Requested Range Not Satisfiable",
205: "Reset Content",
303: "See Other",
503: "Service Unavailable",
101: "Switching Protocols",
307: "Temporary Redirect",
429: "Too Many Requests",
401: "Unauthorized",
422: "Unprocessable Entity",
415: "Unsupported Media Type",
305: "Use Proxy"
};
const toCloudFrontHeaders = headers => {

@@ -87,6 +144,2 @@ const result = {};

const response = {
body: Buffer.from(""),
bodyEncoding: "base64",
status: 200,
statusDescription: "OK",
headers: {}

@@ -146,2 +199,3 @@ };

response.status = statusCode;
response.statusDescription = HttpStatusCodes[statusCode];
}

@@ -153,2 +207,3 @@ });

response.status = status;
if (headers) {

@@ -159,2 +214,6 @@ res.headers = Object.assign(res.headers, headers);

res.write = chunk => {
if (!response.body) {
response.body = Buffer.from("");
}
response.body = Buffer.concat([

@@ -165,2 +224,3 @@ response.body,

};
let gz = isGzipSupported(headers);

@@ -171,6 +231,16 @@

if (text) res.write(text);
if (!res.statusCode) {
res.statusCode = 200;
}
res.finished = true;
response.body = gz
? zlib.gzipSync(response.body).toString("base64")
: Buffer.from(response.body).toString("base64");
if (response.body) {
response.bodyEncoding = "base64";
response.body = gz
? zlib.gzipSync(response.body).toString("base64")
: Buffer.from(response.body).toString("base64");
}
response.headers = toCloudFrontHeaders(res.headers);

@@ -177,0 +247,0 @@

{
"name": "next-aws-cloudfront",
"version": "1.2.0",
"version": "1.3.0-alpha.0",
"description": "Compat layer for running next.js apps in Lambda@Edge",

@@ -27,3 +27,3 @@ "main": "next-aws-cloudfront.js",

},
"gitHead": "52ba33bd3197feb1989331813b831563a64d647c"
"gitHead": "b4819e0997d2fd78e8c5c033c2441a0fe7bb6410"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc