Skip to content
This repository has been archived by the owner on Aug 26, 2023. It is now read-only.

Commit

Permalink
amazing
Browse files Browse the repository at this point in the history
  • Loading branch information
big cock committed Aug 20, 2023
1 parent 4acc29b commit 0f4c149
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/routes/api/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ import fs from "fs";

const router = Router();

interface Keys {
key: string;
ip: any;
created_at: string;
}

router.post("/", (req: Request, res: Response) => {
try {
const ip = req.headers["x-forwarded-for"] || req.socket.remoteAddress;
const keys = JSON.parse(fs.readFileSync("keys.json", "utf8"));

const newKey = {
const newKey: Keys = {
key: generateRandomKey(10),
created_at: new Date().toISOString(),
ip: ip,
Expand Down
8 changes: 7 additions & 1 deletion src/routes/api/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ interface UploadedFile {
mv: (path: string, callback?: (err: Error | null) => void) => void;
}

interface Keys {
key: string;
ip: any;
created_at: string;
}

function generateRandomName(length: number): string {
let result = "";
const characters =
Expand All @@ -29,7 +35,7 @@ router.post("/", (req: Request, res: Response) => {

const keys = JSON.parse(fs.readFileSync("keys.json", "utf8"));

if (!keys.some((k: { key: string }) => k.key === key)) {
if (!keys.some((k: Keys) => k.key === key)) {
return res.status(403).send({
status: 403,
message: "Invalid key retard.",
Expand Down

0 comments on commit 0f4c149

Please sign in to comment.