mirror of
https://github.com/stonith404/pingvin-share.git
synced 2024-10-02 09:30:10 +02:00
refactor: run formatter
This commit is contained in:
parent
83cde4778a
commit
c5099ce2e8
@ -6,37 +6,39 @@ import * as moment from "moment";
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class JobsService {
|
export class JobsService {
|
||||||
constructor(
|
constructor(
|
||||||
private prisma: PrismaService,
|
private prisma: PrismaService,
|
||||||
private fileService: FileService
|
private fileService: FileService
|
||||||
) {
|
) {}
|
||||||
|
|
||||||
|
@Cron("0 * * * *")
|
||||||
|
async deleteExpiredShares() {
|
||||||
|
const expiredShares = await this.prisma.share.findMany({
|
||||||
|
where: {
|
||||||
|
// We want to remove only shares that have an expiration date less than the current date, but not 0
|
||||||
|
AND: [
|
||||||
|
{ expiration: { lt: new Date() } },
|
||||||
|
{ expiration: { not: moment(0).toDate() } },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const expiredShare of expiredShares) {
|
||||||
|
await this.prisma.share.delete({
|
||||||
|
where: { id: expiredShare.id },
|
||||||
|
});
|
||||||
|
|
||||||
|
await this.fileService.deleteAllFiles(expiredShare.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cron("0 * * * *")
|
console.log(`job: deleted ${expiredShares.length} expired shares`);
|
||||||
async deleteExpiredShares() {
|
}
|
||||||
const expiredShares = await this.prisma.share.findMany({
|
|
||||||
where: {
|
|
||||||
// We want to remove only shares that have an expiration date less than the current date, but not 0
|
|
||||||
AND: [{expiration: {lt: new Date()}}, {expiration: {not: moment(0).toDate()}}]
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
for (const expiredShare of expiredShares) {
|
@Cron("0 * * * *")
|
||||||
await this.prisma.share.delete({
|
async deleteExpiredRefreshTokens() {
|
||||||
where: {id: expiredShare.id},
|
const expiredShares = await this.prisma.refreshToken.deleteMany({
|
||||||
});
|
where: { expiresAt: { lt: new Date() } },
|
||||||
|
});
|
||||||
await this.fileService.deleteAllFiles(expiredShare.id);
|
console.log(`job: deleted ${expiredShares.count} expired refresh tokens`);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`job: deleted ${expiredShares.length} expired shares`);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cron("0 * * * *")
|
|
||||||
async deleteExpiredRefreshTokens() {
|
|
||||||
const expiredShares = await this.prisma.refreshToken.deleteMany({
|
|
||||||
where: {expiresAt: {lt: new Date()}},
|
|
||||||
});
|
|
||||||
console.log(`job: deleted ${expiredShares.count} expired refresh tokens`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,11 @@ export class ShareSecurityGuard implements CanActivate {
|
|||||||
include: { security: true },
|
include: { security: true },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!share || (moment().isAfter(share.expiration) && moment(share.expiration).unix() !== 0))
|
if (
|
||||||
|
!share ||
|
||||||
|
(moment().isAfter(share.expiration) &&
|
||||||
|
moment(share.expiration).unix() !== 0)
|
||||||
|
)
|
||||||
throw new NotFoundException("Share not found");
|
throw new NotFoundException("Share not found");
|
||||||
|
|
||||||
if (share.security?.password && !shareToken)
|
if (share.security?.password && !shareToken)
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "dotenv next start",
|
"start": "dotenv next start",
|
||||||
"lint": "next lint",
|
"lint": "next lint",
|
||||||
"format": "prettier --write \"src/**/*.ts\""
|
"format": "prettier --write \"src/**/*.ts*\""
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.10.4",
|
"@emotion/react": "^11.10.4",
|
||||||
|
@ -5,7 +5,10 @@ const Footer = () => {
|
|||||||
<MFooter height="auto" p={10}>
|
<MFooter height="auto" p={10}>
|
||||||
<Center>
|
<Center>
|
||||||
<Text size="xs" color="dimmed">
|
<Text size="xs" color="dimmed">
|
||||||
Made with 🖤 by <Anchor size="xs" href="https://eliasschneider.com" target="_blank">Elias Schneider</Anchor>
|
Made with 🖤 by{" "}
|
||||||
|
<Anchor size="xs" href="https://eliasschneider.com" target="_blank">
|
||||||
|
Elias Schneider
|
||||||
|
</Anchor>
|
||||||
</Text>
|
</Text>
|
||||||
</Center>
|
</Center>
|
||||||
</MFooter>
|
</MFooter>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { ActionIcon, Avatar, Menu } from "@mantine/core";
|
import { ActionIcon, Avatar, Menu } from "@mantine/core";
|
||||||
import { NextLink } from "@mantine/next";
|
import { NextLink } from "@mantine/next";
|
||||||
import { TbDoorExit, TbLink } from "react-icons/tb";;
|
import { TbDoorExit, TbLink } from "react-icons/tb";
|
||||||
import authService from "../../services/auth.service";
|
import authService from "../../services/auth.service";
|
||||||
|
|
||||||
const ActionAvatar = () => {
|
const ActionAvatar = () => {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { ActionIcon, Loader, Skeleton, Table } from "@mantine/core";
|
import { ActionIcon, Loader, Skeleton, Table } from "@mantine/core";
|
||||||
import { TbCircleCheck, TbDownload } from "react-icons/tb";;
|
import { TbCircleCheck, TbDownload } from "react-icons/tb";
|
||||||
import shareService from "../../services/share.service";
|
import shareService from "../../services/share.service";
|
||||||
|
|
||||||
import { byteStringToHumanSizeString } from "../../utils/math/byteStringToHumanSizeString.util";
|
import { byteStringToHumanSizeString } from "../../utils/math/byteStringToHumanSizeString.util";
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { ActionIcon, Table } from "@mantine/core";
|
import { ActionIcon, Table } from "@mantine/core";
|
||||||
import { Dispatch, SetStateAction } from "react";
|
import { Dispatch, SetStateAction } from "react";
|
||||||
import { TbTrash } from "react-icons/tb";;
|
import { TbTrash } from "react-icons/tb";
|
||||||
import { FileUpload } from "../../types/File.type";
|
import { FileUpload } from "../../types/File.type";
|
||||||
import { byteStringToHumanSizeString } from "../../utils/math/byteStringToHumanSizeString.util";
|
import { byteStringToHumanSizeString } from "../../utils/math/byteStringToHumanSizeString.util";
|
||||||
import UploadProgressIndicator from "./UploadProgressIndicator";
|
import UploadProgressIndicator from "./UploadProgressIndicator";
|
||||||
|
@ -8,14 +8,12 @@ const showCreateUploadModal = (
|
|||||||
uploadCallback: (
|
uploadCallback: (
|
||||||
id: string,
|
id: string,
|
||||||
expiration: string,
|
expiration: string,
|
||||||
security: ShareSecurity,
|
security: ShareSecurity
|
||||||
) => void
|
) => void
|
||||||
) => {
|
) => {
|
||||||
return modals.openModal({
|
return modals.openModal({
|
||||||
title: <Title order={4}>Share</Title>,
|
title: <Title order={4}>Share</Title>,
|
||||||
children: (
|
children: <CreateUploadModalBody uploadCallback={uploadCallback} />,
|
||||||
<CreateUploadModalBody uploadCallback={uploadCallback} />
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user