Skip to content

Commit

Permalink
Merge pull request #256 from storyofams/beta
Browse files Browse the repository at this point in the history
Release v1.5.8
  • Loading branch information
ggurkal authored Sep 17, 2021
2 parents d9ac0e7 + 19b0a90 commit 66810f1
Show file tree
Hide file tree
Showing 4 changed files with 265 additions and 140 deletions.
2 changes: 1 addition & 1 deletion lib/internals/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ async function runMainLayer(
res.send(returnValue.contents);
}
} else {
res.json(returnValue ?? null);
res.send(returnValue ?? null);
}
}

Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@
},
"devDependencies": {
"@commitlint/cli": "13.1.0",
"@commitlint/config-conventional": "12.1.4",
"@commitlint/config-conventional": "13.1.0",
"@semantic-release/changelog": "5.0.1",
"@storyofams/eslint-config-ams": "1.1.2",
"@types/express": "^4.17.11",
"@types/express-rate-limit": "^5.1.1",
"@types/jest": "^26.0.20",
"@types/jest": "^27.0.1",
"@types/multer": "^1.4.5",
"@types/response-time": "^2.3.4",
"@types/supertest": "^2.0.10",
"@typescript-eslint/eslint-plugin": "4.28.4",
"@typescript-eslint/parser": "4.28.4",
"@typescript-eslint/eslint-plugin": "4.31.0",
"@typescript-eslint/parser": "4.31.1",
"class-transformer": "0.4.0",
"class-validator": "0.13.1",
"cz-customizable": "git+https://github.com/storyofams/cz-customizable.git#v6.3.2",
Expand All @@ -68,17 +68,17 @@
"eslint-plugin-prettier": "3.3.1",
"express": "^4.17.1",
"express-rate-limit": "^5.2.6",
"husky": "7.0.1",
"husky": "7.0.2",
"jest": "26.6.3",
"lint-staged": "11.1.1",
"lint-staged": "11.1.2",
"multer": "^1.4.2",
"next": "11.1.1",
"next": "11.1.2",
"path-to-regexp": "^6.2.0",
"pinst": "^2.1.6",
"prettier": "2.2.1",
"react": "^17.0.2",
"response-time": "^2.3.2",
"semantic-release": "17.4.4",
"semantic-release": "17.4.7",
"supertest": "^6.1.3",
"ts-jest": "26.5.6",
"typescript": "4.1.3"
Expand Down
44 changes: 44 additions & 0 deletions test/e2e-buffer.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import 'reflect-metadata';
import request from 'supertest';
import { createHandler, Get, SetHeader } from '../lib';
import { setupServer } from './setupServer';

const nextJsLogo = Buffer.from(
'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAA6UlEQVQ4ja3TMUpDYRAE4K8wYCM2kljb2IidvU2apE1ErNQcQMFCjRohx/AUXkOPYERvYBUkihKLf5+8BM3LEwe2WXaGf2b35x+xiibaBdWM2Qlc4B0jvBTUCG/oZuQOhmhhYY6XVmJ2iAN4xGUZr4ErPMAn6ljBxhzEdawF5wPG2MaulMPxDHIHrzgJzjgvAHuSt1ss54iLuJECPIrejwKwGd6ecIZTDPCMrdzcrwKwhGvc4R79qRdNCGQhlsV3iAN/W2NPrPFQCq4tHUkRKtgJzn7W7ErnWeaUz6eVa2go/kwNVEtYnY0vxaFKHj8ZCrUAAAAASUVORK5CYII=',
'base64'
);

class TestHandler {
@Get()
@SetHeader('Content-Type', 'image/png')
public image() {
return nextJsLogo;
}
}

describe('E2E - Buffer', () => {
let server: ReturnType<typeof setupServer>;
beforeAll(() => {
server = setupServer(createHandler(TestHandler));
});

afterAll(() => {
if ('close' in server && typeof server.close === 'function') {
server.close();
}
});

it('Should return the image with the correct headers.', () =>
request(server)
.get('/')
.expect(200)
.then(res =>
expect(res).toMatchObject({
header: {
'content-type': 'image/png',
'content-length': nextJsLogo.length.toString()
},
body: nextJsLogo
})
));
});
Loading

1 comment on commit 66810f1

@vercel
Copy link

@vercel vercel bot commented on 66810f1 Sep 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please # to comment.