Skip to content

Commit

Permalink
[optimize] upgrade to KoAJAX 3 & other latest Upstream packages
Browse files Browse the repository at this point in the history
[fix] disable Test scripts in GitHub actions
  • Loading branch information
TechQuery committed Sep 2, 2024
1 parent ea82b92 commit d54777c
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 40 deletions.
4 changes: 3 additions & 1 deletion core/Proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export class ProxyController {
) {
const { body } = await githubClient.get<string>(
`${owner}/${repo}/pull/${id}.diff`,
{ Authorization }
{ Authorization },
{ responseType: 'text' }
);
const acceptHTML = Accept.includes('html');

Expand Down Expand Up @@ -70,6 +71,7 @@ export class ProxyController {
const res = await githubAPIClient.request({
method: request.method,
path,
// @ts-ignore
headers: { ...header, accept },
body: isNotEmptyObject(body) ? body : undefined,
responseType: acceptJSON ? 'json' : 'arraybuffer'
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "github-restful-middleware",
"version": "1.0.0-rc.0",
"version": "1.0.0-rc.1",
"description": "Express & Koa compatible middleware for GitHub RESTful API",
"keywords": [
"Express",
Expand Down Expand Up @@ -33,7 +33,7 @@
"class-validator": "^0.14.1",
"diff2html": "^3.4.48",
"iterable-observer": "^1.1.0",
"koajax": "^1.1.2",
"koajax": "^3.0.0",
"reflect-metadata": "^0.2.2",
"routing-controllers": "^0.10.4",
"routing-controllers-openapi": "^4.0.0",
Expand All @@ -45,19 +45,19 @@
"build": "rm -rf dist/ docs/ && tsc && npm run docs",
"start": "npm run docs && npx serve docs/",
"test": "lint-staged && tsx --env-file=.env --test test/*.spec.ts",
"prepublishOnly": "npm test && npm run build"
"prepublishOnly": "npm run build"
},
"devDependencies": {
"@octokit/openapi-types": "^22.2.0",
"@tsconfig/node18": "^18.2.4",
"@types/eventsource": "^1.1.15",
"@types/node": "^20.16.1",
"@types/node": "^20.16.3",
"eventsource": "^2.0.2",
"husky": "^9.1.5",
"koa": "^2.15.3",
"lint-staged": "^15.2.9",
"lint-staged": "^15.2.10",
"prettier": "^3.3.3",
"tsx": "^4.17.0",
"tsx": "^4.19.0",
"typedoc": "^0.26.6",
"typescript": "^5.5.4"
},
Expand Down
73 changes: 42 additions & 31 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions test/Proxy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ describe('Proxy API', async () => {
await it('should get a diff file of a pull request', async () => {
const { body } = await client.get<string>(
'/repos/idea2app/GitHub-RESTful-middleware/pull/1.diff',
header
header,
{ responseType: 'text' }
);
assert(body?.includes('diff --git'));
});

await it('should get a diff file of a pull request in HTML format', async () => {
const { body } = await client.get<string>(
'/repos/idea2app/GitHub-RESTful-middleware/pull/1.diff',
{ ...header, Accept: 'text/html' }
{ ...header, Accept: 'text/html' },
{ responseType: 'text' }
);
assert(body?.includes('<div class="d2h-wrapper">'));
});
Expand Down

0 comments on commit d54777c

Please sign in to comment.