Skip to content

Commit

Permalink
fix(server): relLinks field
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamerblue committed Sep 24, 2024
1 parent 364924f commit bf35b30
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions server/src/models/piece.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ export const pieceSchema = new mongoose.Schema(
type: Number,
required: true,
},
// @deprecated
rel: {
type: String,
},
relLinks: {
type: [String],
},
expireAt: {
type: Date,
},
Expand Down
6 changes: 3 additions & 3 deletions server/src/modules/piece/piece.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class PieceController {
@Contract(AddPieceReqDTO, AddPieceRespDTO)
@RateLimitIp(10, 60)
async addPiece(@Data() data: AddPieceReqDTO): Promise<AddPieceRespDTO> {
const { code, lang, ttl, rel } = data;
const { code, lang, ttl, relLinks } = data;
this.ctx.info('[piece.addPiece] Req:', {
...data,
code: `String(${code.length})`,
Expand Down Expand Up @@ -63,13 +63,13 @@ export default class PieceController {
}
}

const created = await Piece.create([{ key, author, bytes, lang, ttl, rel, expireAt, ip: this.ctx.ip }]);
const created = await Piece.create([{ key, author, bytes, lang, ttl, relLinks, expireAt, ip: this.ctx.ip }]);
this.ctx.info('[piece.addPiece] Created:', created[0]._id, key);
const pieceFileContent = {
key,
lang,
author,
rel,
relLinks,
expireAt,
createdAt: created[0].createdAt,
code,
Expand Down
6 changes: 5 additions & 1 deletion server/src/modules/piece/piece.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export class AddPieceReqDTO {
@IsIn(pieceConfig.ttlOptions.map((ttl) => ttl.value))
ttl: number;

/**
* Relative link.
* @deprecated Use `relLinks` instead.
*/
@FromBody()
@IsOptional()
@IsString()
Expand All @@ -31,7 +35,7 @@ export class AddPieceReqDTO {
@IsOptional()
@IsArray()
@IsString({ each: true })
@IsUrl({ each: true })
@IsUrl(undefined, { each: true })
relLinks?: string[];
}

Expand Down

0 comments on commit bf35b30

Please sign in to comment.