yracnet / vite-plugin-api-routes

Create API routes from path directory like to Nextjs
MIT License
29 stars 4 forks source link

Error when building for production #20

Closed dotmartin closed 7 months ago

dotmartin commented 8 months ago

Hiya,

We are using the plugin to get a small API up and running in the Vite server. It works perfectly when running the dev server. But when building for production (vite build) we get this error:

error during build:
Error: [vite-plugin-rest-api] [vite:define] Transform failed with 3 errors:
error: Invalid define value (must be an entity name or valid JSON syntax): /api
error: Invalid define value (must be an entity name or valid JSON syntax): ..
error: Invalid define value (must be an entity name or valid JSON syntax): /
file: /Users/.../ui-library/.api/server.js
file: /Users/.../ui-library/.api/server.js
    at failureErrorWithLog (/Users/.../ui-library/node_modules/esbuild/lib/main.js:1651:15)
    at /Users/.../ui-library/node_modules/esbuild/lib/main.js:849:29
    at responseCallbacks.<computed> (/Users/.../ui-library/node_modules/esbuild/lib/main.js:704:9)
    at handleIncomingPacket (/Users/.../ui-library/node_modules/esbuild/lib/main.js:764:9)
....

We are using the default server.js file. Seems like the esbuild transpiler throws the error. Is this something you guys have seen before?

Thanks in advance!

tteke commented 8 months ago

Hello. I'm having the same issue. Is there an idea why this would happen?

yracnet commented 8 months ago

please,, could you share the files

And share the full path to /ui-library directory (because I see the windows directory path)

Or share the project in github

dotmartin commented 8 months ago

Sorry @yracnet, we ended up writing our own server file for the small API we needed. So I cannot really give you the info you are looking for.

Perhaps @tteke can take over?

Anyway, we did not do any specific configuration. Everything was pretty much out of the box. Aside from the fact that we where using a monorepo using NPM Workspaces. The Vite instance is running in one of the sub-packages.

Hope that gives you some kind idea! Otherwise please let me know if I should close this issue or how you want to proceed. Cheers!

tteke commented 8 months ago

I am using empty configuration object so no special options. And I am on Mac so no windows pathing for me

dotmartin commented 8 months ago

And I am on Mac so no windows pathing for me

For the record, I'm also on mac.

tteke commented 8 months ago

I am also verge of writing up my own server when I get the chance tbh. Because this library causes many errors for me during development. I also have commented on another issue which causes the vite to constantly restart bundling and enter into infinite loop unless I start vite in debug mode.

yracnet commented 8 months ago

Hi @tteke @dotmartin

I was thinking the error could be caused by an invalid encoding path when generating the file, perhaps a space or importing methods from an empty file. However, the generated files will give us more information about the error.

tteke commented 8 months ago

Do you mean the generated files in the .api/ directory ?

yracnet commented 8 months ago

Yes, the plugin generate a files in .api directory, and delegate to the vite-watch the refresh procesos, the logs show that exist a malformat code in this files

tteke commented 8 months ago

Here are the generated files:

configure.js


import express from "express";

// ViteServerHook
// @WARNING: Please don't include the VITE TYPES here, because it has a problem when you build the project
export const viteServerBefore = (server, viteServer) => {
    server.use(express.json());
    server.use(express.urlencoded({ extended: true }));
};

// @WARNING: Please don't include the VITE TYPES here, because it has a problem when you build the project
export const viteServerAfter = (server, viteServer) => {
    server.use((error, req, res, next) => {
        if (error instanceof Error) {
            return res.status(403).json({ error: error.message });
        }
        next(error);
    });
};

// ServerHook
export const serverBefore = (server) => {
    server.use(express.json());
    server.use(express.urlencoded({ extended: true }));
};

export const serverAfter = (server) => {
    server.use((error, req, res, next) => {
        if (error instanceof Error) {
            return res.status(403).json({ error: error.message });
        }
        next(error);
    });
};

// HandlerHook
export const handlerBefore = (handler) => {
};

export const handlerAfter = (server) => {
};

// CallbackHook
export const callbackBefore = (callback, route) => {
    return callback;
};

// StatusHook
export const serverListening = (server) => {

};

export const serverError = (server, error) => {

};

handler.js


import express from "express";
import { applyRouters } from "@api/routers";
import * as configure from "@api/configure";

export const handler = express();

configure.handlerBefore?.(handler);

applyRouters(
  (props) => {
    const { method, route, path, cb } = props;
    if (handler[method]) {
      if(Array.isArray(cb)) {
        handler[method](route, ...cb);
      } else {
        handler[method](route, cb);
      }
    } else {
      console.log("Not Support", method, "for", route, "in", handler);
    }
  }
);

configure.handlerAfter?.(handler);

routers.js


// Imports
import * as _0_0 from "//Users/tteke/Workspace/company-manager/src/api/absent.js";
import * as _0_1 from "//Users/tteke/Workspace/company-manager/src/api/events.js";
import * as _0_2 from "//Users/tteke/Workspace/company-manager/src/api/roster/[eventId].js";
import * as _0_3 from "//Users/tteke/Workspace/company-manager/src/api/server-channels.js";
import * as _0_4 from "//Users/tteke/Workspace/company-manager/src/api/server-users.js";
import * as _0_5 from "//Users/tteke/Workspace/company-manager/src/api/stats/[eventId].js";
import * as _0_6 from "//Users/tteke/Workspace/company-manager/src/api/user.js";
import * as _0_7 from "//Users/tteke/Workspace/company-manager/src/api/users.js";
import * as configure from "@api/configure";

export const routeBase = "/api";

const internal  = [
  _0_0.default && {
        source     : "src/api/absent.js?fn=default",
        method     : "use",
        route      : "/absent",
        path       : "/api/absent",
        url        : "/api/absent",
        cb         : _0_0.default,
      },
  _0_0.GET && {
        source     : "src/api/absent.js?fn=GET",
        method     : "get",
        route      : "/absent",
        path       : "/api/absent",
        url        : "/api/absent",
        cb         : _0_0.GET,
      },
  _0_0.PUT && {
        source     : "src/api/absent.js?fn=PUT",
        method     : "put",
        route      : "/absent",
        path       : "/api/absent",
        url        : "/api/absent",
        cb         : _0_0.PUT,
      },
  _0_0.POST && {
        source     : "src/api/absent.js?fn=POST",
        method     : "post",
        route      : "/absent",
        path       : "/api/absent",
        url        : "/api/absent",
        cb         : _0_0.POST,
      },
  _0_0.PATCH && {
        source     : "src/api/absent.js?fn=PATCH",
        method     : "patch",
        route      : "/absent",
        path       : "/api/absent",
        url        : "/api/absent",
        cb         : _0_0.PATCH,
      },
  _0_0.DELETE && {
        source     : "src/api/absent.js?fn=DELETE",
        method     : "delete",
        route      : "/absent",
        path       : "/api/absent",
        url        : "/api/absent",
        cb         : _0_0.DELETE,
      },
  _0_1.default && {
        source     : "src/api/events.js?fn=default",
        method     : "use",
        route      : "/events",
        path       : "/api/events",
        url        : "/api/events",
        cb         : _0_1.default,
      },
  _0_1.GET && {
        source     : "src/api/events.js?fn=GET",
        method     : "get",
        route      : "/events",
        path       : "/api/events",
        url        : "/api/events",
        cb         : _0_1.GET,
      },
  _0_1.PUT && {
        source     : "src/api/events.js?fn=PUT",
        method     : "put",
        route      : "/events",
        path       : "/api/events",
        url        : "/api/events",
        cb         : _0_1.PUT,
      },
  _0_1.POST && {
        source     : "src/api/events.js?fn=POST",
        method     : "post",
        route      : "/events",
        path       : "/api/events",
        url        : "/api/events",
        cb         : _0_1.POST,
      },
  _0_1.PATCH && {
        source     : "src/api/events.js?fn=PATCH",
        method     : "patch",
        route      : "/events",
        path       : "/api/events",
        url        : "/api/events",
        cb         : _0_1.PATCH,
      },
  _0_1.DELETE && {
        source     : "src/api/events.js?fn=DELETE",
        method     : "delete",
        route      : "/events",
        path       : "/api/events",
        url        : "/api/events",
        cb         : _0_1.DELETE,
      },
  _0_2.default && {
        source     : "src/api/roster/[eventId].js?fn=default",
        method     : "use",
        route      : "/roster/:eventId",
        path       : "/api/roster/:eventId",
        url        : "/api/roster/:eventId",
        cb         : _0_2.default,
      },
  _0_2.GET && {
        source     : "src/api/roster/[eventId].js?fn=GET",
        method     : "get",
        route      : "/roster/:eventId",
        path       : "/api/roster/:eventId",
        url        : "/api/roster/:eventId",
        cb         : _0_2.GET,
      },
  _0_2.PUT && {
        source     : "src/api/roster/[eventId].js?fn=PUT",
        method     : "put",
        route      : "/roster/:eventId",
        path       : "/api/roster/:eventId",
        url        : "/api/roster/:eventId",
        cb         : _0_2.PUT,
      },
  _0_2.POST && {
        source     : "src/api/roster/[eventId].js?fn=POST",
        method     : "post",
        route      : "/roster/:eventId",
        path       : "/api/roster/:eventId",
        url        : "/api/roster/:eventId",
        cb         : _0_2.POST,
      },
  _0_2.PATCH && {
        source     : "src/api/roster/[eventId].js?fn=PATCH",
        method     : "patch",
        route      : "/roster/:eventId",
        path       : "/api/roster/:eventId",
        url        : "/api/roster/:eventId",
        cb         : _0_2.PATCH,
      },
  _0_2.DELETE && {
        source     : "src/api/roster/[eventId].js?fn=DELETE",
        method     : "delete",
        route      : "/roster/:eventId",
        path       : "/api/roster/:eventId",
        url        : "/api/roster/:eventId",
        cb         : _0_2.DELETE,
      },
  _0_3.default && {
        source     : "src/api/server-channels.js?fn=default",
        method     : "use",
        route      : "/server-channels",
        path       : "/api/server-channels",
        url        : "/api/server-channels",
        cb         : _0_3.default,
      },
  _0_3.GET && {
        source     : "src/api/server-channels.js?fn=GET",
        method     : "get",
        route      : "/server-channels",
        path       : "/api/server-channels",
        url        : "/api/server-channels",
        cb         : _0_3.GET,
      },
  _0_3.PUT && {
        source     : "src/api/server-channels.js?fn=PUT",
        method     : "put",
        route      : "/server-channels",
        path       : "/api/server-channels",
        url        : "/api/server-channels",
        cb         : _0_3.PUT,
      },
  _0_3.POST && {
        source     : "src/api/server-channels.js?fn=POST",
        method     : "post",
        route      : "/server-channels",
        path       : "/api/server-channels",
        url        : "/api/server-channels",
        cb         : _0_3.POST,
      },
  _0_3.PATCH && {
        source     : "src/api/server-channels.js?fn=PATCH",
        method     : "patch",
        route      : "/server-channels",
        path       : "/api/server-channels",
        url        : "/api/server-channels",
        cb         : _0_3.PATCH,
      },
  _0_3.DELETE && {
        source     : "src/api/server-channels.js?fn=DELETE",
        method     : "delete",
        route      : "/server-channels",
        path       : "/api/server-channels",
        url        : "/api/server-channels",
        cb         : _0_3.DELETE,
      },
  _0_4.default && {
        source     : "src/api/server-users.js?fn=default",
        method     : "use",
        route      : "/server-users",
        path       : "/api/server-users",
        url        : "/api/server-users",
        cb         : _0_4.default,
      },
  _0_4.GET && {
        source     : "src/api/server-users.js?fn=GET",
        method     : "get",
        route      : "/server-users",
        path       : "/api/server-users",
        url        : "/api/server-users",
        cb         : _0_4.GET,
      },
  _0_4.PUT && {
        source     : "src/api/server-users.js?fn=PUT",
        method     : "put",
        route      : "/server-users",
        path       : "/api/server-users",
        url        : "/api/server-users",
        cb         : _0_4.PUT,
      },
  _0_4.POST && {
        source     : "src/api/server-users.js?fn=POST",
        method     : "post",
        route      : "/server-users",
        path       : "/api/server-users",
        url        : "/api/server-users",
        cb         : _0_4.POST,
      },
  _0_4.PATCH && {
        source     : "src/api/server-users.js?fn=PATCH",
        method     : "patch",
        route      : "/server-users",
        path       : "/api/server-users",
        url        : "/api/server-users",
        cb         : _0_4.PATCH,
      },
  _0_4.DELETE && {
        source     : "src/api/server-users.js?fn=DELETE",
        method     : "delete",
        route      : "/server-users",
        path       : "/api/server-users",
        url        : "/api/server-users",
        cb         : _0_4.DELETE,
      },
  _0_5.default && {
        source     : "src/api/stats/[eventId].js?fn=default",
        method     : "use",
        route      : "/stats/:eventId",
        path       : "/api/stats/:eventId",
        url        : "/api/stats/:eventId",
        cb         : _0_5.default,
      },
  _0_5.GET && {
        source     : "src/api/stats/[eventId].js?fn=GET",
        method     : "get",
        route      : "/stats/:eventId",
        path       : "/api/stats/:eventId",
        url        : "/api/stats/:eventId",
        cb         : _0_5.GET,
      },
  _0_5.PUT && {
        source     : "src/api/stats/[eventId].js?fn=PUT",
        method     : "put",
        route      : "/stats/:eventId",
        path       : "/api/stats/:eventId",
        url        : "/api/stats/:eventId",
        cb         : _0_5.PUT,
      },
  _0_5.POST && {
        source     : "src/api/stats/[eventId].js?fn=POST",
        method     : "post",
        route      : "/stats/:eventId",
        path       : "/api/stats/:eventId",
        url        : "/api/stats/:eventId",
        cb         : _0_5.POST,
      },
  _0_5.PATCH && {
        source     : "src/api/stats/[eventId].js?fn=PATCH",
        method     : "patch",
        route      : "/stats/:eventId",
        path       : "/api/stats/:eventId",
        url        : "/api/stats/:eventId",
        cb         : _0_5.PATCH,
      },
  _0_5.DELETE && {
        source     : "src/api/stats/[eventId].js?fn=DELETE",
        method     : "delete",
        route      : "/stats/:eventId",
        path       : "/api/stats/:eventId",
        url        : "/api/stats/:eventId",
        cb         : _0_5.DELETE,
      },
  _0_6.default && {
        source     : "src/api/user.js?fn=default",
        method     : "use",
        route      : "/user",
        path       : "/api/user",
        url        : "/api/user",
        cb         : _0_6.default,
      },
  _0_6.GET && {
        source     : "src/api/user.js?fn=GET",
        method     : "get",
        route      : "/user",
        path       : "/api/user",
        url        : "/api/user",
        cb         : _0_6.GET,
      },
  _0_6.PUT && {
        source     : "src/api/user.js?fn=PUT",
        method     : "put",
        route      : "/user",
        path       : "/api/user",
        url        : "/api/user",
        cb         : _0_6.PUT,
      },
  _0_6.POST && {
        source     : "src/api/user.js?fn=POST",
        method     : "post",
        route      : "/user",
        path       : "/api/user",
        url        : "/api/user",
        cb         : _0_6.POST,
      },
  _0_6.PATCH && {
        source     : "src/api/user.js?fn=PATCH",
        method     : "patch",
        route      : "/user",
        path       : "/api/user",
        url        : "/api/user",
        cb         : _0_6.PATCH,
      },
  _0_6.DELETE && {
        source     : "src/api/user.js?fn=DELETE",
        method     : "delete",
        route      : "/user",
        path       : "/api/user",
        url        : "/api/user",
        cb         : _0_6.DELETE,
      },
  _0_7.default && {
        source     : "src/api/users.js?fn=default",
        method     : "use",
        route      : "/users",
        path       : "/api/users",
        url        : "/api/users",
        cb         : _0_7.default,
      },
  _0_7.GET && {
        source     : "src/api/users.js?fn=GET",
        method     : "get",
        route      : "/users",
        path       : "/api/users",
        url        : "/api/users",
        cb         : _0_7.GET,
      },
  _0_7.PUT && {
        source     : "src/api/users.js?fn=PUT",
        method     : "put",
        route      : "/users",
        path       : "/api/users",
        url        : "/api/users",
        cb         : _0_7.PUT,
      },
  _0_7.POST && {
        source     : "src/api/users.js?fn=POST",
        method     : "post",
        route      : "/users",
        path       : "/api/users",
        url        : "/api/users",
        cb         : _0_7.POST,
      },
  _0_7.PATCH && {
        source     : "src/api/users.js?fn=PATCH",
        method     : "patch",
        route      : "/users",
        path       : "/api/users",
        url        : "/api/users",
        cb         : _0_7.PATCH,
      },
  _0_7.DELETE && {
        source     : "src/api/users.js?fn=DELETE",
        method     : "delete",
        route      : "/users",
        path       : "/api/users",
        url        : "/api/users",
        cb         : _0_7.DELETE,
      }
].filter(it => it);

export const routers = internal.map((it) => {
  const { method, path, route, url, source } = it;
  return { method, url, path, route, source };
});

export const endpoints = internal.map(
  (it) => it.method?.toUpperCase() + "\t" + it.url
);

export const applyRouters = (applyRouter) => {
  internal.forEach((it) => {
    it.cb = configure.callbackBefore?.(it.cb, it) || it.cb;
    applyRouter(it);
  });
};

server.js


import { handler } from "@api/handler";
import { endpoints } from "@api/routers";
import * as configure from "@api/configure";
import express from "express";

const server = express();
configure.serverBefore?.(server);
const { PORT = 3000, PUBLIC_DIR = "import.meta.env.PUBLIC_DIR" } = process.env;
server.use("import.meta.env.BASE", express.static(PUBLIC_DIR));
server.use("import.meta.env.BASE_API", handler);
configure.serverAfter?.(server);
server.on("error", (error) => {
  console.error(`Error at http://localhost:${PORT}import.meta.env.BASE`, error);
  configure.serverError?.(server, error);
});
server.listen(PORT, () => {
  console.log(`Ready at http://localhost:${PORT}import.meta.env.BASE`);
  configure.serverListening?.(server, endpoints);
});
yracnet commented 8 months ago

//Users/tteke/Workspace/company-manager/src/api/absent.js"; the double "/" at start string will be the error in your environment, I will push a possible fix

yracnet commented 8 months ago

Hi @tteke I publish a new version https://www.npmjs.com/package/vite-plugin-api-routes/v/1.1.3-beta for fix this error

tteke commented 8 months ago

Hey again @yracnet. Just installed 1.1.7-beta. It seems to have fixed #17 so I dont have to run the dev server on debug mode anymore. But when I tried to run build, I get error like this

image
tteke commented 8 months ago

And routers.js changed like this :


// Imports
import * as _0_0 from "@api/root/src/api/absent.js";
import * as _0_1 from "@api/root/src/api/events.js";
import * as _0_2 from "@api/root/src/api/roster/[eventId].js";
import * as _0_3 from "@api/root/src/api/server-channels.js";
import * as _0_4 from "@api/root/src/api/server-users.js";
import * as _0_5 from "@api/root/src/api/stats/[eventId].js";
import * as _0_6 from "@api/root/src/api/user.js";
import * as _0_7 from "@api/root/src/api/users.js";
import * as configure from "@api/configure";

export const routeBase = "/api";

const internal  = [
  _0_0.default && {
        source     : "src/api/absent.js?fn=default",
        method     : "use",
        route      : "/absent",
        path       : "/api/absent",
        url        : "/api/absent",
        cb         : _0_0.default,
      },
  _0_0.GET && {
        source     : "src/api/absent.js?fn=GET",
        method     : "get",
        route      : "/absent",
        path       : "/api/absent",
        url        : "/api/absent",
        cb         : _0_0.GET,
      },
  _0_0.PUT && {
        source     : "src/api/absent.js?fn=PUT",
        method     : "put",
        route      : "/absent",
        path       : "/api/absent",
        url        : "/api/absent",
        cb         : _0_0.PUT,
      },
  _0_0.POST && {
        source     : "src/api/absent.js?fn=POST",
        method     : "post",
        route      : "/absent",
        path       : "/api/absent",
        url        : "/api/absent",
        cb         : _0_0.POST,
      },
  _0_0.PATCH && {
        source     : "src/api/absent.js?fn=PATCH",
        method     : "patch",
        route      : "/absent",
        path       : "/api/absent",
        url        : "/api/absent",
        cb         : _0_0.PATCH,
      },
  _0_0.DELETE && {
        source     : "src/api/absent.js?fn=DELETE",
        method     : "delete",
        route      : "/absent",
        path       : "/api/absent",
        url        : "/api/absent",
        cb         : _0_0.DELETE,
      },
  _0_1.default && {
        source     : "src/api/events.js?fn=default",
        method     : "use",
        route      : "/events",
        path       : "/api/events",
        url        : "/api/events",
        cb         : _0_1.default,
      },
  _0_1.GET && {
        source     : "src/api/events.js?fn=GET",
        method     : "get",
        route      : "/events",
        path       : "/api/events",
        url        : "/api/events",
        cb         : _0_1.GET,
      },
  _0_1.PUT && {
        source     : "src/api/events.js?fn=PUT",
        method     : "put",
        route      : "/events",
        path       : "/api/events",
        url        : "/api/events",
        cb         : _0_1.PUT,
      },
  _0_1.POST && {
        source     : "src/api/events.js?fn=POST",
        method     : "post",
        route      : "/events",
        path       : "/api/events",
        url        : "/api/events",
        cb         : _0_1.POST,
      },
  _0_1.PATCH && {
        source     : "src/api/events.js?fn=PATCH",
        method     : "patch",
        route      : "/events",
        path       : "/api/events",
        url        : "/api/events",
        cb         : _0_1.PATCH,
      },
  _0_1.DELETE && {
        source     : "src/api/events.js?fn=DELETE",
        method     : "delete",
        route      : "/events",
        path       : "/api/events",
        url        : "/api/events",
        cb         : _0_1.DELETE,
      },
  _0_2.default && {
        source     : "src/api/roster/[eventId].js?fn=default",
        method     : "use",
        route      : "/roster/:eventId",
        path       : "/api/roster/:eventId",
        url        : "/api/roster/:eventId",
        cb         : _0_2.default,
      },
  _0_2.GET && {
        source     : "src/api/roster/[eventId].js?fn=GET",
        method     : "get",
        route      : "/roster/:eventId",
        path       : "/api/roster/:eventId",
        url        : "/api/roster/:eventId",
        cb         : _0_2.GET,
      },
  _0_2.PUT && {
        source     : "src/api/roster/[eventId].js?fn=PUT",
        method     : "put",
        route      : "/roster/:eventId",
        path       : "/api/roster/:eventId",
        url        : "/api/roster/:eventId",
        cb         : _0_2.PUT,
      },
  _0_2.POST && {
        source     : "src/api/roster/[eventId].js?fn=POST",
        method     : "post",
        route      : "/roster/:eventId",
        path       : "/api/roster/:eventId",
        url        : "/api/roster/:eventId",
        cb         : _0_2.POST,
      },
  _0_2.PATCH && {
        source     : "src/api/roster/[eventId].js?fn=PATCH",
        method     : "patch",
        route      : "/roster/:eventId",
        path       : "/api/roster/:eventId",
        url        : "/api/roster/:eventId",
        cb         : _0_2.PATCH,
      },
  _0_2.DELETE && {
        source     : "src/api/roster/[eventId].js?fn=DELETE",
        method     : "delete",
        route      : "/roster/:eventId",
        path       : "/api/roster/:eventId",
        url        : "/api/roster/:eventId",
        cb         : _0_2.DELETE,
      },
  _0_3.default && {
        source     : "src/api/server-channels.js?fn=default",
        method     : "use",
        route      : "/server-channels",
        path       : "/api/server-channels",
        url        : "/api/server-channels",
        cb         : _0_3.default,
      },
  _0_3.GET && {
        source     : "src/api/server-channels.js?fn=GET",
        method     : "get",
        route      : "/server-channels",
        path       : "/api/server-channels",
        url        : "/api/server-channels",
        cb         : _0_3.GET,
      },
  _0_3.PUT && {
        source     : "src/api/server-channels.js?fn=PUT",
        method     : "put",
        route      : "/server-channels",
        path       : "/api/server-channels",
        url        : "/api/server-channels",
        cb         : _0_3.PUT,
      },
  _0_3.POST && {
        source     : "src/api/server-channels.js?fn=POST",
        method     : "post",
        route      : "/server-channels",
        path       : "/api/server-channels",
        url        : "/api/server-channels",
        cb         : _0_3.POST,
      },
  _0_3.PATCH && {
        source     : "src/api/server-channels.js?fn=PATCH",
        method     : "patch",
        route      : "/server-channels",
        path       : "/api/server-channels",
        url        : "/api/server-channels",
        cb         : _0_3.PATCH,
      },
  _0_3.DELETE && {
        source     : "src/api/server-channels.js?fn=DELETE",
        method     : "delete",
        route      : "/server-channels",
        path       : "/api/server-channels",
        url        : "/api/server-channels",
        cb         : _0_3.DELETE,
      },
  _0_4.default && {
        source     : "src/api/server-users.js?fn=default",
        method     : "use",
        route      : "/server-users",
        path       : "/api/server-users",
        url        : "/api/server-users",
        cb         : _0_4.default,
      },
  _0_4.GET && {
        source     : "src/api/server-users.js?fn=GET",
        method     : "get",
        route      : "/server-users",
        path       : "/api/server-users",
        url        : "/api/server-users",
        cb         : _0_4.GET,
      },
  _0_4.PUT && {
        source     : "src/api/server-users.js?fn=PUT",
        method     : "put",
        route      : "/server-users",
        path       : "/api/server-users",
        url        : "/api/server-users",
        cb         : _0_4.PUT,
      },
  _0_4.POST && {
        source     : "src/api/server-users.js?fn=POST",
        method     : "post",
        route      : "/server-users",
        path       : "/api/server-users",
        url        : "/api/server-users",
        cb         : _0_4.POST,
      },
  _0_4.PATCH && {
        source     : "src/api/server-users.js?fn=PATCH",
        method     : "patch",
        route      : "/server-users",
        path       : "/api/server-users",
        url        : "/api/server-users",
        cb         : _0_4.PATCH,
      },
  _0_4.DELETE && {
        source     : "src/api/server-users.js?fn=DELETE",
        method     : "delete",
        route      : "/server-users",
        path       : "/api/server-users",
        url        : "/api/server-users",
        cb         : _0_4.DELETE,
      },
  _0_5.default && {
        source     : "src/api/stats/[eventId].js?fn=default",
        method     : "use",
        route      : "/stats/:eventId",
        path       : "/api/stats/:eventId",
        url        : "/api/stats/:eventId",
        cb         : _0_5.default,
      },
  _0_5.GET && {
        source     : "src/api/stats/[eventId].js?fn=GET",
        method     : "get",
        route      : "/stats/:eventId",
        path       : "/api/stats/:eventId",
        url        : "/api/stats/:eventId",
        cb         : _0_5.GET,
      },
  _0_5.PUT && {
        source     : "src/api/stats/[eventId].js?fn=PUT",
        method     : "put",
        route      : "/stats/:eventId",
        path       : "/api/stats/:eventId",
        url        : "/api/stats/:eventId",
        cb         : _0_5.PUT,
      },
  _0_5.POST && {
        source     : "src/api/stats/[eventId].js?fn=POST",
        method     : "post",
        route      : "/stats/:eventId",
        path       : "/api/stats/:eventId",
        url        : "/api/stats/:eventId",
        cb         : _0_5.POST,
      },
  _0_5.PATCH && {
        source     : "src/api/stats/[eventId].js?fn=PATCH",
        method     : "patch",
        route      : "/stats/:eventId",
        path       : "/api/stats/:eventId",
        url        : "/api/stats/:eventId",
        cb         : _0_5.PATCH,
      },
  _0_5.DELETE && {
        source     : "src/api/stats/[eventId].js?fn=DELETE",
        method     : "delete",
        route      : "/stats/:eventId",
        path       : "/api/stats/:eventId",
        url        : "/api/stats/:eventId",
        cb         : _0_5.DELETE,
      },
  _0_6.default && {
        source     : "src/api/user.js?fn=default",
        method     : "use",
        route      : "/user",
        path       : "/api/user",
        url        : "/api/user",
        cb         : _0_6.default,
      },
  _0_6.GET && {
        source     : "src/api/user.js?fn=GET",
        method     : "get",
        route      : "/user",
        path       : "/api/user",
        url        : "/api/user",
        cb         : _0_6.GET,
      },
  _0_6.PUT && {
        source     : "src/api/user.js?fn=PUT",
        method     : "put",
        route      : "/user",
        path       : "/api/user",
        url        : "/api/user",
        cb         : _0_6.PUT,
      },
  _0_6.POST && {
        source     : "src/api/user.js?fn=POST",
        method     : "post",
        route      : "/user",
        path       : "/api/user",
        url        : "/api/user",
        cb         : _0_6.POST,
      },
  _0_6.PATCH && {
        source     : "src/api/user.js?fn=PATCH",
        method     : "patch",
        route      : "/user",
        path       : "/api/user",
        url        : "/api/user",
        cb         : _0_6.PATCH,
      },
  _0_6.DELETE && {
        source     : "src/api/user.js?fn=DELETE",
        method     : "delete",
        route      : "/user",
        path       : "/api/user",
        url        : "/api/user",
        cb         : _0_6.DELETE,
      },
  _0_7.default && {
        source     : "src/api/users.js?fn=default",
        method     : "use",
        route      : "/users",
        path       : "/api/users",
        url        : "/api/users",
        cb         : _0_7.default,
      },
  _0_7.GET && {
        source     : "src/api/users.js?fn=GET",
        method     : "get",
        route      : "/users",
        path       : "/api/users",
        url        : "/api/users",
        cb         : _0_7.GET,
      },
  _0_7.PUT && {
        source     : "src/api/users.js?fn=PUT",
        method     : "put",
        route      : "/users",
        path       : "/api/users",
        url        : "/api/users",
        cb         : _0_7.PUT,
      },
  _0_7.POST && {
        source     : "src/api/users.js?fn=POST",
        method     : "post",
        route      : "/users",
        path       : "/api/users",
        url        : "/api/users",
        cb         : _0_7.POST,
      },
  _0_7.PATCH && {
        source     : "src/api/users.js?fn=PATCH",
        method     : "patch",
        route      : "/users",
        path       : "/api/users",
        url        : "/api/users",
        cb         : _0_7.PATCH,
      },
  _0_7.DELETE && {
        source     : "src/api/users.js?fn=DELETE",
        method     : "delete",
        route      : "/users",
        path       : "/api/users",
        url        : "/api/users",
        cb         : _0_7.DELETE,
      }
].filter(it => it);

export const routers = internal.map((it) => {
  const { method, path, route, url, source } = it;
  return { method, url, path, route, source };
});

export const endpoints = internal.map(
  (it) => it.method?.toUpperCase() + "\t" + it.url
);

export const applyRouters = (applyRouter) => {
  internal.forEach((it) => {
    it.cb = configure.callbackBefore?.(it.cb, it) || it.cb;
    applyRouter(it);
  });
};
yracnet commented 8 months ago

Hi, sorry, I push a new version because the error is caused by packaged project.

yracnet commented 8 months ago

Hi @tteke could you confirm if the last release resolved the issue?

tteke commented 8 months ago

I can confirm 1.1.9-beta resolved the build issue