2 Commits

Author SHA1 Message Date
adfbd5f8a3 adding optional auth to guard 2024-09-24 08:48:10 -05:00
72683c9ae2 adding optional auth to guard 2024-09-24 08:47:52 -05:00
2 changed files with 5 additions and 3 deletions

View File

@@ -1,3 +1,4 @@
export interface TableOptions { export interface TableOptions {
connectionString; accountName: string;
accountKey: string;
} }

View File

@@ -1,7 +1,7 @@
import { Inject, Injectable } from '@nestjs/common'; import { Inject, Injectable } from '@nestjs/common';
import { TableOptions } from './az-table.interface'; import { TableOptions } from './az-table.interface';
import { TABLE_OPTIONS } from './az-table.constants'; import { TABLE_OPTIONS } from './az-table.constants';
import { TableClient } from '@azure/data-tables'; import { TableClient, AzureNamedKeyCredential } from '@azure/data-tables';
@Injectable() @Injectable()
export class TableService { export class TableService {
@@ -11,7 +11,8 @@ export class TableService {
) {} ) {}
async getTableClient(tableName: string): Promise<TableClient> { async getTableClient(tableName: string): Promise<TableClient> {
const tableClient: TableClient = new TableClient(this.tablesOptions.connectionString, tableName); const credential: AzureNamedKeyCredential = new AzureNamedKeyCredential(this.tablesOptions.accountName, this.tablesOptions.accountKey);
const tableClient: TableClient = new TableClient(`https://${this.tablesOptions.accountName}.table.core.windows.net`, tableName, credential);
return tableClient; return tableClient;
} }