-
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC-v2.0] Support AutoImport #22
Comments
AutoImport function is provided by autoImport: {
presets: [
{
from: '@swordjs/h3',
imports: ['sendError']
}
]
} In the ts file, you'll be able to use const autoImportsPresets: Preset[] = [
{
from: '@swordjs/sword-framework'.
imports: ['useApi', 'useApp', 'usePipeline', 'usePlugin', 'useGetApiMap', 'usePlatform', 'usePlatformHook', 'useIsDev', 'useIsProd']
}
]. This allows us to quickly write code like this: import { ReqQuery, ReqParams, Res } from '. /proto'.
export default useApi<{
query: ReqQuery.
params: ReqParams.
res: Res.
}>({
handler: async (ctx) => {
console.log(sendError).
return {
message: 'hello world'
}.
}
}). And the Since the dev environment of sword.js is using esbuild-register to open a new sub-process to execute functions, and also enjoy auto-import, we changed the source code of |
No description provided.
The text was updated successfully, but these errors were encountered: