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 = {
id: string;
insert_time: Date;
expiry_time: Date;
expire_time: Date;
ciphertext: string;
hmac: string;
};

View File

@ -10,9 +10,14 @@
try {
const note: EncryptedNote = await response.json();
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 {
status: response.status,
cache: {
maxage: maxage,
private: false
},
props: { note }
};
} catch {