From 4ee8dac5c54ce8a897382d3d4fb5bb852d24cf24 Mon Sep 17 00:00:00 2001 From: "S. Amir Mohammad Najafi" Date: Tue, 20 Dec 2022 13:52:28 +0330 Subject: [PATCH 1/4] feat(logger): move incident to deployment mode --- core/logger/src/logger.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/logger/src/logger.ts b/core/logger/src/logger.ts index f9306c2c8..b662a22db 100644 --- a/core/logger/src/logger.ts +++ b/core/logger/src/logger.ts @@ -126,10 +126,6 @@ export const createLogger = (scope: string, color?: string | null, debug?: boole color, scope, - incident: isBrowser - ? console.log.bind(console, '%c%s%c.%s() Incident `%s` %s!', styleScope, scope, 'color: orange;') - : console.log.bind(console, `${styleScope}🚸\n%s${style.reset}.%s() Incident \`%s\` %s!${style.reset}`, scope), - accident: isBrowser ? console.warn.bind(console, '%c%s%c.%s() Accident `%s` %s!', styleScope, scope, style.reset) : console.warn.bind(console, `${styleScope}⚠️\n%s\x1b[33m.%s() Accident \`%s\` %s!${style.reset}`, scope), @@ -147,6 +143,7 @@ export const createLogger = (scope: string, color?: string | null, debug?: boole logMethodArgs: empty, logMethodFull: empty, logOther: empty, + incident: empty, }; } @@ -163,5 +160,9 @@ export const createLogger = (scope: string, color?: string | null, debug?: boole logMethodFull: console.debug.bind(console, keySection + '.%s(%o) => %o', styleScope, scope, style.reset), logOther: console.debug.bind(console, keySection, styleScope, scope, style.reset), + + incident: isBrowser + ? console.log.bind(console, '%c%s%c.%s() Incident `%s` %s!', styleScope, scope, 'color: orange;') + : console.log.bind(console, `${styleScope}🚸\n%s${style.reset}.%s() Incident \`%s\` %s!${style.reset}`, scope), }; }; From a54c1a5a637a0c8c65f6df1f6205fc7a380c55a1 Mon Sep 17 00:00:00 2001 From: "S. Amir Mohammad Najafi" Date: Tue, 20 Dec 2022 13:52:48 +0330 Subject: [PATCH 2/4] docs(logger): incident and accident --- core/logger/src/type.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/logger/src/type.ts b/core/logger/src/type.ts index ed6aa7fa7..f2d8b6983 100644 --- a/core/logger/src/type.ts +++ b/core/logger/src/type.ts @@ -96,7 +96,8 @@ export interface AlwatrLogger { logMethodFull(method: string, args: Record | string | number | boolean, result: unknown): void; /** - * `console.log` an event or expected accident. (not warn or error) + * `console.log` an event or expected accident. + * not warn or error just important information. * * Example: * @@ -107,7 +108,7 @@ export interface AlwatrLogger { incident(method: string, code: string, desc: string, ...args: unknown[]): void; /** - * `console.warn` an unexpected accident or error that you handled. + * `console.warn` an unexpected accident or error that you handled like warning. * * Example: * From 753ef6e7d2dbd1dd1ffd7fe2feec73b4c556d465 Mon Sep 17 00:00:00 2001 From: "S. Amir Mohammad Najafi" Date: Tue, 20 Dec 2022 14:29:36 +0330 Subject: [PATCH 3/4] chrome(storage-client): fix spelling mistake --- core/storage-client/src/storage-client.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/storage-client/src/storage-client.ts b/core/storage-client/src/storage-client.ts index 102ef3032..e96e7fb2b 100644 --- a/core/storage-client/src/storage-client.ts +++ b/core/storage-client/src/storage-client.ts @@ -51,7 +51,7 @@ alwatrRegisteredList.push({ * * console.log('has \'alimd\': %o', await db.has('alimd')); * console.log('keys: %o', await db.keys()); - * console.log('getAll: %o', await db.getAll()); + * console.log('getStorage: %o', await db.getStorage()); * console.log('delete: %o', await db.delete('alimd')); * try { * await db.delete('abcd'); @@ -102,7 +102,7 @@ export class AlwatrStorageClient Date: Tue, 20 Dec 2022 14:30:37 +0330 Subject: [PATCH 4/4] fix(nano-server): check method on getBody --- core/nano-server/src/nano-server.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/nano-server/src/nano-server.ts b/core/nano-server/src/nano-server.ts index f58c8baab..782531f65 100644 --- a/core/nano-server/src/nano-server.ts +++ b/core/nano-server/src/nano-server.ts @@ -403,6 +403,11 @@ export class AlwatrConnection { * ``` */ async getBody(): Promise { + // method must be POST or PUT or PATCH + if (!(this.method === 'POST' || this.method === 'PUT' || this.method === 'PATCH')) { + return null; + } + let body = ''; this.incomingMessage.on('data', (chunk: unknown) => {