Skip to content

Commit

Permalink
feat: support node version >=16
Browse files Browse the repository at this point in the history
  • Loading branch information
412799755 committed Oct 26, 2023
1 parent 980013b commit 3da6394
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
3 changes: 0 additions & 3 deletions core/controller-decorator/src/decorator/http/HTTPParam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ export function HTTPParam(param?: HTTPParamParams) {

export function Request() {
return function(target: any, propertyKey: PropertyKey, parameterIndex: number) {
const [ nodeMajor ] = process.versions.node.split('.').map(v => Number(v));
assert(nodeMajor >= 16,
`[controller/${target.name}] expect node version >=16, but now is ${nodeMajor}`);
assert(typeof propertyKey === 'string',
`[controller/${target.name}] expect method name be typeof string, but now is ${String(propertyKey)}`);
const methodName = propertyKey as string;
Expand Down
40 changes: 22 additions & 18 deletions plugin/controller/test/http/params.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,26 @@ describe('test/params.test.ts', () => {
});
});

it('Request should work', async () => {
app.mockCsrf();
const param = {
name: 'foo',
desc: 'mock-desc',
};
const headerKey = 'test-header';
await app.httpRequest()
.post('/apps')
.send(param)
.set('test', headerKey)
.expect(200)
.expect(res => {
assert(res.body.headers.test === headerKey);
assert(res.body.method === 'POST');
assert(res.body.requestBody === JSON.stringify(param));
});
});
const [ nodeMajor ] = process.versions.node.split('.').map(v => Number(v));
if (nodeMajor >= 16) {
it('Request should work', async () => {
app.mockCsrf();
const param = {
name: 'foo',
desc: 'mock-desc',
};
const headerKey = 'test-header';
await app.httpRequest()
.post('/apps')
.send(param)
.set('test', headerKey)
.expect(200)
.expect(res => {
assert(res.body.headers.test === headerKey);
assert(res.body.method === 'POST');
assert(res.body.requestBody === JSON.stringify(param));
});
});
}

});

0 comments on commit 3da6394

Please sign in to comment.