Skip to content

Commit

Permalink
fix: please codefactor
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealBarenziah committed Dec 30, 2020
1 parent 380d7be commit e1eef6c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/postToImgbb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ export const postToImgbb = (params: IPostParams) =>
image: base64str,
});

let path = `/1/upload?key=${apiKey}`;
if (name) path += `&name=${name}`;
if (expiration) path += `&expiration=${expiration}`;
let query = `/1/upload?key=${apiKey}`;
if (name) query += `&name=${name}`;
if (expiration) query += `&expiration=${expiration}`;

const options = {
hostname: "api.imgbb.com",
method: "POST",
timeout: 5000,
path: path,
path: query,
headers: {
Accept: "application/json",
"Content-Type": "application/x-www-form-urlencoded",
Expand Down
6 changes: 3 additions & 3 deletions src/validateInput.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const fs = require("fs").promises;
import { lstat } from "fs/promises";

/**
* Formally validate input params
Expand All @@ -9,10 +9,10 @@ const fs = require("fs").promises;
* A promise that resolve to `true` if things are looking good, and otherwise resolve to `false`
*/
export const validateInput = async (apiKey: string, path: string) => {
const presumedFile = await fs.lstat(path);
const presumedFile = await lstat(path);
if (
apiKey.length === 32 && // imgBB API keys being 32 characters long is empiric knowledge
(await presumedFile.isFile()) // Using fs.lstat to ensure there is a file to upload
presumedFile.isFile() // Using fs.lstat to ensure there is a file to upload
) {
return true;
} else return false;
Expand Down

0 comments on commit e1eef6c

Please sign in to comment.