Skip to content

Commit

Permalink
Merge pull request #77 from AlexanderYW/fix/npm-publish-fix
Browse files Browse the repository at this point in the history
Corrected some issues with publishing to NPM
  • Loading branch information
AlexanderYW authored Oct 17, 2021
2 parents a29d8f4 + b7c32a4 commit 43b11e1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
11 changes: 7 additions & 4 deletions src/Drivers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
CannotDeleteFileException,
CannotGetMetaDataException,
CannotSetVisibilityException,
Exception,
} from '@adonisjs/core/build/standalone'

import {
Expand Down Expand Up @@ -36,6 +35,7 @@ import {
ContainerExistsOptions,
ContainerCreateResponse,
ContainerDeleteResponse,
BlockBlobClient,
} from '@azure/storage-blob'
import { ReadStream } from 'fs'
import {
Expand Down Expand Up @@ -89,7 +89,7 @@ export class AzureStorageDriver implements AzureStorageDriverContract {
}

public async generateBlobSASURL(
blockBlobClient: { containerName: any; location: any; credential: any; url: any },
blockBlobClient: BlockBlobClient,
options: BlobSASSignatureValues
): Promise<string> {
options.permissions =
Expand All @@ -100,15 +100,18 @@ export class AzureStorageDriver implements AzureStorageDriverContract {
options.startsOn = options.startsOn || new Date()
options.expiresOn = options.expiresOn || new Date(options.startsOn.valueOf() + 3600 * 1000)

const factories = (blockBlobClient as any).pipeline.factories
const credential = factories[factories.length - 1] as StorageSharedKeyCredential

const blobSAS = await generateBlobSASQueryParameters(
{
containerName: blockBlobClient.containerName, // Required
blobName: blockBlobClient.location, // Required
blobName: blockBlobClient.name, // Required
permissions: options.permissions, // Required
startsOn: options.startsOn,
expiresOn: options.expiresOn,
},
blockBlobClient.credential
credential
)

return `${blockBlobClient.url}?${blobSAS.toString()}`
Expand Down
12 changes: 9 additions & 3 deletions src/Drivers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { Exception } from '@adonisjs/core/build/standalone'
* Unable to create container
*/
export class CannotCreateContainerException extends Exception {
/* tslint:disable:no-unused-variable */
private containerName: string
/* tslint:disable:no-unused-variable */
private original: any
public static invoke(containerName: string, original: any) {
public static invoke(containerName: string, original: any): CannotCreateContainerException {
const error = new this(
`Cannot create container with name: "${containerName}"`,
500,
Expand All @@ -22,9 +24,11 @@ export class CannotCreateContainerException extends Exception {
* Unable to create container
*/
export class CannotFindContainerException extends Exception {
/* tslint:disable:no-unused-variable */
private containerName: string
/* tslint:disable:no-unused-variable */
private original: any
public static invoke(containerName: string, original: any) {
public static invoke(containerName: string, original: any): CannotFindContainerException {
const error = new this(
`Cannot find container with name: "${containerName}"`,
500,
Expand All @@ -40,9 +44,11 @@ export class CannotFindContainerException extends Exception {
* Unable to create container
*/
export class CannotDeleteContainerException extends Exception {
/* tslint:disable:no-unused-variable */
private containerName: string
/* tslint:disable:no-unused-variable */
private original: any
public static invoke(containerName: string, original: any) {
public static invoke(containerName: string, original: any): CannotDeleteContainerException {
const error = new this(
`Cannot delete container with name: "${containerName}"`,
500,
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "./node_modules/@adonisjs/mrm-preset/_tsconfig",
"compilerOptions": {
"types": ["@types/node", "@adonisjs/core"],
"noUnusedLocals": false,
"skipLibCheck": true
},
"exclude": [
Expand Down

0 comments on commit 43b11e1

Please sign in to comment.