owebjs 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-FRG47WHC.js +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +1 -1
- package/dist/utils/assignRoutes.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-JSRKSHP6.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as d}from"./chunk-OR3GJT5E.js";import{d as u,e as m}from"./chunk-XR5MHIBF.js";import{a}from"./chunk-2HA4XQFN.js";import p from"node:path";import{dirname as R}from"node:path";import{fileURLToPath as E}from"node:url";var g=R(E(import.meta.url)),_=a(async l=>{let r=[];for(let s of l){let f=p.parse(s.rel),t=s.filePath.replaceAll("\\","/"),i=new URL(p.resolve(t),`file://${g}`).pathname.replaceAll("\\","/"),c=u(f),o=m(c),e=(await import(i)).default;r.push({url:o.url,method:o.method,fn:e,fileInfo:s})}return r},"generateRoutes"),w=a(async(l,r)=>{let s=await d(l),f=await _(s);for(let t of f)r[t.method](t.url,function(i,c){let o=new t.fn(...arguments),h=a(()=>{if(o.handle.constructor.name=="AsyncFunction")o.handle(...arguments).catch(e=>{let n=[...arguments,e];o?.handleError?o.handleError(...n):r._options.OWEB_INTERNAL_ERROR_HANDLER(...n)});else try{o.handle(...arguments)}catch(e){let n=[...arguments,e];o?.handleError?o.handleError(...n):r._options.OWEB_INTERNAL_ERROR_HANDLER(...n)}},"handle");if(t.fileInfo.hooks.length)for(let e=0;e<t.fileInfo.hooks.length;e++){let n=t.fileInfo.hooks[e];new n().handle(i,c,()=>{e+1==t.fileInfo.hooks.length&&h()})}else h()})},"assignRoutes");export{_ as a,w as b};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { FastifyServerOptions, FastifyListenOptions, FastifyInstance } from 'fastify';
|
|
1
|
+
import { FastifyServerOptions, FastifyRequest, FastifyReply, FastifyListenOptions, FastifyInstance } from 'fastify';
|
|
2
2
|
|
|
3
3
|
interface OwebOptions extends FastifyServerOptions {
|
|
4
4
|
uWebSocketsEnabled?: boolean;
|
|
5
|
+
OWEB_INTERNAL_ERROR_HANDLER?: Function;
|
|
5
6
|
}
|
|
6
7
|
interface LoadRoutesOptions {
|
|
7
8
|
directory: string;
|
|
@@ -11,14 +12,15 @@ interface _FastifyInstance extends FastifyInstance {
|
|
|
11
12
|
declare class _FastifyInstance {
|
|
12
13
|
}
|
|
13
14
|
declare class Oweb extends _FastifyInstance {
|
|
14
|
-
|
|
15
|
+
_options: OwebOptions;
|
|
15
16
|
constructor(options?: OwebOptions);
|
|
16
17
|
setup(): Promise<unknown>;
|
|
17
18
|
loadRoutes({ directory }: LoadRoutesOptions): Promise<void>;
|
|
19
|
+
setInternalErrorHandler(errorHandlerCallback: (request: FastifyRequest, reply: FastifyReply, error: Error) => void): void;
|
|
18
20
|
start(listenOptions?: FastifyListenOptions): Promise<{
|
|
19
21
|
err: Error;
|
|
20
22
|
address: string;
|
|
21
23
|
}>;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
export { LoadRoutesOptions, OwebOptions, Oweb as default };
|
|
26
|
+
export { LoadRoutesOptions, Oweb, OwebOptions, Oweb as default };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{b as a}from"./chunk-FRG47WHC.js";import"./chunk-OR3GJT5E.js";import"./chunk-XR5MHIBF.js";import{a as r}from"./chunk-2HA4XQFN.js";import p from"fastify";var _=class{static{r(this,"_FastifyInstance")}},n=class extends _{static{r(this,"Oweb")}_options={};constructor(t={}){super();let s=t??{};this._options=s,this._options.OWEB_INTERNAL_ERROR_HANDLER=(e,o,i)=>o.status(500).send({error:i.message})}async setup(){return new Promise(async t=>{if(this._options.uWebSocketsEnabled){let s=(await import("./uwebsocket/server.js")).default,e=await s({});this._options.serverFactory=(o,i)=>(e.on("request",o),e),Object.assign(this,p(this._options)),t(!0)}else Object.assign(this,p(this._options)),t(!0)})}loadRoutes({directory:t}){return a(t,this)}setInternalErrorHandler(t){this._options.OWEB_INTERNAL_ERROR_HANDLER=t}start(t={port:3e3,host:"127.0.0.1"}){return new Promise(s=>{this.listen({port:+t.port},(e,o)=>s({err:e,address:o}))})}};export{n as Oweb,n as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b}from"../chunk-
|
|
1
|
+
import{a,b}from"../chunk-FRG47WHC.js";import"../chunk-OR3GJT5E.js";import"../chunk-XR5MHIBF.js";import"../chunk-2HA4XQFN.js";export{b as assignRoutes,a as generateRoutes};
|
package/package.json
CHANGED
package/dist/chunk-JSRKSHP6.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as h}from"./chunk-OR3GJT5E.js";import{d as u,e as m}from"./chunk-XR5MHIBF.js";import{a as i}from"./chunk-2HA4XQFN.js";import c from"node:path";import{dirname as p}from"node:path";import{fileURLToPath as d}from"node:url";var g=p(d(import.meta.url)),w=i(async r=>{let n=[];for(let t of r){let s=c.parse(t.rel),e=t.filePath.replaceAll("\\","/"),a=new URL(c.resolve(e),`file://${g}`).pathname.replaceAll("\\","/"),l=u(s),o=m(l),f=await import(a);n.push({url:o.url,method:o.method,fn:f?.default,fileInfo:t})}return n},"generateRoutes"),U=i(async(r,n)=>{let t=await h(r),s=await w(t);for(let e of s)n[e.method](e.url,function(a,l){if(e.fileInfo.hooks.length)for(let o=0;o<e.fileInfo.hooks.length;o++){let f=e.fileInfo.hooks[o];new f().handle(a,l,()=>{o+1==e.fileInfo.hooks.length&&new e.fn(...arguments).handle(...arguments)})}else new e.fn(...arguments).handle(...arguments)})},"assignRoutes");export{w as a,U as b};
|