Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 28 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
{
"$schema": "https://json.schemastore.org/package.json",
"private": true,
"name": "@tus/azure-store",
"version": "2.0.0",
"description": "Azure blob storage for @tus/server",
"main": "./dist/index.js",
"exports": "./dist/index.js",
Comment thread
sam-ayo marked this conversation as resolved.
Outdated
"type": "module",
"workspaces": [
"packages/*",
"test"
"homepage": "https://github.com/tus/tus-node-server#readme",
"bugs": "https://github.com/tus/tus-node-server/issues",
"repository": "tus/tus-node-server",
"files": [
"dist",
"src",
"!test*"
],
"license": "MIT",
"scripts": {
"build": "tsc --build",
"lint": "biome lint --write .",
"format": "biome format --write .",
"format:check": "biome format --error-on-warnings .",
"pretest": "tsc --build",
"test": "npm test -w ./packages",
"version": "changeset version && npm install",
"release": "gh workflow run release",
"release:local": "npm run build && changeset publish"
"test": "mocha './dist/test/*.js' --exit"
},
"dependencies": {
"@tus/utils": "^0.6.0",
"@azure/storage-blob": "^12.24.0",
"debug": "^4.3.4"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.29.2",
"typescript": "^5.8.2"
"@types/debug": "^4.1.12",
"@types/mocha": "^10.0.6",
"@types/node": "^22.13.7",
"mocha": "^11.0.1",
"should": "^13.2.3"
},
"engines": {
"node": ">=20.19.0"
}
}
}
3 changes: 2 additions & 1 deletion packages/azure-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
},
"dependencies": {
"@tus/utils": "^0.6.0",
"@azure/core-auth": "^1.9.0",
"@azure/storage-blob": "^12.24.0",
"debug": "^4.3.4"
},
Expand All @@ -35,4 +36,4 @@
"engines": {
"node": ">=20.19.0"
}
}
}
19 changes: 10 additions & 9 deletions packages/azure-store/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ import {
type ContainerClient,
StorageSharedKeyCredential,
} from '@azure/storage-blob'
import type {TokenCredential} from '@azure/core-auth'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need a new dep just for this type? Would be great if this is not needed.

@sam-ayo sam-ayo Feb 24, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree in general to not need to add a new dependency only to get a type, but I believe it's necessary in this case to show that a user could use other credential authentication to connect to the storage account.


type Options = {
cache?: KvStore<Upload>
account: string
accountKey: string
containerName: string
accountKey?: string
credential?: TokenCredential

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's one or the other you should make this a discriminated union

}

const log = debug('tus-node-server:stores:azurestore')
Expand All @@ -44,22 +46,21 @@ export class AzureStore extends DataStore {
if (!options.account) {
throw new Error('Azure store must have a account')
}
if (!options.accountKey) {
throw new Error('Azure store must have a account key')
}
if (!options.containerName) {
throw new Error('Azure store must have a container name')
}
if (!options.accountKey && !options.credential) {
throw new Error('Azure store requires either accountKey or credential')
}

const storageAccountBaseUrl = `https://${options.account}.blob.core.windows.net`
const sharedKeyCredential = new StorageSharedKeyCredential(
options.account,
options.accountKey
)
const credential = options.credential
? options.credential
: new StorageSharedKeyCredential(options.account, options.accountKey!)

this.blobServiceClient = new BlobServiceClient(
storageAccountBaseUrl,
sharedKeyCredential
credential
)
this.containerClient = this.blobServiceClient.getContainerClient(
options.containerName
Expand Down