Skip to content

Commit

Permalink
Merge pull request #3 from pskucherov/ps.setAppName
Browse files Browse the repository at this point in the history
Возможность задавать x-app-name
  • Loading branch information
mtvkand authored Apr 24, 2022
2 parents 714f4f5 + f7741cf commit 8532869
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { OrdersServiceDefinition, OrdersStreamServiceDefinition } from './genera
import { SandboxServiceDefinition } from './generated/sandbox';
import { responseMiddleware } from './middlewares/response';

export const createSdk = (token: string) => {
const metadata = createMetadata(token);
export const createSdk = (token: string, appName?: string) => {
const metadata = createMetadata(token, appName);
const metadataCred = createMetadataCredentials(metadata);
const sslCred = createSSLCredentials(metadataCred);

Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { CallCredentials, ChannelCredentials, credentials, Metadata } from '@grp
import { createChannel } from 'nice-grpc';
import { APP_NAME } from './constants';

export const createMetadata = (token: string): Metadata => {
export const createMetadata = (token: string, appName?: string): Metadata => {
const metadata = new Metadata();
metadata.add('Authorization', `Bearer ${token}`);
metadata.add('x-app-name', APP_NAME);
metadata.add('x-app-name', appName || APP_NAME);

return metadata;
};
Expand Down

0 comments on commit 8532869

Please sign in to comment.