Commit c38daeb8 authored by nanahira's avatar nanahira

serve static and header

parent e8298003
......@@ -20,7 +20,6 @@ WORKDIR /app
COPY --from=api /app/package*.json ./
RUN npm ci
COPY --from=api /app/dist dist
COPY --from=api /app/views views
COPY --from=web /app/dist/console-web public
CMD ["npm", "run", "start:prod"]
VOLUME /app/config
\ No newline at end of file
......@@ -14,6 +14,7 @@
"@nestjs/config": "^1.0.1",
"@nestjs/core": "^8.0.0",
"@nestjs/platform-express": "^8.0.0",
"@nestjs/serve-static": "^2.2.2",
"@nestjs/swagger": "^5.0.9",
"@nestjs/typeorm": "^8.0.2",
"axios": "^0.21.1",
......@@ -2847,6 +2848,23 @@
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true
},
"node_modules/@nestjs/serve-static": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/@nestjs/serve-static/-/serve-static-2.2.2.tgz",
"integrity": "sha512-3Mr+Q/npS3N7iGoF3Wd6Lj9QcjMGxbNrSqupi5cviM0IKrZ1BHl5qekW95rWYNATAVqoTmjGROAq+nKKpuUagQ==",
"dependencies": {
"path-to-regexp": "0.1.7"
},
"peerDependencies": {
"@nestjs/common": "^6.0.0 || ^7.0.0 || ^8.0.0",
"@nestjs/core": "^6.0.0 || ^7.0.0 || ^8.0.0"
}
},
"node_modules/@nestjs/serve-static/node_modules/path-to-regexp": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
"integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
},
"node_modules/@nestjs/swagger": {
"version": "5.0.9",
"resolved": "https://registry.npmjs.org/@nestjs/swagger/-/swagger-5.0.9.tgz",
......@@ -13840,6 +13858,21 @@
}
}
},
"@nestjs/serve-static": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/@nestjs/serve-static/-/serve-static-2.2.2.tgz",
"integrity": "sha512-3Mr+Q/npS3N7iGoF3Wd6Lj9QcjMGxbNrSqupi5cviM0IKrZ1BHl5qekW95rWYNATAVqoTmjGROAq+nKKpuUagQ==",
"requires": {
"path-to-regexp": "0.1.7"
},
"dependencies": {
"path-to-regexp": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
"integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
}
}
},
"@nestjs/swagger": {
"version": "5.0.9",
"resolved": "https://registry.npmjs.org/@nestjs/swagger/-/swagger-5.0.9.tgz",
......
......@@ -27,6 +27,7 @@
"@nestjs/config": "^1.0.1",
"@nestjs/core": "^8.0.0",
"@nestjs/platform-express": "^8.0.0",
"@nestjs/serve-static": "^2.2.2",
"@nestjs/swagger": "^5.0.9",
"@nestjs/typeorm": "^8.0.2",
"axios": "^0.21.1",
......
......@@ -14,11 +14,16 @@ import { Build } from './entities/Build.entity';
import { Depot } from './entities/Depot.entity';
import { UpdateController } from './update/update.controller';
import { UpdateService } from './update/update.service';
import { ServeStaticModule } from '@nestjs/serve-static';
import path from 'path';
const configModule = ConfigModule.forRoot();
@Module({
imports: [
ServeStaticModule.forRoot({
rootPath: path.join(__dirname, '..', 'public'),
}),
configModule,
TypeOrmModule.forRootAsync({
name: 'app',
......
import { Body, Controller, Get, Param, ParseArrayPipe, Post, Query, Render, ValidationPipe } from '@nestjs/common';
import { Body, Controller, Get, Header, Param, ParseArrayPipe, Post, Query, Render, ValidationPipe } from '@nestjs/common';
import { UpdateService } from './update.service';
import { ApiBody, ApiOkResponse, ApiOperation, ApiParam, ApiProperty, ApiQuery, ApiTags } from '@nestjs/swagger';
import { DepotDto } from '../dto/Depot.dto';
......@@ -9,6 +9,7 @@ export class UpdateController {
constructor(private readonly updateService: UpdateService) {}
@Get('apps.json')
@ApiOperation({ summary: '获取 apps.json', description: '懒得解释这是啥了……' })
@Header('Cache-Control', 'public, max-age=600')
getAppsJson() {
return this.updateService.getAppsJson();
}
......@@ -20,6 +21,7 @@ export class UpdateController {
@ApiParam({ name: 'version', description: 'APP 的版本号' })
@ApiQuery({ type: DepotDto, description: 'APP 的类型' })
@ApiOkResponse({ type: String })
@Header('Cache-Control', 'public, max-age=31536000, immutable')
async getChecksum(
@Param('id') id: string,
@Query(new ValidationPipe({ transform: true })) depot: DepotDto,
......@@ -35,6 +37,7 @@ export class UpdateController {
@ApiParam({ name: 'version', description: 'APP 的版本号' })
@ApiQuery({ type: DepotDto, description: 'APP 的类型' })
@ApiOkResponse({ type: String })
@Header('Cache-Control', 'public, max-age=31536000, immutable')
async getFullPackageMetalink(
@Param('id') id: string,
@Query(new ValidationPipe({ transform: true })) depot: DepotDto,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment