@backlib/koa
Advanced tools
Comparing version 0.2.0 to 0.3.0-SNAPSHOT-02
@@ -1,1 +0,1 @@ | ||
export * from './koa'; | ||
export * from './base-router'; |
@@ -10,5 +10,5 @@ "use strict"; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./koa"), exports); | ||
__exportStar(require("./base-router"), exports); |
{ | ||
"name": "@backlib/koa", | ||
"version": "0.2.0", | ||
"version": "0.3.0-SNAPSHOT-02", | ||
"description": "Minimalist KOA utilities for backend web services", | ||
@@ -12,3 +12,3 @@ "main": "dist/index.js", | ||
"type": "git", | ||
"url": "https://github.com/briteboard/node-backlib.git" | ||
"url": "https://github.com/britesnow/node-backlib-koa.git" | ||
}, | ||
@@ -23,18 +23,24 @@ "scripts": { | ||
"dependencies": { | ||
"@koa/router": "^9.3.1", | ||
"@types/koa": "^2.11.3", | ||
"@types/koa__router": "^8.0.2", | ||
"fs-extra-plus": "^0.5.18", | ||
"@koa/router": "^10.0.0", | ||
"@types/koa": "^2.11.6", | ||
"@types/koa__router": "^8.0.3", | ||
"fs-extra-plus": "^0.5.20", | ||
"handlebars": "^4.7.6", | ||
"js-yaml": "^3.14.0", | ||
"koa": "^2.13.0", | ||
"koa-compose": "^4.1.0" | ||
"koa-compose": "^4.1.0", | ||
"markdown-it": "^12.0.2" | ||
}, | ||
"peerDependencies": { | ||
"backlib": "^0.2.0" | ||
"backlib": "^0.3.0" | ||
}, | ||
"devDependencies": { | ||
"@types/mocha": "^8.0.0", | ||
"mocha": "^8.0.1", | ||
"@types/js-yaml": "^3.12.5", | ||
"@types/markdown-it": "^10.0.3", | ||
"@types/mocha": "^8.0.4", | ||
"backlib": "^0.3.0", | ||
"mocha": "^8.2.1", | ||
"rimraf": "^3.0.2", | ||
"ts-node-dev": "^1.0.0-pre.51", | ||
"typescript": "^3.9.6" | ||
"ts-node-dev": "^1.0.0", | ||
"typescript": "^4.1.2" | ||
}, | ||
@@ -41,0 +47,0 @@ "files": [ |
Minimalist utilities for backend services. | ||
Minimalist koa utilities on top of backlib. | ||
@@ -10,75 +10,1 @@ - **Typed** Build with typescript for typescript. | ||
> NOTE: Still under development. If not part of BriteSnow, wait for 0.3.0 and above to use this library. In the meantime feel free to copy/paste code. | ||
## Log | ||
Provides a `BaseLog` class with a `LogWriter` driver architecture. | ||
```ts | ||
import {BaseLog, LogWriter} from 'backlib'; | ||
interface WebLogRecord { | ||
... | ||
} | ||
class WebLog extends BaseLog<WebLogRecord>{ | ||
constructor() { | ||
const writers: LogWriter<WebLogRecord>[] = []; | ||
const baseName = 'web_log'; | ||
// Add custom writer using redstream (Redis Stream) for realtime login | ||
const logStream = getWebLogStream(); // not provided | ||
writers.push({ | ||
name: baseName + '_stream', | ||
writeRec: async (rec: WebLogRecord) => { | ||
await logStream.xadd(rec); | ||
} | ||
}); | ||
super({ writers }); | ||
} | ||
} | ||
const _webLog = new WebLog(); // must be after ServiceLog definition | ||
export webLog(rec: WebLogRecord){ | ||
_webLog.log(rec); | ||
} | ||
``` | ||
## isTop | ||
Know if a decorator method is at the `leaf` of the class tree. Usefull when want to apply logic one one per method name. | ||
```ts | ||
// One per decorator | ||
const leafTracer = newLeafTracer(); | ||
export function MethodDec() { | ||
return function (target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>) { | ||
// original method | ||
const method = descriptor.value!; | ||
descriptor.value = async function methodDecWrapper() { | ||
// must be called on each invocation (because of order of Decoration eval at init time). | ||
// However, flag is cache, so fast check. | ||
const isLeaf = leafTracer.trace(this.constructor, target.constructor, propertyKey); | ||
if (isLeaf){ | ||
// here logic to be apply only for the top most method for a given name for this class inheritance tree | ||
} | ||
const result = method.apply(this,arguments);// exec and get result | ||
if (isLeaf){ | ||
// eventual logic post execution | ||
} | ||
return result; | ||
} | ||
} | ||
} | ||
``` |
@@ -1,2 +0,2 @@ | ||
export * from './koa'; | ||
export * from './base-router'; | ||
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
18194
10
8
10
1
+ Addedhandlebars@^4.7.6
+ Addedjs-yaml@^3.14.0
+ Addedmarkdown-it@^12.0.2
+ Added@koa/router@10.1.1(transitive)
+ Addedargparse@1.0.102.0.1(transitive)
+ Addedbacklib@0.3.3(transitive)
+ Addedentities@2.1.0(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedhandlebars@4.7.8(transitive)
+ Addedjs-yaml@3.14.1(transitive)
+ Addedlinkify-it@3.0.3(transitive)
+ Addedmarkdown-it@12.3.2(transitive)
+ Addedmdurl@1.0.1(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedneo-async@2.6.2(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsprintf-js@1.0.3(transitive)
+ Addeduc.micro@1.0.6(transitive)
+ Addeduglify-js@3.19.3(transitive)
+ Addedwordwrap@1.0.0(transitive)
- Removed@koa/router@9.4.0(transitive)
- Removedat-least-node@1.0.0(transitive)
- Removedbacklib@0.2.1(transitive)
- Removedfs-extra@9.1.0(transitive)
Updated@koa/router@^10.0.0
Updated@types/koa@^2.11.6
Updated@types/koa__router@^8.0.3
Updatedfs-extra-plus@^0.5.20