This repository has been archived by the owner on Nov 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: switch tsc to preconstruct.tools
- Loading branch information
Showing
36 changed files
with
1,074 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module.exports = { | ||
presets: [ | ||
'@babel/preset-typescript', | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
targets: { | ||
node: '12', | ||
}, | ||
}, | ||
], | ||
], | ||
plugins: [['@babel/plugin-proposal-class-properties', { loose: true }]], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,8 @@ | |
"author": "Lxxyx <[email protected]>", | ||
"homepage": "https://github.com/midwayjs/hooks", | ||
"license": "MIT", | ||
"main": "lib/index.js", | ||
"main": "dist/midwayjs-hooks-core.cjs.js", | ||
"module": "dist/midwayjs-hooks-core.esm.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "[email protected]:midwayjs/hooks.git" | ||
|
@@ -38,10 +39,17 @@ | |
"koa-static-cache": "^5.1.4", | ||
"lodash": "^4.17.21", | ||
"pkg-dir": "^5.0.0", | ||
"tslib": "^2.1.0", | ||
"upath": "^2.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/es-module-lexer": "^0.3.0", | ||
"@types/koa-static-cache": "^5.1.0" | ||
}, | ||
"preconstruct": { | ||
"entrypoints": [ | ||
"request/index.ts", | ||
"index.ts" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"main": "dist/midwayjs-hooks-core-request.cjs.js", | ||
"module": "dist/midwayjs-hooks-core-request.esm.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,39 @@ | ||
import type { LambdaParam } from '../types/http' | ||
import axios from 'axios' | ||
import { LambdaParam } from '../types/http' | ||
|
||
export const defaults = axios.defaults | ||
const defaults = axios.defaults | ||
|
||
export async function request(param: LambdaParam) { | ||
async function request(param: LambdaParam) { | ||
const response = await axios(param) | ||
return response.data | ||
} | ||
/** | ||
* @internal private api | ||
*/ | ||
|
||
function createRequest(baseUrl, name) { | ||
return (...args) => { | ||
return request({ | ||
url: getUrl(baseUrl, name), | ||
method: args.length === 0 ? 'GET' : 'POST', | ||
data: { | ||
args, | ||
}, | ||
meta: {}, | ||
}) | ||
} | ||
} | ||
|
||
function getUrl(baseUrl, name) { | ||
if (name === 'default') { | ||
return baseUrl | ||
} | ||
|
||
if (baseUrl.endsWith('/')) { | ||
return `${baseUrl}${name}` | ||
} | ||
|
||
return `${baseUrl}/${name}` | ||
} | ||
|
||
export { createRequest, defaults, request } |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/hooks-loader/src/__tests__/__snapshots__/hooks-loader.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.