firebase-storage
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -57,6 +57,7 @@ export interface StorageObject { | ||
}; | ||
export declare const getStorage: ({ clientEmail, privateKey, bucket: _bucket, }: { | ||
export declare const getStorage: ({ clientEmail, privateKey, bucket: _bucket, parallels, }: { | ||
clientEmail: string; | ||
privateKey: string; | ||
bucket?: string | undefined; | ||
parallels?: number | undefined; | ||
}) => { | ||
@@ -63,0 +64,0 @@ info: (params: ParamType<typeof info>) => Promise<StorageObject>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getStorage = exports.list = exports.del = exports.upload = exports.download = exports.info = exports.createToken = void 0; | ||
const semaphore_1 = require("@node-libraries/semaphore"); | ||
const jose_1 = require("jose"); | ||
@@ -91,3 +92,3 @@ const createToken = ({ clientEmail, privateKey, }) => (0, jose_1.importPKCS8)(privateKey, "RS256").then((key) => new jose_1.SignJWT({ | ||
exports.list = list; | ||
const getStorage = ({ clientEmail, privateKey, bucket: _bucket, }) => { | ||
const getStorage = ({ clientEmail, privateKey, bucket: _bucket, parallels = 1000, }) => { | ||
const property = { | ||
@@ -110,30 +111,46 @@ token: "", | ||
}; | ||
const s = (0, semaphore_1.semaphore)(parallels); | ||
return { | ||
info: async (params) => (0, exports.info)({ | ||
...params, | ||
token: await getToken(), | ||
bucket: getBucket(params.bucket), | ||
}), | ||
download: async (params) => (0, exports.download)({ | ||
...params, | ||
token: await getToken(), | ||
bucket: getBucket(params.bucket), | ||
}), | ||
upload: async (params) => (0, exports.upload)({ | ||
...params, | ||
token: await getToken(), | ||
bucket: getBucket(params.bucket), | ||
}), | ||
del: async (params) => (0, exports.del)({ | ||
...params, | ||
token: await getToken(), | ||
bucket: getBucket(params.bucket), | ||
}), | ||
list: async (params) => (0, exports.list)({ | ||
...params, | ||
token: await getToken(), | ||
bucket: getBucket(params.bucket), | ||
}), | ||
info: async (params) => { | ||
await s.acquire(); | ||
return (0, exports.info)({ | ||
...params, | ||
token: await getToken(), | ||
bucket: getBucket(params.bucket), | ||
}).finally(() => s.release()); | ||
}, | ||
download: async (params) => { | ||
await s.acquire(); | ||
return (0, exports.download)({ | ||
...params, | ||
token: await getToken(), | ||
bucket: getBucket(params.bucket), | ||
}).finally(() => s.release()); | ||
}, | ||
upload: async (params) => { | ||
await s.acquire(); | ||
return (0, exports.upload)({ | ||
...params, | ||
token: await getToken(), | ||
bucket: getBucket(params.bucket), | ||
}).finally(() => s.release()); | ||
}, | ||
del: async (params) => { | ||
await s.acquire(); | ||
return (0, exports.del)({ | ||
...params, | ||
token: await getToken(), | ||
bucket: getBucket(params.bucket), | ||
}).finally(() => s.release()); | ||
}, | ||
list: async (params) => { | ||
await s.acquire(); | ||
return (0, exports.list)({ | ||
...params, | ||
token: await getToken(), | ||
bucket: getBucket(params.bucket), | ||
}).finally(() => s.release()); | ||
}, | ||
}; | ||
}; | ||
exports.getStorage = getStorage; |
@@ -57,6 +57,7 @@ export interface StorageObject { | ||
}; | ||
export declare const getStorage: ({ clientEmail, privateKey, bucket: _bucket, }: { | ||
export declare const getStorage: ({ clientEmail, privateKey, bucket: _bucket, parallels, }: { | ||
clientEmail: string; | ||
privateKey: string; | ||
bucket?: string | undefined; | ||
parallels?: number | undefined; | ||
}) => { | ||
@@ -63,0 +64,0 @@ info: (params: ParamType<typeof info>) => Promise<StorageObject>; |
@@ -0,1 +1,2 @@ | ||
import { semaphore } from "@node-libraries/semaphore"; | ||
import { SignJWT, importPKCS8 } from "jose"; | ||
@@ -82,3 +83,3 @@ export const createToken = ({ clientEmail, privateKey, }) => importPKCS8(privateKey, "RS256").then((key) => new SignJWT({ | ||
}; | ||
export const getStorage = ({ clientEmail, privateKey, bucket: _bucket, }) => { | ||
export const getStorage = ({ clientEmail, privateKey, bucket: _bucket, parallels = 1000, }) => { | ||
const property = { | ||
@@ -101,29 +102,45 @@ token: "", | ||
}; | ||
const s = semaphore(parallels); | ||
return { | ||
info: async (params) => info({ | ||
...params, | ||
token: await getToken(), | ||
bucket: getBucket(params.bucket), | ||
}), | ||
download: async (params) => download({ | ||
...params, | ||
token: await getToken(), | ||
bucket: getBucket(params.bucket), | ||
}), | ||
upload: async (params) => upload({ | ||
...params, | ||
token: await getToken(), | ||
bucket: getBucket(params.bucket), | ||
}), | ||
del: async (params) => del({ | ||
...params, | ||
token: await getToken(), | ||
bucket: getBucket(params.bucket), | ||
}), | ||
list: async (params) => list({ | ||
...params, | ||
token: await getToken(), | ||
bucket: getBucket(params.bucket), | ||
}), | ||
info: async (params) => { | ||
await s.acquire(); | ||
return info({ | ||
...params, | ||
token: await getToken(), | ||
bucket: getBucket(params.bucket), | ||
}).finally(() => s.release()); | ||
}, | ||
download: async (params) => { | ||
await s.acquire(); | ||
return download({ | ||
...params, | ||
token: await getToken(), | ||
bucket: getBucket(params.bucket), | ||
}).finally(() => s.release()); | ||
}, | ||
upload: async (params) => { | ||
await s.acquire(); | ||
return upload({ | ||
...params, | ||
token: await getToken(), | ||
bucket: getBucket(params.bucket), | ||
}).finally(() => s.release()); | ||
}, | ||
del: async (params) => { | ||
await s.acquire(); | ||
return del({ | ||
...params, | ||
token: await getToken(), | ||
bucket: getBucket(params.bucket), | ||
}).finally(() => s.release()); | ||
}, | ||
list: async (params) => { | ||
await s.acquire(); | ||
return list({ | ||
...params, | ||
token: await getToken(), | ||
bucket: getBucket(params.bucket), | ||
}).finally(() => s.release()); | ||
}, | ||
}; | ||
}; |
{ | ||
"name": "firebase-storage", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"main": "./dist/cjs/index.js", | ||
@@ -20,15 +20,16 @@ "types": "./dist/cjs/index.d.ts", | ||
"dependencies": { | ||
"jose": "^5.1.3" | ||
"@node-libraries/semaphore": "^1.0.3", | ||
"jose": "^5.2.2" | ||
}, | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^6.13.2", | ||
"@typescript-eslint/parser": "^6.13.2", | ||
"@typescript-eslint/eslint-plugin": "^7.0.2", | ||
"@typescript-eslint/parser": "^7.0.2", | ||
"cpy-cli": "^5.0.0", | ||
"eslint": "8.55.0", | ||
"eslint": "8.56.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-import-resolver-typescript": "^3.6.1", | ||
"eslint-plugin-import": "^2.29.0", | ||
"eslint-plugin-import": "^2.29.1", | ||
"rimraf": "^5.0.5", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.3.2" | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.3.3" | ||
}, | ||
@@ -35,0 +36,0 @@ "keywords": [ |
@@ -16,5 +16,6 @@ # firebase-storage | ||
const bucket = "XXXXXXXX.appspot.com"; // Can also be specified in each function | ||
const parallels = 5; //default 1000 | ||
async function main() { | ||
const storage = getStorage({ privateKey, clientEmail, bucket }); | ||
const storage = getStorage({ privateKey, clientEmail, bucket, parallels }); | ||
const file = new Blob(["Test value"], { | ||
@@ -21,0 +22,0 @@ type: "text/plain", |
17879
436
48
2
+ Added@node-libraries/semaphore@1.0.3(transitive)
Updatedjose@^5.2.2