Git Product home page Git Product logo

Comments (3)

axe-me avatar axe-me commented on June 19, 2024

can you provide a repro?

I could create new route without any problem.

from vite-plugin-node.

AlexRMU avatar AlexRMU commented on June 19, 2024

+1

C:\pkg\node_modules\.pnpm\[email protected]\node_modules\fastify\lib\route.js:367
            throw new FST_ERR_DUPLICATED_ROUTE(opts.method, opts.url)
                  ^
FastifyError [Error]: Method 'POST' already declared for route '/auth/login'
    at Object.addNewRoute (C:\pkg\node_modules\.pnpm\[email protected]\node_modules\fastify\lib\route.js:367:19)
    at Object.route (C:\pkg\node_modules\.pnpm\[email protected]\node_modules\fastify\lib\route.js:261:19)
    at Object.prepareRoute (C:\pkg\node_modules\.pnpm\[email protected]\node_modules\fastify\lib\route.js:167:18)
    at Object._post [as post] (C:\pkg\node_modules\.pnpm\[email protected]\node_modules\fastify\fastify.js:270:34)
    at FastifyAdapter.injectRouteOptions (C:\pkg\node_modules\.pnpm\@[email protected]_@[email protected]_@[email protected]\node_modules\@nestjs\platform-fastify\adapters\fastify-adapter.js:392:46)
    at FastifyAdapter.post (C:\pkg\node_modules\.pnpm\@[email protected]_@[email protected]_@[email protected]\node_modules\@nestjs\platform-fastify\adapters\fastify-adapter.js:129:21)
    at C:\pkg\node_modules\.pnpm\@[email protected]_@[email protected]_@[email protected][email protected][email protected]\node_modules\@nestjs\core\router\router-explorer.js:105:17
    at Array.forEach (<anonymous>)
    at C:\pkg\node_modules\.pnpm\@[email protected]_@[email protected]_@[email protected][email protected][email protected]\node_modules\@nestjs\core\router\router-explorer.js:90:29
    at Array.forEach (<anonymous>) {
  code: 'FST_ERR_DUPLICATED_ROUTE',
  statusCode: 500
}
// package.json
"@nestjs/cli": "^10.3.2",
"@nestjs/common": "^10.3.3",
"@nestjs/core": "^10.3.3",
"@nestjs/platform-fastify": "^10.3.3",
"@swc/cli": "^0.3.10",
"@swc/core": "^1.4.2",
"@swc/helpers": "^0.5.6",
"typescript": "^5.3.3",
"vite": "^5.1.4",
"vite-plugin-node": "^3.1.0",
"fastify": "^4.26.1"
// vite.config.ts
import { defineConfig } from "vite";
import { VitePluginNode as vite_plugin_node } from "vite-plugin-node";

export default defineConfig({
    plugins: [
        ...vite_plugin_node({
            adapter: "nest",
            appPath: "./src/index.ts",
            exportName: "App",
            tsCompiler: "swc",
            initAppOnBoot: true,
        }),
    ],
});
// ./src/index.ts
import { NestFactory } from "@nestjs/core";
import {
  FastifyAdapter,
  type NestFastifyApplication,
} from "@nestjs/platform-fastify";
import { AppModule } from "./app.module";
import { RawServerDefault } from "fastify";

async function create() {
  const adapter = new FastifyAdapter({});
  const app: NestFastifyApplication<RawServerDefault> =
    await NestFactory.create<NestFastifyApplication>(AppModule, adapter);
  return app;
}

export const App = create();

from vite-plugin-node.

AlexRMU avatar AlexRMU commented on June 19, 2024

It seems that this happens when several requests arrive at one endpoint, for some reason they are processed simultaneously and
at the same time they try to declare these methods.

from vite-plugin-node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.