Skip to content

Commit 54b1d40

Browse files
committed
feat: adding route generation and moved build to script
1 parent f089f5c commit 54b1d40

20 files changed

+278
-6
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ To build the Angular application for production:
7272
bun run build
7373
```
7474

75+
This will run all the required build steps.
76+
I've included a routes.txt generator, so you can add the routes you want to pre-render in the `routes.txt` file.
77+
You can remove that library and build steps if you don't want to pre-render the routes.
78+
7579
To run the Application:
7680

7781
```bash

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Module } from '@nestjs/common';
2-
import { BackendTestModule } from '@backend/test';
2+
import { BackendTestModule } from '@app/backend-test';
3+
import { RoutesGeneratorModule } from '@app/backend-routes-generator';
34

45
@Module({
5-
imports: [BackendTestModule],
6+
imports: [BackendTestModule, RoutesGeneratorModule],
67
controllers: [],
78
})
89
export class AppModule {}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": ["../../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
}
17+
]
18+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# backend-routes-generator
2+
3+
This library was generated with [Nx](https://nx.dev).
4+
5+
## Running unit tests
6+
7+
Run `nx test backend-routes-generator` to execute the unit tests via [Jest](https://jestjs.io).
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* eslint-disable */
2+
export default {
3+
displayName: 'backend-routes-generator',
4+
preset: '../../../jest.preset.js',
5+
testEnvironment: 'node',
6+
transform: {
7+
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
8+
},
9+
moduleFileExtensions: ['ts', 'js', 'html'],
10+
coverageDirectory: '../../../coverage/libs/backend/routes-generator',
11+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "backend-routes-generator",
3+
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "libs/backend/routes-generator/src",
5+
"projectType": "library",
6+
"tags": [],
7+
"targets": {
8+
"test": {
9+
"executor": "@nx/jest:jest",
10+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
11+
"options": {
12+
"jestConfig": "libs/backend/routes-generator/jest.config.ts"
13+
}
14+
}
15+
}
16+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Test } from '@nestjs/testing';
2+
import { RoutesGeneratorController } from './routes-generator.controller';
3+
import { RoutesGeneratorService } from '../services/routes-generator.service';
4+
5+
describe('RoutesGeneratorController', () => {
6+
let controller: RoutesGeneratorController;
7+
8+
beforeEach(async () => {
9+
const module = await Test.createTestingModule({
10+
providers: [RoutesGeneratorService],
11+
controllers: [RoutesGeneratorController],
12+
}).compile();
13+
14+
controller = module.get(RoutesGeneratorController);
15+
});
16+
17+
it('should be defined', () => {
18+
expect(controller).toBeTruthy();
19+
});
20+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Controller, Get } from '@nestjs/common';
2+
import { RoutesGeneratorService } from '../services/routes-generator.service';
3+
4+
@Controller('routes')
5+
export class RoutesGeneratorController {
6+
constructor(private routeGenerator: RoutesGeneratorService) {}
7+
8+
@Get()
9+
generateRoutes() {
10+
return this.routeGenerator.generateRoutesTxt();
11+
}
12+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './routes-generator.module';
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Module } from '@nestjs/common';
2+
import { RoutesGeneratorController } from './controllers/routes-generator.controller';
3+
import { RoutesGeneratorService } from './services/routes-generator.service';
4+
5+
@Module({
6+
controllers: [RoutesGeneratorController],
7+
providers: [RoutesGeneratorService],
8+
exports: [RoutesGeneratorService],
9+
})
10+
export class RoutesGeneratorModule {}

0 commit comments

Comments
 (0)