Skip to content

Commit 5f9e644

Browse files
committed
fix: added a build command that pre-renders
1 parent 5cff66e commit 5f9e644

File tree

6 files changed

+10
-5
lines changed

6 files changed

+10
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This project is a Angular (With SSR) + Nestjs monorepo using Nx. It is a full-st
88
Feel free to contribute to this project by creating a pull request.
99

1010
- [ ] Check on how to build for bun runtime
11-
- [ ] Pre rendering routes doesn't spin up the server, so the HTTP calls are not working.
11+
- [x] Pre rendering routes doesn't spin up the server, so the HTTP calls are not working.
1212
- Wouraround: Use full api url's (http://localhost:4200/api) instead of relative url's (/api)
1313
- And spin up the api before building
1414
- [ ] Create a material included starter

apps/api/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ async function bootstrap() {
1212
const app = await NestFactory.create(AppModule);
1313
const globalPrefix = 'api';
1414
app.setGlobalPrefix(globalPrefix);
15+
app.enableShutdownHooks();
1516
const port = process.env.PORT || 3000;
1617
await app.listen(port);
1718
Logger.log(
1819
`🚀 Application is running on: http://localhost:${port}/${globalPrefix}`,
1920
);
2021
}
21-
2222
bootstrap();

bun.lockb

3.97 KB
Binary file not shown.

libs/backend/root/src/app.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ import { BackendTestModule } from '@backend/test';
66
controllers: [],
77
})
88
export class AppModule {}
9-
9+

libs/frontend/root/src/root/root.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@ import { derivedAsync } from 'ngxtension/derived-async';
1313
})
1414
export class RootComponent {
1515
private readonly httpClient = inject(HttpClient);
16-
movie = derivedAsync(() => this.httpClient.get(`/api/backend-test`));
16+
movie = derivedAsync(() =>
17+
this.httpClient.get(`http://localhost:3000/api/backend-test`),
18+
);
1719
}

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"license": "MIT",
55
"scripts": {
66
"start": "nx run-many -t serve -p tag:scope:app",
7-
"build": "nx build"
7+
"build": "concurrently \"nx serve api\" \"bun run wait-and-build\" --kill-others --success last --kill-signal SIGINT",
8+
"wait-and-build": "wait-on tcp:3000 && nx build app"
89
},
910
"private": true,
1011
"dependencies": {
@@ -66,6 +67,7 @@
6667
"@types/node": "20.12.12",
6768
"@typescript-eslint/eslint-plugin": "^7.10.0",
6869
"@typescript-eslint/parser": "^7.10.0",
70+
"concurrently": "^8.2.2",
6971
"eslint": "~9.3.0",
7072
"eslint-config-prettier": "^9.1.0",
7173
"eslint-plugin-playwright": "^1.6.2",
@@ -78,6 +80,7 @@
7880
"ts-jest": "^29.1.3",
7981
"ts-node": "10.9.2",
8082
"typescript": "~5.4.5",
83+
"wait-on": "^7.2.0",
8184
"webpack-cli": "^5.1.4"
8285
}
8386
}

0 commit comments

Comments
 (0)