Skip to content

Commit

Permalink
Merge pull request #27 from yracnet/v1.1.x
Browse files Browse the repository at this point in the history
hot fix
  • Loading branch information
yracnet authored Nov 13, 2024
2 parents 4021b29 + e169b5c commit 40495ed
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@vitejs/plugin-react-swc": "^3.6.0",
"typescript": "^5.4.4",
"vite": "^5.2.8",
"vite-plugin-api-routes": "file:../vite-plugin-api-routes-v1.1.10.tgz",
"vite-plugin-api-routes": "file:../vite-plugin-api-routes-v1.1.12.tgz",
"vite-plugin-chunk-split": "^0.5.0"
}
}
6 changes: 3 additions & 3 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1238,9 +1238,9 @@ vary@~1.1.2:
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==

"vite-plugin-api-routes@file:../vite-plugin-api-routes-v1.1.10.tgz":
version "1.1.10"
resolved "file:../vite-plugin-api-routes-v1.1.10.tgz#3fb1787d1f63eb73ec7487ecf29b2134531ffa97"
"vite-plugin-api-routes@file:../vite-plugin-api-routes-v1.1.12.tgz":
version "1.1.12"
resolved "file:../vite-plugin-api-routes-v1.1.12.tgz#da9871fa07f71db96d2d03de8a8b4ba818b4be02"
dependencies:
fast-glob "^3.3.2"
slash-path "^0.0.1"
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite-plugin-api-routes",
"version": "1.1.11",
"version": "1.1.12",
"type": "module",
"description": "A Vite.js plugin that creates API routes by mapping the directory structure, similar to Next.js API Routes. This plugin enhances the functionality for backend development using Vite.",
"keywords": [
Expand Down Expand Up @@ -54,6 +54,7 @@
"bugs": "https://github.com/yracnet/vite-plugin-api-routes/issues",
"scripts": {
"build": "tsup",
"tar": "yarn pack",
"prepublish": "yarn build",
"prepack": "yarn build"
},
Expand Down
35 changes: 18 additions & 17 deletions src/plugin/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const pluginImpl = (config: PluginConfig): PluginOption => {
enforce: "pre",
config: () => {
return {
// appType: "custom",
resolve: {
alias: {
[`${config.moduleId}/root`]: config.root,
Expand Down Expand Up @@ -60,23 +61,23 @@ export const pluginImpl = (config: PluginConfig): PluginOption => {
});
//@ts-ignore
configure.viteServerBefore?.(devServer.middlewares, devServer, vite);
return () => {
// Register Proxy After Vite Inicialize
middlewares.use(baseApi, async (req, res, next) => {
try {
const { handler } = await ssrLoadModule(config.handler, {
fixStacktrace: true,
});
handler(req, res, next);
} catch (error) {
ssrFixStacktrace(error as Error);
process.exitCode = 1;
next(error);
}
});
//@ts-ignore
configure.viteServerAfter?.(devServer.middlewares, devServer, vite);
};
// Register Proxy After Vite Inicialize
middlewares.use(baseApi, async (req, res, next) => {
try {
const { handler } = await ssrLoadModule(config.handler, {
fixStacktrace: true,
});
handler(req, res, next);
} catch (error) {
ssrFixStacktrace(error as Error);
process.exitCode = 1;
next(error);
}
});
//@ts-ignore
configure.viteServerAfter?.(devServer.middlewares, devServer, vite);
// return () => {
// };
},
writeBundle: async () => {
if (process.env.IS_API_BUILD) return;
Expand Down

0 comments on commit 40495ed

Please sign in to comment.