@kustomer/apps-server-sdk
Advanced tools
Comparing version 0.0.42 to 0.0.43
import { AxiosInstance, AxiosRequestConfig } from 'axios'; | ||
import { ENVS } from '../constants'; | ||
import { Logger } from '../logger'; | ||
import { KLogger } from '../logger'; | ||
export interface APIBaseOptions { | ||
@@ -10,2 +10,3 @@ readonly app: string; | ||
readonly token?: string; | ||
readonly logger?: KLogger; | ||
} | ||
@@ -18,3 +19,3 @@ export declare class APIBase { | ||
readonly axios: AxiosInstance; | ||
readonly _log: Logger; | ||
readonly _log: KLogger; | ||
protected get baseUrls(): { | ||
@@ -21,0 +22,0 @@ gateway: string; |
@@ -33,3 +33,5 @@ "use strict"; | ||
this.options = options; | ||
this._log = new logger_1.Logger(`kapp:${this.options.app}:${this.name}`); | ||
this._log = | ||
this.options.logger || | ||
new logger_1.Logger(`kapp:${this.options.app}:${this.name}`); | ||
this.axios = axios_1.default.create(); | ||
@@ -36,0 +38,0 @@ this.axios.interceptors.request.use(this._onRequest.bind(this)); |
@@ -9,2 +9,3 @@ export * from './kapp'; | ||
export * from './testing'; | ||
export * from './logger'; | ||
export * as ROLES from './constants/roles'; |
@@ -38,3 +38,4 @@ "use strict"; | ||
__exportStar(require("./testing"), exports); | ||
__exportStar(require("./logger"), exports); | ||
exports.ROLES = __importStar(require("./constants/roles")); | ||
//# sourceMappingURL=index.js.map |
import express from 'express'; | ||
import { AppOptions, KStartOptions } from './options'; | ||
import { KAppOptions, KStartOptions } from './options'; | ||
import { EventCallback, EventResources } from './event'; | ||
import { Logger } from './logger'; | ||
import { KLogger } from './logger'; | ||
import { Manifest } from './manifest'; | ||
@@ -12,3 +12,3 @@ import * as components from './components'; | ||
export declare class KApp<KAppSettings = any> { | ||
readonly options: AppOptions; | ||
readonly options: KAppOptions; | ||
/** | ||
@@ -36,3 +36,3 @@ * triggered when your app is installed | ||
*/ | ||
readonly log: Logger; | ||
readonly log: KLogger; | ||
/** | ||
@@ -76,3 +76,3 @@ * express app instance | ||
*/ | ||
constructor(options: AppOptions); | ||
constructor(options: KAppOptions); | ||
/** | ||
@@ -79,0 +79,0 @@ * start app server and publish new app version if necessary |
@@ -102,3 +102,3 @@ "use strict"; | ||
this.options = options; | ||
this.log = new logger_1.Logger(this.options.app); | ||
this.log = this.options.logger || new logger_1.Logger(this.options.app); | ||
this._token = jsonwebtoken_1.default.sign({ | ||
@@ -105,0 +105,0 @@ app: this.options.app, |
import debug from 'debug'; | ||
export interface KLogger { | ||
info: (...args: any[]) => void; | ||
warn: (...args: any[]) => void; | ||
error: (...args: any[]) => void; | ||
} | ||
/** | ||
@@ -6,3 +11,3 @@ * App Logger | ||
*/ | ||
export declare class Logger { | ||
export declare class Logger implements KLogger { | ||
readonly info: debug.Debugger; | ||
@@ -9,0 +14,0 @@ readonly warn: debug.Debugger; |
@@ -7,3 +7,4 @@ /// <reference types="node" /> | ||
import { Changelog, I18n, SettingsManifest } from './components'; | ||
export interface AppOptions { | ||
import { KLogger } from './logger'; | ||
export interface KAppOptions { | ||
/** The client id given to you on app registration */ | ||
@@ -89,7 +90,22 @@ clientId: string; | ||
i18n?: I18n; | ||
/** | ||
* Logger override that can be used via `app.log.(info | warn | error)` | ||
*/ | ||
logger?: KLogger; | ||
} | ||
export interface KStartOptions { | ||
/** | ||
* Port that your app will listen on | ||
* @default 80 | ||
*/ | ||
port?: number; | ||
/** | ||
* Should the app attempt to publish a version on startup? | ||
* @default true | ||
*/ | ||
publish?: boolean; | ||
/** | ||
* HTTP/HTTPS server options | ||
*/ | ||
serverOptions?: https.ServerOptions & http.ServerOptions; | ||
} |
/// <reference types="jest" /> | ||
import sinon from 'sinon'; | ||
import { KApp } from '../../kapp'; | ||
import { AppOptions } from '../../options'; | ||
import { KAppOptions } from '../../options'; | ||
import * as api from '../../api'; | ||
@@ -18,3 +18,3 @@ declare type APIStub = sinon.SinonStubbedInstance<api.Orgs & { | ||
private readonly _orgs; | ||
constructor(options?: Partial<AppOptions>); | ||
constructor(options?: Partial<KAppOptions>); | ||
start: jest.Mock<Promise<void>, []>; | ||
@@ -21,0 +21,0 @@ stop: jest.Mock<Promise<void>, []>; |
{ | ||
"name": "@kustomer/apps-server-sdk", | ||
"version": "0.0.42", | ||
"version": "0.0.43", | ||
"description": "Kustomer Server Side App SDK", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
185463
3520