Skip to content
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

Cannot build on @nestia/[email protected] #994

Closed
sacru2red opened this issue Aug 21, 2024 · 7 comments
Closed

Cannot build on @nestia/[email protected] #994

sacru2red opened this issue Aug 21, 2024 · 7 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@sacru2red
Copy link

Bug Report

Summary

Write a short summary of the bug in here.

  • SDK Version: 3.11.0
  • Expected behavior: working
  • Actual behavior: swagger generator is dead

Write detailed description in here.

nestia.config.ts

import type nestia from '@nestia/sdk'

export const NESTIA_CONFIG = {
  input: {
    include: ['./src/**/*.controller.ts', './src/presentation/**/*.ts'],
  },
  output: './src/api',
  swagger: {
    output: './swagger/swagger.json',
    security: {
      bearer: {
        type: 'http',
        scheme: 'bearer',
        bearerFormat: 'JWT',
      },
    },
  },
} satisfies nestia.INestiaConfig
export default NESTIA_CONFIG

@nestia/[email protected] works but not 3.11.0

nestia sdk generate dead

$ npx nestia swagger
-----------------------------------------------------------
 Nestia Swagger Generator
-----------------------------------------------------------

(before logging "Analyzing reflections")

Code occuring the bug

/* Demonstration code occuring the bug you're reporting */

Write the demonstration code occuring the bug you're reporting.

However, as the nestia is not a typical library who being used by the import statement but a executable program generating the SDK (Software Development Kit), it would be difficult to describe the bug with only the demonstration code.

In that case, you'd better to make a demonstration project occuring the bug to report. After the demonstration repository composition, fill the below bash script section. Of course, if you can describe the bug clearly, without the demonstration project construction, just skip it. Creating the demonstration repository is not essential.

git clone https://github.com/someone/nestia-bug-report-xxx
cd nestia-bug-report-xxx
npx nestia sdk
@samchon
Copy link
Owner

samchon commented Aug 21, 2024

Reproducible repo?

@sacru2red
Copy link
Author

@samchon
늦었지만 재현가능한 레포를 만들었습니다.

https://github.com/sacru2red/nestia-build-fail

@sacru2red
Copy link
Author

음..

Not works

input: {
    include: ['./src/**/*.controller.ts'],
  },

Works

input: async () => {
    const app = await NestFactory.create(AppModule);
    return app;
  },

@samchon samchon self-assigned this Aug 22, 2024
@samchon samchon added the bug Something isn't working label Aug 22, 2024
@samchon samchon added the enhancement New feature or request label Aug 22, 2024
@samchon
Copy link
Owner

samchon commented Aug 22, 2024

Traveled your code, and found the reason.

At first, you have to setup ts-patch. Just run the npx nestia setup command.

The second problem is, as you've written like above comment, the dynamic module importing by location path no more works. NestJS application module is blocking it. Therefore, I also need to take a major update that allowing only function typed input configurion like input: () => NestFactory.create(AppModule).

About the second problem, I'll take a major update ASAP.

@sacru2red
Copy link
Author

sacru2red commented Aug 22, 2024

@samchon
edit: my fault ignore it

I'am trying with

input: async () => {
    const app = await NestFactory.create(AppModule);
    return app;
  },

but got error in my project at

@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal: true,
      expandVariables: true,
      validationSchema: Joi.object({
        NODE_ENV: Joi.string().valid('dev', 'prod').required(),
        MARIA_DB_HOST: Joi.string().required(),
        MARIA_DB_PORT: Joi.number().required(),
        MARIA_DB_USERNAME: Joi.string().required(),
        MARIA_DB_PASSWORD: Joi.string().required(),
        MARIA_DB_DATABASE: Joi.string().required(),
      }),
    }),
Error: Config validation error: "NODE_ENV" is required
    at Function.forRoot (C:\Users\smartbig\Desktop\svn\bodumcareServer\api-v2.bodumcare.com\node_modules\@nestjs\config\dist\config.module.js:86:23)
    at Object.<anonymous> (C:\Users\smartbig\Desktop\svn\bodumcareServer\api-v2.bodumcare.com\src\app.module.ts:73:18)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Module.m._compile (C:\Users\smartbig\Desktop\svn\bodumcareServer\api-v2.bodumcare.com\node_modules\ts-node\src\index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
    at Object.require.extensions.<computed> [as .ts] (C:\Users\smartbig\Desktop\svn\bodumcareServer\api-v2.bodumcare.com\node_modules\ts-node\src\index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1024:12)
    at Module.require (node:internal/modules/cjs/loader:1233:19)
    at require (node:internal/modules/helpers:179:18)

do you know any solution?
(cross-env NODE_ENV=prod && nestia sdk --config nestia.config.ts not working cross-env NODE_ENV=prod nestia sdk --config nestia.config.ts works)

@samchon
Copy link
Owner

samchon commented Aug 22, 2024

Then try to find another way to keep the dynamic controller importing way by location path.

You can skip the problem just by making an independent module from such env configuration, and main module to import it.

@samchon
Copy link
Owner

samchon commented Aug 22, 2024

Upgrade to 3.11.2 patch version, then your problem be fixed.

Thanks for reporting.

samchon added a commit that referenced this issue Aug 22, 2024
Fix #994: when `INestiaConfig.input` is not application, but controller path(s).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
No open projects
Status: Done
Development

No branches or pull requests

2 participants