Comparing version 0.0.3 to 0.0.4
@@ -1,2 +0,2 @@ | ||
import { Elysia } from 'elysia'; | ||
import Elysia from 'elysia'; | ||
export type Attribute = { | ||
@@ -21,6 +21,8 @@ ip?: string; | ||
}; | ||
export declare const logester: (logger?: typeof Logestic.defaultLogger) => Elysia; | ||
export declare class Logestic { | ||
private requestedAttrs; | ||
private logger; | ||
private static defaultLogger; | ||
instance: Elysia; | ||
static defaultLogger: (msg: string) => void; | ||
constructor(logger?: typeof Logestic.defaultLogger); | ||
@@ -27,0 +29,0 @@ use(attr: keyof Attribute): Logestic; |
// @bun | ||
import{Elysia as F} from"elysia";var G={common:{uses:["ip","method","path","status","contentLength"],format:({ip:w,method:$,path:k,status:v,contentLength:z})=>{return`${w} ${$} ${k} ${v} ${z}`}}};class x{requestedAttrs;logger;static defaultLogger=(w)=>{console.log(w)};constructor(w=x.defaultLogger){this.requestedAttrs={},this.logger=w}use(w){if(w instanceof Array){for(let $ of w)this.requestedAttrs[$]=!0;return this}return this.requestedAttrs[w]=!0,this}static preset(w,$=x.defaultLogger){const{uses:k,format:v}=G[w];return new x($).use(k).custom(v)}custom(w){return new F().onAfterHandle(({request:$,path:k,body:v,query:z,set:A})=>{let j={};for(let C in this.requestedAttrs)switch(C){case"ip":j.ip=$.headers.get("x-forwarded-for")||"<ip>";break;case"method":j.method=$.method;break;case"path":j.path=k;break;case"body":j.body=v;break;case"query":j.query=z;break;case"time":j.time=new Date;break;case"contentLength":j.contentLength=Number($.headers.get("content-length"));break;case"status":j.status=A.status;break;case"referer":j.referer=$.headers.get("referer")||"<referer>";break;case"userAgent":j.userAgent=$.headers.get("user-agent")||"<user-agent>";break}const B=w(j);this.logger(B)})}log(w){this.logger(w)}}export{x as Logestic}; | ||
import E from"elysia";var F={common:{uses:["ip","method","path","status","contentLength"],format:({ip:A,method:S,path:v,status:w,contentLength:x})=>{return`${A} ${S} ${v} ${w} ${x}`}}},I=(A=k.defaultLogger)=>{return new k(A).instance};class k{requestedAttrs;logger;instance;static defaultLogger=(A)=>{console.log(A)};constructor(A=k.defaultLogger){this.requestedAttrs={},this.logger=A,this.instance=new E({name:"logestic"})}use(A){if(A instanceof Array){for(let S of A)this.requestedAttrs[S]=!0;return this}return this.requestedAttrs[A]=!0,this}static preset(A,S=k.defaultLogger){const{uses:v,format:w}=F[A];return new k(S).use(v).custom(w)}custom(A){return this.instance=this.instance.onAfterHandle(({request:S,path:v,body:w,query:x,set:z})=>{let j={};for(let C in this.requestedAttrs)switch(C){case"ip":j.ip=S.headers.get("x-forwarded-for")||"<ip>";break;case"method":j.method=S.method;break;case"path":j.path=v;break;case"body":j.body=w;break;case"query":j.query=x;break;case"time":j.time=new Date;break;case"contentLength":j.contentLength=Number(S.headers.get("content-length"));break;case"status":j.status=z.status;break;case"referer":j.referer=S.headers.get("referer")||"<referer>";break;case"userAgent":j.userAgent=S.headers.get("user-agent")||"<user-agent>";break}const B=A(j);this.logger(B)}),this.instance}log(A){this.logger(A)}}export{I as logester,k as Logestic}; |
{ | ||
"name": "logestic", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "An advanced and customisable logging library for ElysiaJS", | ||
@@ -10,2 +10,8 @@ "main": "dist/index.js", | ||
], | ||
"exports": { | ||
"require": "./dist/index.js", | ||
"import": "./dist/index.js", | ||
"node": "./dist/index.js", | ||
"default": "./dist/index.js" | ||
}, | ||
"keywords": [ | ||
@@ -26,11 +32,10 @@ "logging", | ||
"type": "module", | ||
"dependencies": { | ||
"elysia": "0.8.17" | ||
}, | ||
"devDependencies": { | ||
"@elysiajs/eden": "0.8.1", | ||
"@types/bun": "latest" | ||
"typescript": "^5.0.0", | ||
"bun-types": "latest" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^5.0.0" | ||
"typescript": "^5.0.0", | ||
"elysia": "0.8.17" | ||
}, | ||
@@ -37,0 +42,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4916
41
3
- Removedelysia@0.8.17