Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: release #373

Merged
merged 5 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 2 additions & 3 deletions package-lock.json

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

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@restorecommerce/chassis-srv",
"version": "1.6.3",
"version": "1.6.5",
"description": "Restore Commerce microservice chassis",
"main": "./lib/index.js",
"author": "n-fuse GmbH",
Expand All @@ -17,7 +17,6 @@
],
"typings": "lib/index.d.ts",
"dependencies": {
"@grpc/grpc-js": "1.12.2",
"@restorecommerce/grpc-client": "2.2.5",
"@restorecommerce/kafka-client": "1.2.20",
"@restorecommerce/logger": "^1.3.1",
Expand Down
4 changes: 2 additions & 2 deletions src/command-interface/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ export class CommandInterface implements CommandInterfaceServiceImplementation {
* @returns Arbitrary JSON
*/
decodeMsg(msg: any): any {
return JSON.parse(Buffer.from(msg.value, 'base64').toString());
return JSON.parse(Buffer.from(msg.value).toString());
}

/**
Expand All @@ -748,7 +748,7 @@ export class CommandInterface implements CommandInterfaceServiceImplementation {
if (msg) {
return {
type_url: 'payload',
value: Buffer.from(JSON.stringify(msg)).toString('base64')
value: Buffer.from(JSON.stringify(msg))
};
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/microservice/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createLogger } from '@restorecommerce/logger';
import { Logger } from 'winston';
import * as _ from 'lodash';
import { EventEmitter } from 'events';
import { BindConfig, grpc } from './transport/provider/grpc';
import { BindConfig, grpcServer } from './transport/provider/grpc';

const transports: Record<string, any> = {};

Expand All @@ -17,7 +17,7 @@ export const registerTransport = (name: string, provider: any): void => {
};

// register included providers
registerTransport('grpc', grpc.Server);
registerTransport('grpc', grpcServer);

/**
* Initializes all configured transports.
Expand Down
9 changes: 2 additions & 7 deletions src/microservice/transport/provider/grpc/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as grpc from '@grpc/grpc-js';
import * as _ from 'lodash';
import { Logger } from 'winston';
import type { Server as GRPCServer, ServiceImplementation } from 'nice-grpc';
Expand Down Expand Up @@ -46,8 +45,6 @@ export class Server {
this.config = config;
this.logger = logger;

grpc.setLogger(console);

this.server = createServer()
.use(tracingMiddleware)
.use(metaMiddleware)
Expand All @@ -70,15 +67,13 @@ export class Server {
*/
async start(): Promise<void> {
if (!this.isBound) {
const credentials = grpc.ServerCredentials.createInsecure();
if (_.has(this.config, 'credentials.ssl')) {
// TODO Re-enable
// credentials = grpc.credentials.createSsl(
// this.config.credentials.ssl.certs);
}
await this.server.listen(
this.config.addr,
credentials
this.config.addr
).catch(err => {
this.logger.error('Error starting server', { message: err.message, code: err.code, stack: err.stack });
throw err;
Expand All @@ -95,4 +90,4 @@ export class Server {
}
}

export { grpc };
export { Server as grpcServer };
2 changes: 1 addition & 1 deletion test/cfg/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"logger": {
"console": {
"handleExceptions": false,
"level": "error",
"level": "silly",
"colorize": true,
"prettyPrint": true
}
Expand Down
11 changes: 4 additions & 7 deletions test/command.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import { createServiceConfig } from '@restorecommerce/service-config';
import { createLogger } from '@restorecommerce/logger';
import { createClient } from 'redis';
import {
CommandInterfaceServiceDefinition
} from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/commandinterface';
import {
CommandInterfaceServiceDefinition as CISServiceDefinition,
CommandInterfaceServiceDefinition,
CommandInterfaceServiceClient
} from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/commandinterface';
import {
Expand All @@ -26,7 +23,7 @@ import { Channel, createChannel } from 'nice-grpc';
* @returns Arbitrary JSON
*/
const decodeMsg = (msg: any): any => {
const decoded = Buffer.from(msg.value, 'base64').toString();
const decoded = Buffer.from(msg.value).toString();
return JSON.parse(decoded);
};

Expand All @@ -38,7 +35,7 @@ const decodeMsg = (msg: any): any => {
const encodeMsg = (msg: any): any => {

const stringified = JSON.stringify(msg);
const encoded = Buffer.from(stringified).toString('base64');
const encoded = Buffer.from(stringified);
const ret = {
type_url: 'payload',
value: encoded
Expand Down Expand Up @@ -110,7 +107,7 @@ describe('CommandInterfaceService', () => {
grpcClient = createGrpcClient({
...cfg.get('client:commandinterface'),
logger
}, CISServiceDefinition, channel);
}, CommandInterfaceServiceDefinition, channel);
});
after(async function teardown() {
this.timeout(30000);
Expand Down
Loading