add note cache headers

This commit is contained in:
Maxime Cannoodt 2022-06-29 22:06:27 +02:00
parent 9b4eccd2a7
commit f78de8ab3d
3 changed files with 7 additions and 2 deletions

Binary file not shown.

View File

@ -1,7 +1,7 @@
export type EncryptedNote = { export type EncryptedNote = {
id: string; id: string;
insert_time: Date; insert_time: Date;
expiry_time: Date; expire_time: Date;
ciphertext: string; ciphertext: string;
hmac: string; hmac: string;
}; };

View File

@ -10,9 +10,14 @@
try { try {
const note: EncryptedNote = await response.json(); const note: EncryptedNote = await response.json();
note.insert_time = new Date(note.insert_time as unknown as string); note.insert_time = new Date(note.insert_time as unknown as string);
note.expiry_time = new Date(note.expiry_time as unknown as string); note.expire_time = new Date(note.expire_time as unknown as string);
const maxage = Math.floor((note.expire_time.valueOf() - note.insert_time.valueOf()) / 1000);
return { return {
status: response.status, status: response.status,
cache: {
maxage: maxage,
private: false
},
props: { note } props: { note }
}; };
} catch { } catch {