@mateosuarezdev/brpc 1.0.16 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { BunFile } from "bun";
|
|
2
2
|
import type { OptimizedImageBuffer } from "./types";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* file can be File, BunFile or string (base64)
|
|
5
|
+
*/
|
|
6
|
+
export declare function optimizeImage(file: File | BunFile | string, opts?: {
|
|
4
7
|
width?: number;
|
|
5
8
|
quality?: number;
|
|
9
|
+
originalMimeType?: string;
|
|
6
10
|
}): Promise<OptimizedImageBuffer>;
|
package/dist/storage/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
2
|
+
var G=(W)=>W.startsWith("image/"),q=(W)=>W.startsWith("video/"),K=(W)=>W.startsWith("audio/"),S=(W)=>W.startsWith("text/")||W.includes("pdf")||W.includes("word")||W.includes("sheet")||W.includes("presentation")||W.includes("opendocument")||W==="application/rtf",V=(W)=>W.includes("zip")||W.includes("rar")||W.includes("tar")||W.includes("7z")||W.includes("gzip"),z=(W)=>W==="application/javascript"||W==="application/json"||W==="text/html"||W==="text/css"||W==="application/xml"||W.includes("javascript"),D=(W)=>W.startsWith("font/")||W.includes("font"),N=(W)=>{if(!W)return"other";let H=W.toLowerCase();if(G(H))return"image";if(q(H))return"video";if(K(H))return"audio";if(S(H))return"document";if(V(H))return"archive";if(z(H))return"code";if(D(H))return"font";return"other"},M={isImage:G,isVideo:q,isAudio:K,isDocument:S,isArchive:V,isCode:z,isFont:D};function u(){let H=Buffer.from("Hello, this is a test file for S3 upload!","utf-8");return new File([H],"test.txt",{type:"text/plain"})}function C(W,H){if(W.url)return W.url;if(W.key)if(W.isPrivate)return`/storage/${W.key}`;else return`https://${H?.bucket??process.env.AWS_BUCKET}.s3.amazonaws.com/${W.key}`;throw Error("Invalid storage object")}class Q extends Error{code;clientCode;httpStatus;data;cause;static STATUS_MAP={BAD_REQUEST:400,UNAUTHORIZED:401,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_SUPPORTED:405,TIMEOUT:408,CONFLICT:409,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,UNPROCESSABLE_CONTENT:422,TOO_MANY_REQUESTS:429,CLIENT_CLOSED_REQUEST:499,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504};constructor(W){super(W.message);if(this.name="BRPCError",this.code=W.code,this.clientCode=W.clientCode,this.httpStatus=Q.STATUS_MAP[W.code],this.data=W.data,this.cause=W.cause,Error.captureStackTrace)Error.captureStackTrace(this,Q)}toJSON(){return{name:this.name,code:this.code,clientCode:this.clientCode,message:this.message,data:this.data,httpStatus:this.httpStatus}}static badRequest(W,H,J){return new Q({code:"BAD_REQUEST",message:W,clientCode:H,data:J})}static unauthorized(W="Unauthorized",H,J){return new Q({code:"UNAUTHORIZED",message:W,clientCode:H,data:J})}static forbidden(W="Forbidden",H,J){return new Q({code:"FORBIDDEN",message:W,clientCode:H,data:J})}static notFound(W="Not Found",H,J){return new Q({code:"NOT_FOUND",message:W,clientCode:H,data:J})}static preconditionFailed(W="Precondition failed",H,J){return new Q({code:"NOT_FOUND",message:W,clientCode:H,data:J})}static conflict(W,H,J){return new Q({code:"CONFLICT",message:W,clientCode:H,data:J})}static unprocessableContent(W,H,J){return new Q({code:"UNPROCESSABLE_CONTENT",message:W,clientCode:H,data:J})}static tooManyRequests(W="Too many requests",H,J){return new Q({code:"TOO_MANY_REQUESTS",message:W,clientCode:H,data:J})}static internalServerError(W="Internal Server Error",H,J){return new Q({code:"INTERNAL_SERVER_ERROR",message:W,clientCode:H,data:J})}static timeout(W="Request timeout",H,J){return new Q({code:"TIMEOUT",message:W,clientCode:H,data:J})}}import j from"sharp";async function n(W,H={}){let J=H.width??1200,X=H.quality??75;if(!W)throw Q.conflict("A file must be provided in order to optimize");let _,Y="unknown.webp",Z="image/webp";if(typeof W==="string"){let[$,x]=W.split(",");Z=$.match(/:(.*?);/)?.[1]??"image/webp",_=Buffer.from(x,"base64")}else{if(!M.isImage(W.type))throw Q.conflict("The file must be an image to be optimized");_=await W.arrayBuffer(),Y=W.name??Y,Z=W.type??Z}return{buffer:await j(_).resize(J,null,{withoutEnlargement:!0}).webp({quality:X}).toBuffer(),metadata:{name:Y.replace(/\.[^/.]+$/,".webp"),type:Z,extension:".webp",resolvedType:"image"}}}import R from"sharp";import{randomUUID as F}from"crypto";import{extname as O}from"path";async function U(W,H,J){if(!H)return{data:null,error:Error("File not found")};let X=W.replace(/^\/+|\/+$/g,""),_=O(H.name),Y=`${F()}${_}`,Z=`${X}/${Y}`,L=`./buckets/${X}/${Y}`;try{let $=await Bun.write(L,H);return{data:{key:Z,file:H,bytesWritten:$},error:null}}catch($){return{data:null,error:Error(`Failed to upload ${H.name} to local filesystem`)}}}async function T(W,H,J){if(!H||H.length===0)return[];let X=H.map((Y)=>{let Z=J?.(Y)??Y.name;return U(W,Y,Z)});return await Promise.all(X)}async function k(W){let H=Bun.file(`./buckets/${W}`);if(!await H.exists())return null;return H}async function b(W){let H=Bun.file(`./buckets/${W}`);if(!await H.exists())return!1;return await H.delete(),!0}var A={uploadOne:U,uploadMany:T,getOne:k,deleteOne:b};async function t(W){let H=`./cache/images/${W.key}_${W.width}_${W.quality}.webp`,J=await A.getOne(H);if(J){if(!M.isImage(J.type))return null;return J}let X=W.key,_=await A.getOne(X);if(!_)return null;if(!M.isImage(_.type))return null;let Y=await _.arrayBuffer(),Z=await R(Y).resize(W.width,null,{withoutEnlargement:!0}).webp({quality:W.quality??75}).toBuffer();await Bun.write(H,Z);let L=Bun.file(H);if(!await L.exists())return null;return L}import E from"path";var v=process.env.AWS_FOLDER,w=v?`${v}/`:"";var{s3:B}=globalThis.Bun;async function ZW(W,H,J){let X="buffer"in H?{buffer:H.buffer,metadata:H.metadata}:{buffer:H,metadata:{name:H.name,type:H.type,extension:E.extname(H.name),resolvedType:N(H.type)}};if("buffer"in H&&!H.metadata)throw Q.badRequest("Metadata required when uploading buffer");let _=W.length>1?`${W.replace(/^\/+|\/+$/g,"")}/`:"",Y=`${crypto.randomUUID()}${X.metadata.extension}`,Z=`${w}${_}${Y}`,L=B.file(Z),$=J?.acl??"public-read",x=$!=="public-read"&&$!=="public-read-write",I=await L.write(X.buffer,{acl:$});return{uploadedBy:J?.uploadedBy??null,key:Z,url:null,name:X.metadata.name,thumbnail:null,resolvedType:X.metadata.resolvedType,provider:"s3",isPrivate:x,metadata:{size:I,type:X.metadata.type,extension:X.metadata.extension,acl:$},isActive:!0}}var{s3:P}=globalThis.Bun;async function MW(W,H){if(!W||typeof W!=="string")throw Q.badRequest("Key is required");let J=W.trim();if(!J||J.length===0)throw Q.badRequest("Key must be a non-empty string");try{return await P.delete(W),{key:W,deleted:!0,error:null}}catch(X){return{key:W,deleted:!1,error:X}}}var{s3:h}=globalThis.Bun;async function GW(W,H={debug:!0}){try{return{exists:await h.exists(W),error:null}}catch(J){if(H?.debug)console.error("There was an error checking for file existance",J);return{exists:null,error:J}}}export{ZW as uploadOne,n as optimizeImage,N as mimeTypeToResolvedType,t as getOptimizedImage,C as getObjectUrl,u as generateTestFile,M as fileTypePredicates,MW as deleteOne,GW as checkFileExistance};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=12A04BF9E699859764756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["..\\src\\storage\\utils\\files.ts", "..\\src\\errors\\BRPCError.ts", "..\\src\\storage\\images\\optimize.ts", "..\\src\\storage\\images\\get-optimized.ts", "..\\src\\storage\\local\\index.ts", "..\\src\\storage\\s3\\upload.ts", "..\\src\\storage\\s3\\constants.ts", "..\\src\\storage\\s3\\delete.ts", "..\\src\\storage\\s3\\helpers.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import type { ResolvedFileType, StorageObject } from \"../types\";\r\n\r\nconst isImage = (type: string): boolean => type.startsWith(\"image/\");\r\n\r\nconst isVideo = (type: string): boolean => type.startsWith(\"video/\");\r\n\r\nconst isAudio = (type: string): boolean => type.startsWith(\"audio/\");\r\n\r\nconst isDocument = (type: string): boolean =>\r\n type.startsWith(\"text/\") ||\r\n type.includes(\"pdf\") ||\r\n type.includes(\"word\") ||\r\n type.includes(\"sheet\") ||\r\n type.includes(\"presentation\") ||\r\n type.includes(\"opendocument\") ||\r\n type === \"application/rtf\";\r\n\r\nconst isArchive = (type: string): boolean =>\r\n type.includes(\"zip\") ||\r\n type.includes(\"rar\") ||\r\n type.includes(\"tar\") ||\r\n type.includes(\"7z\") ||\r\n type.includes(\"gzip\");\r\n\r\nconst isCode = (type: string): boolean =>\r\n type === \"application/javascript\" ||\r\n type === \"application/json\" ||\r\n type === \"text/html\" ||\r\n type === \"text/css\" ||\r\n type === \"application/xml\" ||\r\n type.includes(\"javascript\");\r\n\r\nconst isFont = (type: string): boolean =>\r\n type.startsWith(\"font/\") || type.includes(\"font\");\r\n\r\n/**\r\n * Maps MIME types to file categories\r\n * @param mimeType - The MIME type string\r\n * @returns FileType category\r\n */\r\nconst mimeTypeToResolvedType = (mimeType: string): ResolvedFileType => {\r\n if (!mimeType) return \"other\";\r\n\r\n const type = mimeType.toLowerCase();\r\n\r\n if (isImage(type)) return \"image\";\r\n if (isVideo(type)) return \"video\";\r\n if (isAudio(type)) return \"audio\";\r\n if (isDocument(type)) return \"document\";\r\n if (isArchive(type)) return \"archive\";\r\n if (isCode(type)) return \"code\";\r\n if (isFont(type)) return \"font\";\r\n\r\n return \"other\";\r\n};\r\n\r\n// Optional: Export the predicate functions if you need them elsewhere\r\nconst fileTypePredicates = {\r\n isImage,\r\n isVideo,\r\n isAudio,\r\n isDocument,\r\n isArchive,\r\n isCode,\r\n isFont,\r\n};\r\n\r\n/**\r\n * Generates a text.txt file so you can test file uploading is working\r\n */\r\nfunction generateTestFile() {\r\n // Create test content\r\n const textContent = \"Hello, this is a test file for S3 upload!\";\r\n const buffer = Buffer.from(textContent, \"utf-8\");\r\n\r\n // Create a File object (assuming you have File constructor available in Bun)\r\n const testFile = new File([buffer], \"test.txt\", { type: \"text/plain\" });\r\n\r\n return testFile;\r\n}\r\n\r\n/**\r\n * @returns url of the file\r\n */\r\nfunction
|
|
5
|
+
"import type { ResolvedFileType, StorageObject } from \"../types\";\r\n\r\nconst isImage = (type: string): boolean => type.startsWith(\"image/\");\r\n\r\nconst isVideo = (type: string): boolean => type.startsWith(\"video/\");\r\n\r\nconst isAudio = (type: string): boolean => type.startsWith(\"audio/\");\r\n\r\nconst isDocument = (type: string): boolean =>\r\n type.startsWith(\"text/\") ||\r\n type.includes(\"pdf\") ||\r\n type.includes(\"word\") ||\r\n type.includes(\"sheet\") ||\r\n type.includes(\"presentation\") ||\r\n type.includes(\"opendocument\") ||\r\n type === \"application/rtf\";\r\n\r\nconst isArchive = (type: string): boolean =>\r\n type.includes(\"zip\") ||\r\n type.includes(\"rar\") ||\r\n type.includes(\"tar\") ||\r\n type.includes(\"7z\") ||\r\n type.includes(\"gzip\");\r\n\r\nconst isCode = (type: string): boolean =>\r\n type === \"application/javascript\" ||\r\n type === \"application/json\" ||\r\n type === \"text/html\" ||\r\n type === \"text/css\" ||\r\n type === \"application/xml\" ||\r\n type.includes(\"javascript\");\r\n\r\nconst isFont = (type: string): boolean =>\r\n type.startsWith(\"font/\") || type.includes(\"font\");\r\n\r\n/**\r\n * Maps MIME types to file categories\r\n * @param mimeType - The MIME type string\r\n * @returns FileType category\r\n */\r\nconst mimeTypeToResolvedType = (mimeType: string): ResolvedFileType => {\r\n if (!mimeType) return \"other\";\r\n\r\n const type = mimeType.toLowerCase();\r\n\r\n if (isImage(type)) return \"image\";\r\n if (isVideo(type)) return \"video\";\r\n if (isAudio(type)) return \"audio\";\r\n if (isDocument(type)) return \"document\";\r\n if (isArchive(type)) return \"archive\";\r\n if (isCode(type)) return \"code\";\r\n if (isFont(type)) return \"font\";\r\n\r\n return \"other\";\r\n};\r\n\r\n// Optional: Export the predicate functions if you need them elsewhere\r\nconst fileTypePredicates = {\r\n isImage,\r\n isVideo,\r\n isAudio,\r\n isDocument,\r\n isArchive,\r\n isCode,\r\n isFont,\r\n};\r\n\r\n/**\r\n * Generates a text.txt file so you can test file uploading is working\r\n */\r\nfunction generateTestFile() {\r\n // Create test content\r\n const textContent = \"Hello, this is a test file for S3 upload!\";\r\n const buffer = Buffer.from(textContent, \"utf-8\");\r\n\r\n // Create a File object (assuming you have File constructor available in Bun)\r\n const testFile = new File([buffer], \"test.txt\", { type: \"text/plain\" });\r\n\r\n return testFile;\r\n}\r\n\r\n/**\r\n * @returns url of the file\r\n */\r\nfunction getObjectUrl(\r\n storageObject: StorageObject,\r\n options?: { bucket?: string }\r\n): string {\r\n // External file\r\n if (storageObject.url) {\r\n return storageObject.url;\r\n }\r\n\r\n // Internal file\r\n if (storageObject.key) {\r\n if (storageObject.isPrivate) {\r\n return `/storage/${storageObject.key}`; // Proxy through server\r\n } else {\r\n return `https://${\r\n options?.bucket ?? process.env.AWS_BUCKET\r\n }.s3.amazonaws.com/${storageObject.key}`; // Direct S3\r\n }\r\n }\r\n\r\n throw new Error(\"Invalid storage object\");\r\n}\r\n\r\nexport {\r\n mimeTypeToResolvedType,\r\n fileTypePredicates,\r\n getObjectUrl,\r\n generateTestFile,\r\n};\r\n",
|
|
6
6
|
"export type BRPCErrorCode =\r\n | \"BAD_REQUEST\"\r\n | \"UNAUTHORIZED\"\r\n | \"FORBIDDEN\"\r\n | \"NOT_FOUND\"\r\n | \"METHOD_NOT_SUPPORTED\"\r\n | \"TIMEOUT\"\r\n | \"CONFLICT\"\r\n | \"PRECONDITION_FAILED\"\r\n | \"PAYLOAD_TOO_LARGE\"\r\n | \"UNPROCESSABLE_CONTENT\"\r\n | \"TOO_MANY_REQUESTS\"\r\n | \"CLIENT_CLOSED_REQUEST\"\r\n | \"INTERNAL_SERVER_ERROR\"\r\n | \"NOT_IMPLEMENTED\"\r\n | \"BAD_GATEWAY\"\r\n | \"SERVICE_UNAVAILABLE\"\r\n | \"GATEWAY_TIMEOUT\";\r\n\r\nexport interface BRPCErrorOptions {\r\n code: BRPCErrorCode;\r\n message: string;\r\n clientCode?: string; // Custom code for client-side detection\r\n cause?: Error;\r\n data?: Record<string, any>;\r\n}\r\n\r\nexport class BRPCError extends Error {\r\n public readonly code: BRPCErrorCode;\r\n public readonly clientCode?: string;\r\n public readonly httpStatus: number;\r\n public readonly data?: Record<string, any>;\r\n public readonly cause?: Error;\r\n\r\n private static readonly STATUS_MAP: Record<BRPCErrorCode, number> = {\r\n BAD_REQUEST: 400,\r\n UNAUTHORIZED: 401,\r\n FORBIDDEN: 403,\r\n NOT_FOUND: 404,\r\n METHOD_NOT_SUPPORTED: 405,\r\n TIMEOUT: 408,\r\n CONFLICT: 409,\r\n PRECONDITION_FAILED: 412,\r\n PAYLOAD_TOO_LARGE: 413,\r\n UNPROCESSABLE_CONTENT: 422,\r\n TOO_MANY_REQUESTS: 429,\r\n CLIENT_CLOSED_REQUEST: 499,\r\n INTERNAL_SERVER_ERROR: 500,\r\n NOT_IMPLEMENTED: 501,\r\n BAD_GATEWAY: 502,\r\n SERVICE_UNAVAILABLE: 503,\r\n GATEWAY_TIMEOUT: 504,\r\n };\r\n\r\n constructor(options: BRPCErrorOptions) {\r\n super(options.message);\r\n\r\n this.name = \"BRPCError\";\r\n this.code = options.code;\r\n this.clientCode = options.clientCode;\r\n this.httpStatus = BRPCError.STATUS_MAP[options.code];\r\n this.data = options.data;\r\n this.cause = options.cause;\r\n\r\n // Maintains proper stack trace for where our error was thrown (only available on V8)\r\n if (Error.captureStackTrace) {\r\n Error.captureStackTrace(this, BRPCError);\r\n }\r\n }\r\n\r\n /**\r\n * Create a serializable object for sending to frontend\r\n */\r\n toJSON() {\r\n return {\r\n name: this.name,\r\n code: this.code,\r\n clientCode: this.clientCode,\r\n message: this.message,\r\n data: this.data,\r\n httpStatus: this.httpStatus,\r\n };\r\n }\r\n\r\n /**\r\n * Static factory methods for common errors\r\n */\r\n static badRequest(\r\n message: string,\r\n clientCode?: string,\r\n data?: Record<string, any>\r\n ) {\r\n return new BRPCError({ code: \"BAD_REQUEST\", message, clientCode, data });\r\n }\r\n\r\n static unauthorized(\r\n message: string = \"Unauthorized\",\r\n clientCode?: string,\r\n data?: Record<string, any>\r\n ) {\r\n return new BRPCError({ code: \"UNAUTHORIZED\", message, clientCode, data });\r\n }\r\n\r\n static forbidden(\r\n message: string = \"Forbidden\",\r\n clientCode?: string,\r\n data?: Record<string, any>\r\n ) {\r\n return new BRPCError({ code: \"FORBIDDEN\", message, clientCode, data });\r\n }\r\n\r\n static notFound(\r\n message: string = \"Not Found\",\r\n clientCode?: string,\r\n data?: Record<string, any>\r\n ) {\r\n return new BRPCError({ code: \"NOT_FOUND\", message, clientCode, data });\r\n }\r\n\r\n static preconditionFailed(\r\n message: string = \"Precondition failed\",\r\n clientCode?: string,\r\n data?: Record<string, any>\r\n ) {\r\n return new BRPCError({ code: \"NOT_FOUND\", message, clientCode, data });\r\n }\r\n\r\n static conflict(\r\n message: string,\r\n clientCode?: string,\r\n data?: Record<string, any>\r\n ) {\r\n return new BRPCError({ code: \"CONFLICT\", message, clientCode, data });\r\n }\r\n\r\n static unprocessableContent(\r\n message: string,\r\n clientCode?: string,\r\n data?: Record<string, any>\r\n ) {\r\n return new BRPCError({\r\n code: \"UNPROCESSABLE_CONTENT\",\r\n message,\r\n clientCode,\r\n data,\r\n });\r\n }\r\n\r\n static tooManyRequests(\r\n message: string = \"Too many requests\",\r\n clientCode?: string,\r\n data?: Record<string, any>\r\n ) {\r\n return new BRPCError({\r\n code: \"TOO_MANY_REQUESTS\",\r\n message,\r\n clientCode,\r\n data,\r\n });\r\n }\r\n\r\n static internalServerError(\r\n message: string = \"Internal Server Error\",\r\n clientCode?: string,\r\n data?: Record<string, any>\r\n ) {\r\n return new BRPCError({\r\n code: \"INTERNAL_SERVER_ERROR\",\r\n message,\r\n clientCode,\r\n data,\r\n });\r\n }\r\n\r\n static timeout(\r\n message: string = \"Request timeout\",\r\n clientCode?: string,\r\n data?: Record<string, any>\r\n ) {\r\n return new BRPCError({ code: \"TIMEOUT\", message, clientCode, data });\r\n }\r\n}\r\n",
|
|
7
|
-
"import type { BunFile } from \"bun\";\r\nimport type { OptimizedImageBuffer } from \"./types\";\r\nimport { BRPCError } from \"../../errors\";\r\nimport { fileTypePredicates } from \"../utils\";\r\nimport sharp from \"sharp\";\r\n\r\nexport async function optimizeImage(\r\n file: File | BunFile,\r\n opts: {\r\n width?: number;\r\n quality?: number;\r\n } = {}\r\n): Promise<OptimizedImageBuffer> {\r\n // doing like this because zod can\r\n // directly pass undefined, overriding\r\n // the defaults that are only for not provided\r\n // not for strict undefined\r\n const width = opts.width ?? 1200;\r\n const quality = opts.quality ?? 75;\r\n\r\n if (!file) {\r\n throw BRPCError.conflict(\"A file must be provided in order to optimize\");\r\n }\r\n\r\n if (!fileTypePredicates.isImage(file.type)) {\r\n
|
|
7
|
+
"import type { BunFile } from \"bun\";\r\nimport type { OptimizedImageBuffer } from \"./types\";\r\nimport { BRPCError } from \"../../errors\";\r\nimport { fileTypePredicates } from \"../utils\";\r\nimport sharp from \"sharp\";\r\n\r\n/**\r\n * file can be File, BunFile or string (base64)\r\n */\r\nexport async function optimizeImage(\r\n file: File | BunFile | string,\r\n opts: {\r\n width?: number;\r\n quality?: number;\r\n originalMimeType?: string; // like image/png from base64\r\n } = {}\r\n): Promise<OptimizedImageBuffer> {\r\n // doing like this because zod can\r\n // directly pass undefined, overriding\r\n // the defaults that are only for not provided\r\n // not for strict undefined\r\n const width = opts.width ?? 1200;\r\n const quality = opts.quality ?? 75;\r\n\r\n if (!file) {\r\n throw BRPCError.conflict(\"A file must be provided in order to optimize\");\r\n }\r\n\r\n let buffer: Buffer | ArrayBuffer;\r\n let name = \"unknown.webp\";\r\n let type = \"image/webp\";\r\n\r\n if (typeof file === \"string\") {\r\n // base64 input\r\n const [meta, data] = file.split(\",\");\r\n type = meta.match(/:(.*?);/)?.[1] ?? \"image/webp\";\r\n buffer = Buffer.from(data, \"base64\");\r\n } else {\r\n if (!fileTypePredicates.isImage(file.type)) {\r\n throw BRPCError.conflict(\"The file must be an image to be optimized\");\r\n }\r\n buffer = await file.arrayBuffer();\r\n name = file.name ?? name;\r\n type = file.type ?? type;\r\n }\r\n\r\n const optimizedBuffer = await sharp(buffer)\r\n .resize(width, null, { withoutEnlargement: true })\r\n .webp({ quality: quality })\r\n .toBuffer();\r\n\r\n return {\r\n buffer: optimizedBuffer,\r\n metadata: {\r\n name: name.replace(/\\.[^/.]+$/, \".webp\"),\r\n type: type,\r\n extension: \".webp\",\r\n resolvedType: \"image\",\r\n },\r\n };\r\n}\r\n",
|
|
8
8
|
"import sharp from \"sharp\";\r\nimport { local } from \"../local\";\r\nimport { fileTypePredicates } from \"../utils\";\r\nimport type { GetOptimizedImageOptions } from \"./types\";\r\n\r\n/**\r\n * Returns an existing optimized image from cache or\r\n * creates one on the fly\r\n * @example\r\n * ```ts\r\n * const optimizedImage = await getImage({\r\n * key: \"originalFileKey\",\r\n * width: 800\r\n * })\r\n * if (!optimizedImage) throw BRPCError.notFound()\r\n * return optimizedImage\r\n * ```\r\n */\r\nexport async function getOptimizedImage(options: GetOptimizedImageOptions) {\r\n // const url = new URL(req.url);\r\n // const imagePath = url.searchParams.get(\"src\");\r\n // const width = parseInt(url.searchParams.get(\"w\") || \"800\");\r\n // const quality = parseInt(url.searchParams.get(\"q\") || \"75\");\r\n\r\n const localCache = `./cache/images/${options.key}_${options.width}_${options.quality}.webp`;\r\n\r\n // 1. Check local cache\r\n const localFile = await local.getOne(localCache);\r\n\r\n if (localFile) {\r\n if (!fileTypePredicates.isImage(localFile.type)) {\r\n return null;\r\n }\r\n return localFile;\r\n }\r\n\r\n // 2. Check Spaces cache - using Bun's global s3 instance\r\n // const cachedFile = s3.file(`appS3Folder/cache/${cacheKey}`);\r\n // if (await cachedFile.exists()) {\r\n // const cached = await cachedFile.arrayBuffer();\r\n // await Bun.write(localCache, cached);\r\n // return new Response(cached, {\r\n // headers: { 'Content-Type': 'image/webp' }\r\n // });\r\n // }\r\n\r\n // 3. Fetch from Spaces, optimize, cache\r\n // const originalFile = s3.file(`originals/${imagePath}`);\r\n // const originalBuffer = await originalFile.arrayBuffer();\r\n\r\n // 3.2 Fetch from local\r\n // const originalPath = `./buckets/cache/images/originals/${options.path}`;\r\n const originalKey = options.key;\r\n const originalFile = await local.getOne(originalKey);\r\n\r\n if (!originalFile) return null;\r\n\r\n if (!fileTypePredicates.isImage(originalFile.type)) {\r\n return null;\r\n }\r\n\r\n const buffer = await originalFile.arrayBuffer();\r\n\r\n const optimizedBuffer = await sharp(buffer)\r\n .resize(options.width, null, { withoutEnlargement: true })\r\n .webp({ quality: options.quality ?? 75 })\r\n .toBuffer();\r\n\r\n // Cache everywhere\r\n // await Promise.all([\r\n // Bun.write(localCache, optimizedBuffer),\r\n // cachedFile.write(optimizedBuffer, { type: 'image/webp' })\r\n // ]);\r\n\r\n // Cache to local\r\n await Bun.write(localCache, optimizedBuffer);\r\n\r\n const cachedFile = Bun.file(localCache);\r\n\r\n const exists = await cachedFile.exists();\r\n\r\n if (!exists) return null;\r\n\r\n return cachedFile;\r\n}\r\n",
|
|
9
9
|
"import { randomUUID } from \"crypto\";\r\nimport { extname } from \"path\";\r\nimport type { SafeResult } from \"../../types\";\r\n\r\ntype UploadSuccess = {\r\n key: string;\r\n file: File;\r\n bytesWritten: number;\r\n};\r\n\r\n/**\r\n * Uploads a file to local filesystem\r\n * @param path - The folder path (e.g. \"public/images\")\r\n * @param file - The file to upload\r\n * @param filename - Optional custom filename to use instead of original file.name\r\n * @returns Promise<SafeResult<number>> - Success: {data: bytesWritten, error: null}\r\n * Failure: {data: null, error: Error}\r\n *\r\n * Example:\r\n * ```ts\r\n * const {data, error} = await uploadToLocal(\"public/avatars\", userPhoto);\r\n * if (error) {\r\n * console.error(\"Upload failed:\", error);\r\n * return;\r\n * }\r\n * console.log(`Uploaded ${data} bytes`);\r\n * ```\r\n */\r\nasync function uploadOne(\r\n path: string,\r\n file: File,\r\n _filename?: string\r\n): Promise<SafeResult<UploadSuccess>> {\r\n if (!file)\r\n return {\r\n data: null,\r\n error: new Error(`File not found`),\r\n };\r\n\r\n const cleanPath = path.replace(/^\\/+|\\/+$/g, \"\");\r\n const ext = extname(file.name);\r\n const uniqueName = `${randomUUID()}${ext}`;\r\n const filePath = `${cleanPath}/${uniqueName}`;\r\n const fullPath = `./buckets/${cleanPath}/${uniqueName}`;\r\n\r\n try {\r\n const writtenBytes = await Bun.write(fullPath, file);\r\n return {\r\n data: {\r\n key: filePath,\r\n file: file,\r\n bytesWritten: writtenBytes,\r\n },\r\n error: null,\r\n };\r\n } catch (err) {\r\n return {\r\n data: null,\r\n error: new Error(`Failed to upload ${file.name} to local filesystem`),\r\n };\r\n }\r\n}\r\n\r\nasync function uploadMany(\r\n path: string,\r\n files: File[],\r\n nameGetter?: (file: File) => string\r\n): Promise<SafeResult<UploadSuccess>[]> {\r\n if (!files || files.length === 0) {\r\n return [];\r\n }\r\n\r\n const uploadPromises = files.map((file) => {\r\n const filename = nameGetter?.(file) ?? file.name;\r\n return uploadOne(path, file, filename);\r\n });\r\n\r\n const results = await Promise.all(uploadPromises);\r\n\r\n return results;\r\n}\r\n\r\nasync function getOne(key: string) {\r\n const file = Bun.file(`./buckets/${key}`);\r\n const exists = await file.exists();\r\n\r\n if (!exists) return null;\r\n\r\n return file;\r\n}\r\n\r\nasync function deleteOne(key: string) {\r\n const file = Bun.file(`./buckets/${key}`);\r\n const exists = await file.exists();\r\n\r\n if (!exists) return false;\r\n\r\n await file.delete();\r\n\r\n return true;\r\n}\r\n\r\nexport const local = {\r\n uploadOne,\r\n uploadMany,\r\n getOne,\r\n deleteOne,\r\n};\r\n",
|
|
10
10
|
"import type { Acl, InsertStorageObjet } from \"../types\";\r\nimport bunPath from \"path\";\r\nimport { mimeTypeToResolvedType } from \"../utils\";\r\nimport { BRPCError } from \"../../errors/BRPCError\";\r\nimport { CONSTRUCTED_AWS_FOLDER } from \"./constants\";\r\nimport { s3 as s3Bun } from \"bun\";\r\nimport type { OptimizedImageBuffer } from \"../images\";\r\n\r\n/**\r\n * Uploads a file or optimized buffer to S3 with UUID-based naming\r\n *\r\n * @param path - S3 folder path (e.g. \"images/avatars\")\r\n * @param file - File object or OptimizedBuffer from optimize()\r\n * @returns SafeResult with S3 key, bytes written, isPrivate and metadata for database storage\r\n *\r\n * @throws {Error} When buffer is provided without required metadata\r\n *\r\n * @example\r\n * ```typescript\r\n * // regular files\r\n * const result = await uploadOne('images', userFile);\r\n *\r\n * // optimized images\r\n * const optimized = await optimize(bunFile);\r\n * const result2 = await uploadOne('images/optimized', optimized);\r\n *\r\n * if (result.error) throw BRPCError.conlict(\"Error uploading \")\r\n *\r\n * if (result.data) {\r\n * console.log(`Uploaded: ${result.data.key}`);\r\n * // Save metadata to DB: result.data.metadata\r\n * }\r\n * ```\r\n */\r\nasync function uploadOne(\r\n path: string,\r\n file: File | OptimizedImageBuffer,\r\n opts?: { acl?: Acl; externalReference?: string; uploadedBy?: string }\r\n): Promise<InsertStorageObjet> {\r\n // Extract file info based on type\r\n const fileInfo =\r\n \"buffer\" in file\r\n ? {\r\n buffer: file.buffer,\r\n metadata: file.metadata,\r\n }\r\n : {\r\n buffer: file,\r\n metadata: {\r\n name: file.name,\r\n type: file.type,\r\n extension: bunPath.extname(file.name),\r\n resolvedType: mimeTypeToResolvedType(file.type),\r\n },\r\n };\r\n\r\n // Validate metadata for buffer uploads\r\n if (\"buffer\" in file && !file.metadata) {\r\n throw BRPCError.badRequest(\"Metadata required when uploading buffer\");\r\n }\r\n\r\n // Common upload logic\r\n const cleanPath = path.length > 1 ? `${path.replace(/^\\/+|\\/+$/g, \"\")}/` : \"\";\r\n const fileName = `${crypto.randomUUID()}${fileInfo.metadata.extension}`;\r\n const key = `${CONSTRUCTED_AWS_FOLDER}${cleanPath}${fileName}`;\r\n\r\n const s3file = s3Bun.file(key);\r\n\r\n const acl = opts?.acl ?? \"public-read\";\r\n\r\n const isPrivate = acl !== \"public-read\" && acl !== \"public-read-write\";\r\n\r\n const writtenBytes = await s3file.write(fileInfo.buffer, {\r\n acl: acl,\r\n });\r\n\r\n const digestedObject: InsertStorageObjet = {\r\n uploadedBy: opts?.uploadedBy ?? null,\r\n key: key,\r\n url: null,\r\n name: fileInfo.metadata.name,\r\n thumbnail: null,\r\n resolvedType: fileInfo.metadata.resolvedType,\r\n provider: \"s3\",\r\n isPrivate: isPrivate,\r\n metadata: {\r\n size: writtenBytes,\r\n type: fileInfo.metadata.type,\r\n extension: fileInfo.metadata.extension,\r\n acl: acl,\r\n },\r\n isActive: true,\r\n };\r\n\r\n return digestedObject;\r\n}\r\n\r\nexport { uploadOne };\r\n",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"import { BRPCError } from \"../../errors\";\r\nimport { s3 as s3Bun } from \"bun\";\r\nimport type { DeleteOneResult } from \"./types\";\r\n\r\nexport async function deleteOne(\r\n key: string,\r\n opts?: { debug?: boolean }\r\n): Promise<DeleteOneResult> {\r\n if (!key || typeof key !== \"string\") {\r\n throw BRPCError.badRequest(\"Key is required\");\r\n }\r\n\r\n const sanitizedKey = key.trim();\r\n if (!sanitizedKey || sanitizedKey.length === 0) {\r\n throw BRPCError.badRequest(\"Key must be a non-empty string\");\r\n }\r\n\r\n try {\r\n await s3Bun.delete(key);\r\n return {\r\n key: key,\r\n deleted: true,\r\n error: null,\r\n };\r\n } catch (e) {\r\n return {\r\n key: key,\r\n deleted: false,\r\n error: e as Error,\r\n };\r\n // if (opts?.debug) {\r\n // console.error(`Error deleting file with key \"${key}\"`, e);\r\n // }\r\n //? Handle this at app level\r\n // throw BRPCError.conflict(\r\n // \"There was an error when trying to delete the file\",\r\n // \"FILE_NOT_DELETED\"\r\n // );\r\n }\r\n}\r\n",
|
|
13
13
|
"import { s3 as s3Bun } from \"bun\";\r\n\r\n/**\r\n * Checks a file existance in S3\r\n */\r\nasync function checkFileExistance(\r\n key: string,\r\n opts: { debug?: boolean } = { debug: process.env.NODE_ENV !== \"production\" }\r\n): Promise<{ exists: boolean; error: null } | { exists: null; error: Error }> {\r\n try {\r\n const exists = await s3Bun.exists(key);\r\n return { exists, error: null };\r\n } catch (e) {\r\n if (opts?.debug) {\r\n console.error(\"There was an error checking for file existance\", e);\r\n }\r\n return { exists: null, error: e as Error };\r\n }\r\n}\r\n\r\nexport { checkFileExistance };\r\n"
|
|
14
14
|
],
|
|
15
|
-
"mappings": ";AAEA,IAAM,EAAU,CAAC,IAA0B,EAAK,WAAW,QAAQ,EAE7D,EAAU,CAAC,IAA0B,EAAK,WAAW,QAAQ,EAE7D,EAAU,CAAC,IAA0B,EAAK,WAAW,QAAQ,EAE7D,EAAa,CAAC,IAClB,EAAK,WAAW,OAAO,GACvB,EAAK,SAAS,KAAK,GACnB,EAAK,SAAS,MAAM,GACpB,EAAK,SAAS,OAAO,GACrB,EAAK,SAAS,cAAc,GAC5B,EAAK,SAAS,cAAc,GAC5B,IAAS,kBAEL,EAAY,CAAC,IACjB,EAAK,SAAS,KAAK,GACnB,EAAK,SAAS,KAAK,GACnB,EAAK,SAAS,KAAK,GACnB,EAAK,SAAS,IAAI,GAClB,EAAK,SAAS,MAAM,EAEhB,EAAS,CAAC,IACd,IAAS,0BACT,IAAS,oBACT,IAAS,aACT,IAAS,YACT,IAAS,mBACT,EAAK,SAAS,YAAY,EAEtB,EAAS,CAAC,IACd,EAAK,WAAW,OAAO,GAAK,EAAK,SAAS,MAAM,EAO5C,EAAyB,CAAC,IAAuC,CACrE,GAAI,CAAC,EAAU,MAAO,QAEtB,IAAM,EAAO,EAAS,YAAY,EAElC,GAAI,EAAQ,CAAI,EAAG,MAAO,QAC1B,GAAI,EAAQ,CAAI,EAAG,MAAO,QAC1B,GAAI,EAAQ,CAAI,EAAG,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ACL,QAAS,GACT,MAAO,IACT,EACA,MAAO,EAAG,CACV,MAAO,CACL,IAAK,EACL,QAAS,GACT,MAAO,CACT,GC7BJ,yBAKA,eAAe,EAAkB,CAC/B,EACA,EAA4B,CAAE,MAAO,EAAsC,EACC,CAC5E,GAAI,CAEF,MAAO,CAAE,OADM,MAAM,EAAM,OAAO,CAAG,EACpB,MAAO,IAAK,EAC7B,MAAO,EAAG,CACV,GAAI,GAAM,MACR,QAAQ,MAAM,iDAAkD,CAAC,EAEnE,MAAO,CAAE,OAAQ,KAAM,MAAO,CAAW",
|
|
16
|
+
"debugId": "12A04BF9E699859764756E2164756E21",
|
|
17
17
|
"names": []
|
|
18
18
|
}
|
|
@@ -21,7 +21,7 @@ declare function generateTestFile(): File;
|
|
|
21
21
|
/**
|
|
22
22
|
* @returns url of the file
|
|
23
23
|
*/
|
|
24
|
-
declare function
|
|
24
|
+
declare function getObjectUrl(storageObject: StorageObject, options?: {
|
|
25
25
|
bucket?: string;
|
|
26
26
|
}): string;
|
|
27
|
-
export { mimeTypeToResolvedType, fileTypePredicates,
|
|
27
|
+
export { mimeTypeToResolvedType, fileTypePredicates, getObjectUrl, generateTestFile, };
|