Skip to content

Commit 84e0cd8

Browse files
committed
feat: add client serve
1 parent 769434f commit 84e0cd8

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"@nestjs/passport": "^7.0.0",
2828
"@nestjs/platform-express": "^7.0.0",
2929
"@nestjs/schedule": "^0.4.0",
30+
"@nestjs/serve-static": "^2.1.1",
3031
"@nestjs/swagger": "^4.4.0",
3132
"class-transformer": "^0.2.3",
3233
"class-validator": "^0.12.2",

src/app.module.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,37 @@
11
import { Module } from '@nestjs/common';
22
import { MikroOrmModule } from 'nestjs-mikro-orm';
33
import { ScheduleModule } from '@nestjs/schedule';
4-
import { ConfigModule } from '@nestjs/config';
4+
import { ConfigModule, ConfigService } from '@nestjs/config';
5+
import { ServeStaticModule } from '@nestjs/serve-static';
56
import { AuthModule } from './auth/auth.module';
67
import { MeetupsModule } from './meetups/meetups.module';
78
import { UsersModule } from './users/users.module';
89
import { ImagesModule } from './images/images.module';
910
import { MaintenanceModule } from './maintenance/maintenance.module';
1011
import config from './mikro-orm.config';
1112
import { configuration } from './configuration';
13+
import { join } from 'path';
1214

1315
@Module({
1416
imports: [
1517
ConfigModule.forRoot({
1618
isGlobal: true,
1719
load: [configuration],
1820
}),
21+
ServeStaticModule.forRootAsync({
22+
useFactory: (configService: ConfigService) => {
23+
const clientPath = configService.get('clientPath');
24+
return clientPath
25+
? [
26+
{
27+
rootPath: configService.get('clientPath'),
28+
exclude: ['/api*'],
29+
},
30+
]
31+
: [];
32+
},
33+
inject: [ConfigService],
34+
}),
1935
MikroOrmModule.forRoot(config),
2036
ScheduleModule.forRoot(),
2137
AuthModule,

src/configuration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ export const configuration = () => ({
44
secret: process.env.SECRET ?? 'secret',
55
adminKey: process.env.ADMIN_KEY,
66
dbRefreshCron: process.env.DB_REFRESH_CRON,
7+
clientPath: process.env.CLIENT_PATH,
78
});

yarn.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,13 @@
610610
"@angular-devkit/schematics" "9.0.6"
611611
fs-extra "8.1.0"
612612

613+
"@nestjs/serve-static@^2.1.1":
614+
version "2.1.1"
615+
resolved "https://registry.yarnpkg.com/@nestjs/serve-static/-/serve-static-2.1.1.tgz#b18573bb14a52fc9ebc82fc887d1bc0846f1d18c"
616+
integrity sha512-hkrCm7R8BWE8k9iiFlRtBIw+/VR4SMWos3yErRvC12y1ADI7gWkbu46+urx8jlcMnOEQW/xTAWY51xe6miBvHQ==
617+
dependencies:
618+
path-to-regexp "0.1.7"
619+
613620
"@nestjs/swagger@^4.4.0":
614621
version "4.5.7"
615622
resolved "https://registry.yarnpkg.com/@nestjs/swagger/-/swagger-4.5.7.tgz#f38d73c984af70f95655b2828c539fab5482129b"

0 commit comments

Comments
 (0)