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
feat(schematics): add an option to generate nestjs node-app #807
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for creating this PR, it looks great! Just had a few points of feedback for you to address.
Also, please add e2e
tests.
@@ -58,7 +77,7 @@ function createSourceCode(options: NormalizedSchema): Rule { | |||
tmpl: '', | |||
name: options.name | |||
}), | |||
move(join(options.appProjectRoot, 'src')) | |||
move(options.appProjectRoot) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose this is alright if you need to add additional config.. but may I ask why this was needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created the file the same way nest-cli created them and they create a test folder containing test next to the src folder, that's why. But I will revert this as you mentioned in the next comment that we do not need those tests.
@@ -17,6 +17,10 @@ export const jasmineMarblesVersion = '0.3.1'; | |||
export const expressVersion = '4.16.3'; | |||
export const expressTypingsVersion = '4.16.0'; | |||
|
|||
export const nestjsVersion = '^5.1.0'; | |||
export const supertestVersion = '^3.1.0'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we do not need supertest
.
supertest
is for end-to-end testing of APIs which we opt to test through the frontend
application.
Example:
api1
is used by frontend1
. Testing frontend1
e2e should cover testing api1
by definition. Thus, testing api1
"e2e" should not be necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will remove.
|
||
async function bootstrap() { | ||
const app = await NestFactory.create(AppModule); | ||
await app.listen(3000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use 3333
to match the express
app?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can do
@@ -0,0 +1,22 @@ | |||
import { Test, TestingModule } from '@nestjs/testing'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not pertaining just to this file, but for these nest
modules, controllers, and services: Can they go into the app
directory similar to the Angular
directory structure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can do
c1d7b15
to
3e53951
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have done the requested changes, but need some help with the e2e test (see comments)
` | ||
); | ||
// const jestResult = await runCLIAsync('test node-app3'); | ||
// expect(jestResult.stderr).toContain('Test Suites: 1 passed, 1 total'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having problems with this test. Help appreciated!
expect(server).toBeTruthy(); | ||
|
||
await new Promise(resolve => { | ||
server.stdout.once('data', async data => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only works because I disabled nest's default Logger.
With the default logger enabled, starting the server logs multiple lines, where only the last will be Listening at http://localhost:3333
. How can I change this to have a short timeout and then get the last printed line?
const port = 3333; | ||
|
||
async function bootstrap() { | ||
const app = await NestFactory.create(AppModule, { logger: false }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ logger: false }
should be removed, but I need help to get the e2e test working properly with the default logger enabled, due to multiple lines being printed.
Thank you so much for taking the time to make this important contribution. We are sorry for not having a clear idea of how support of NestJS and other frameworks should look like earlier. Now that we have thought and discussed about how NestJS and other frameworks should be supported in Nx and we think the best approach is outside of this repository/ project for the following reasons:
@FallenRiteMonk @kamilmysliwiec Please let me know what you think. |
@FrozenPandaz I fully understand and appreciate your decision. Thanks also for replying and not just letting this PR hang around without any comment. Since I'm fairly new to creating/working with schematics and also not to deep into nestjs I don't know how much of a help I can be, but I would sure like to contribute as good as possible since I see great potential in the connection between nx and nestjs in some of my near future works, so @kamilmysliwiec pleas keep me up to date on what are the plans and how I can help. Thanks |
For the people looking for an example on how to use Nest with Nx, check my starter project: https://github.com/colmena/angular-nest-universal-starter I aim to support that project, so if it's not working in the future feel free to open an issue in that repo 👍 |
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
No description provided.