Skip to content

Commit

Permalink
-Moved main.ts to root level so that both by command npm run and vs c…
Browse files Browse the repository at this point in the history
…ode can run same code

-ModuleResolution node is causing issue to resolve modules. So removed from tsconfig.
-configService is not working in main.ts. Bug is already present on github: nestjsx/nestjs-config/issues/275
-as configService is having issue, resolved config using json file.
  • Loading branch information
hnviradiya committed Jan 7, 2022
1 parent 5e23030 commit 1f27480
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/src/server/main.ts",
"program": "${workspaceFolder}/src/main.ts",
"preLaunchTask": "tsc: build - tsconfig.json",
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
Expand Down
11 changes: 5 additions & 6 deletions src/server/main.ts → src/main.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { ConfigService } from '@nestjs/config';
import { NestFactory } from '@nestjs/core';
import createServer from 'next/dist/server/next';
import { AppModule } from './app.module';
import { HttpExceptionFilter } from './next.filter';
import { AppModule } from './server/app.module';
import { HttpExceptionFilter } from './server/next.filter';
import config from './nest.config.json';

async function bootstrap() {
const app = await NestFactory.create(AppModule);

const configService = app.get<ConfigService>(ConfigService);
await app.init();
const nextServer = createServer({
dev: configService.get<string>('NODE_ENV') !== 'production',
dev: config.NODE_ENV !== 'production',
dir: './src/client',
});
await nextServer.prepare();
Expand Down
3 changes: 3 additions & 0 deletions src/nest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"NODE_ENV": "development"
}
12 changes: 3 additions & 9 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,10 @@
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"resolveJsonModule": true,
"jsx": "preserve"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
// "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
// "exclude": ["node_modules"]
}

0 comments on commit 1f27480

Please sign in to comment.