1
0
mirror of https://github.com/SomboChea/ui synced 2026-01-19 09:36:30 +07:00

refactor: replaced date fns with dayjs (#345)

This commit is contained in:
Priscila Oliveira
2019-12-06 17:58:24 +01:00
committed by Juan Picado @jotadeveloper
parent 474e9e18de
commit 501845b5f8
9 changed files with 28 additions and 18 deletions

View File

@@ -3,12 +3,19 @@
*/
import { Base64 } from 'js-base64';
import addHours from 'date-fns/addHours';
import dayjs from 'dayjs';
export function generateTokenWithTimeRange(limit = 0) {
export function generateTokenWithTimeRange(amount = 0) {
const payload = {
username: 'verdaccio',
exp: Number.parseInt(String(addHours(new Date(), limit).getTime() / 1000), 10),
exp: Number.parseInt(
String(
dayjs(new Date())
.add(amount, 'hour')
.valueOf() / 1000
),
10
),
};
return `xxxxxx.${Base64.encode(JSON.stringify(payload))}.xxxxxx`;
}