Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
console
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
console
Commits
9f488f78
Commit
9f488f78
authored
Aug 06, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix result cache
parent
c62b2392
Pipeline
#15422
passed with stages
in 3 minutes and 49 seconds
Changes
3
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
807 additions
and
158 deletions
+807
-158
console-api/package-lock.json
console-api/package-lock.json
+789
-150
console-api/package.json
console-api/package.json
+1
-0
console-api/src/update/update.controller.ts
console-api/src/update/update.controller.ts
+17
-8
No files found.
console-api/package-lock.json
View file @
9f488f78
This diff is collapsed.
Click to expand it.
console-api/package.json
View file @
9f488f78
...
...
@@ -74,6 +74,7 @@
"eslint"
:
"^7.30.0"
,
"eslint-config-prettier"
:
"^8.3.0"
,
"eslint-plugin-prettier"
:
"^3.4.0"
,
"express"
:
"^4.18.1"
,
"jest"
:
"27.0.6"
,
"prettier"
:
"^2.3.2"
,
"supertest"
:
"^6.1.3"
,
...
...
console-api/src/update/update.controller.ts
View file @
9f488f78
import
{
Body
,
Controller
,
Get
,
Header
,
Param
,
ParseArrayPipe
,
Post
,
Query
,
Render
,
ValidationPipe
}
from
'
@nestjs/common
'
;
import
{
Body
,
Controller
,
Get
,
Header
,
Param
,
ParseArrayPipe
,
Post
,
Query
,
Render
,
Res
,
ValidationPipe
}
from
'
@nestjs/common
'
;
import
{
UpdateService
}
from
'
./update.service
'
;
import
{
ApiBody
,
ApiCreatedResponse
,
ApiOkResponse
,
ApiOperation
,
ApiParam
,
Api
Query
,
Api
Tags
}
from
'
@nestjs/swagger
'
;
import
{
ApiBody
,
ApiCreatedResponse
,
ApiOkResponse
,
ApiOperation
,
ApiParam
,
ApiTags
}
from
'
@nestjs/swagger
'
;
import
{
DepotDto
}
from
'
../dto/Depot.dto
'
;
import
{
Response
}
from
'
express
'
;
@
Controller
(
'
update
'
)
@
ApiTags
(
'
update
'
)
...
...
@@ -14,19 +15,26 @@ export class UpdateController {
return
this
.
updateService
.
getAppsJson
();
}
private
async
cacheResult
<
T
>
(
res
:
Response
,
prom
:
Promise
<
T
>
)
{
const
result
=
await
prom
;
res
.
setHeader
(
'
Cache-Control
'
,
'
public, max-age=31536000, immutable
'
);
return
result
;
}
@
Get
(
'
checksums/:id/:version
'
)
@
Render
(
'
checksums
'
)
@
ApiOperation
({
summary
:
'
获取 app 校验和
'
,
description
:
'
是 shasum 的格式
'
})
@
ApiParam
({
name
:
'
id
'
,
description
:
'
APP 的 id
'
})
@
ApiParam
({
name
:
'
version
'
,
description
:
'
APP 的版本号
'
})
@
ApiOkResponse
({
type
:
String
})
@
Header
(
'
Cache-Control
'
,
'
public, max-age=31536000, immutable
'
)
//
@Header('Cache-Control', 'public, max-age=31536000, immutable')
async
getChecksum
(
@
Param
(
'
id
'
)
id
:
string
,
@
Query
(
new
ValidationPipe
({
transform
:
true
}))
depot
:
DepotDto
,
@
Param
(
'
version
'
)
version
:
string
@
Param
(
'
version
'
)
version
:
string
,
@
Res
({
passthrough
:
true
})
res
:
Response
)
{
return
this
.
updateService
.
getChecksum
(
id
,
depot
,
version
);
return
this
.
cacheResult
(
res
,
this
.
updateService
.
getChecksum
(
id
,
depot
,
version
)
);
}
@
Get
(
'
metalinks/:id/:version
'
)
...
...
@@ -35,13 +43,14 @@ export class UpdateController {
@
ApiParam
({
name
:
'
id
'
,
description
:
'
APP 的 id
'
})
@
ApiParam
({
name
:
'
version
'
,
description
:
'
APP 的版本号
'
})
@
ApiOkResponse
({
type
:
String
})
@
Header
(
'
Cache-Control
'
,
'
public, max-age=31536000, immutable
'
)
//
@Header('Cache-Control', 'public, max-age=31536000, immutable')
async
getFullPackageMetalink
(
@
Param
(
'
id
'
)
id
:
string
,
@
Query
(
new
ValidationPipe
({
transform
:
true
}))
depot
:
DepotDto
,
@
Param
(
'
version
'
)
version
:
string
@
Param
(
'
version
'
)
version
:
string
,
@
Res
({
passthrough
:
true
})
res
:
Response
)
{
return
this
.
updateService
.
getFullPackageMetalink
(
id
,
depot
,
version
);
return
this
.
cacheResult
(
res
,
this
.
updateService
.
getFullPackageMetalink
(
id
,
depot
,
version
)
);
}
@
Post
(
'
update/:id/:version
'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment