owebjs 1.0.2 → 1.0.4

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Oweb
2
2
 
3
- Flexible route handler that built on top of Fastify
3
+ Flexible handler that built on top of Fastify
4
4
 
5
5
  ## Installation
6
6
 
@@ -0,0 +1 @@
1
+ import{a as n}from"./chunk-2HA4XQFN.js";var h=n((c,o)=>{let t=Object.keys(c);for(let e=0,s=t.length;e<s;e++)o(c[t[e]],t[e])},"forEach");export{h as a};
@@ -0,0 +1 @@
1
+ import{a as h}from"./chunk-2D3NDWTU.js";import{a}from"./chunk-2HA4XQFN.js";import{Readable as d}from"stream";var r=class extends d{static{a(this,"HttpRequest")}req;res;url;method;statusCode;statusMessage;body;headers;socket;constructor(s){super();let t=s.getQuery();this.req=s,this.url=s.getUrl()+(t?"?"+t:""),this.method=s.getMethod().toUpperCase(),this.statusCode=null,this.statusMessage=null,this.body={},this.headers={},this.socket={},s.forEach((e,o)=>{this.headers[e]=o})}getRawHeaders(){let s=[];return h(this.headers,(t,e)=>{s.push(t,e)}),s}getRaw(){return this.req}_read(s){return this.slice(0,s)}};export{r as a};
@@ -0,0 +1 @@
1
+ import{a as s}from"./chunk-2HA4XQFN.js";var e=class{static{s(this,"HttpResponseSocket")}uResponse;constructor(r){this.uResponse=r}get remoteAddress(){return Buffer.from(this.uResponse.getRemoteAddressAsText()).toString()}destroy(){return this.uResponse.end()}};export{e as a};
@@ -0,0 +1 @@
1
+ import{a as o}from"./chunk-2HA4XQFN.js";var r=o(t=>t+"","toString"),e=o(t=>r(t).toLowerCase(),"toLowerCase");export{r as a,e as b};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-2WXLF7QU.js";import{a as p}from"./chunk-Z23QA6PX.js";import{a as u}from"./chunk-2HA4XQFN.js";import E from"uWebSockets.js";import{EventEmitter as k}from"node:events";var q="request";function v({cert_file_name:d,key_file_name:h}){let m="App";d&&h&&(m="SSLApp");let c=u((i,n)=>{n.statusCode=404,n.statusMessage="Not Found",n.end()},"handler"),g={cert_file_name:d,key_file_name:h},o=E[m](g).any("/*",(i,n)=>{i.finished=!1;let e=new a(n),t=new p(i,o);e.res=t,t.req=e,e.socket=t.socket,e.method!=="HEAD"?i.onData((r,f)=>{let S=Buffer.from(r);return f?(e.push(S),e.push(null),i.finished?void 0:c(e,t)):e.push(S)}):i.finished||c(e,t)}),y=class extends k{static{u(this,"uServerClass")}constructor(){super();let n=this.on.bind(this),e=this.once.bind(this);this.once=function(t,s){return e(t,s)},this.on=function(t,s){if(t===q){c=s;return}return n(t,s)}}close(n){if(E.us_listen_socket_close(o._socket),!!n)return n()}start(n,e,t){let s,r=u(function(f){o._socket=f,t&&t(f)},"callbackFunction");return n&&e&&t&&(s=[n,e,r]),!t&&(!e||typeof e=="function")&&(t=e,e=n,s=[e,r]),o.listen(...s)}listen(n,e,t){if(typeof n=="object"){let s=n;return e=s.port,t=s.cb,n=s.host,this.start(n,e,r=>{o._socket=r,t&&t(r)})}else return(!e||typeof e=="function")&&!t?(t=e,e=n,this.start(e,t)):this.start(n,e,t)}get uwsApp(){return o}},l=new y;return l[Symbol("IncomingMessage")]=a,l[Symbol("ServerResponse")]=p,l}u(v,"default");export{v as a};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-7JAXN5IF.js";import{b as r}from"./chunk-ARAMBVQ3.js";import{a as i}from"./chunk-2HA4XQFN.js";import{Writable as d}from"stream";var h=class extends d{static{i(this,"HttpResponse")}res;req;server;statusCode;statusMessage;__headers;headersSent;socket;finished;constructor(e,s){super(),this.res=e,this.server=s,this.statusCode=200,this.statusMessage="OK",this.__headers={},this.headersSent=!1,this.socket=new a(e),this.res.onAborted(()=>{this.finished=this.res.finished=!0})}setHeader(e,s){this.__headers[r(e)]=s}getHeaderNames(){return Object.keys(this.__headers)}getHeaders(){return Object.assign({},this.__headers)}getHeader(e){return this.__headers[r(e)]}hasHeader(e){return!!this.__headers[r(e)]}removeHeader(e){delete this.__headers[r(e)]}write(e){this.finished||this.res.write(e)}writeHead(e){if(this.finished)return;this.statusCode=e;let s;arguments.length===2?s=arguments[1]:arguments.length===3?(this.statusMessage=arguments[1],s=arguments[2]):s={},Object.keys(s).forEach(t=>{this.setHeader(t,s[t])})}end(e){if(this.finished)return;function s(t){t.res.writeStatus(`${t.statusCode} ${t.statusMessage}`),t.finished=!0,t.res.end(e)}return i(s,"doWrite"),e?s(this):(e="",s(this))}getRaw(){return this.res}};export{h as a};
package/dist/index.d.ts CHANGED
@@ -1,15 +1,22 @@
1
- import { FastifyInstance as FastifyInstance$1 } from 'fastify';
1
+ import { FastifyServerOptions, FastifyListenOptions, FastifyInstance } from 'fastify';
2
2
 
3
- interface FastifyInstance extends FastifyInstance$1 {
3
+ interface OwebOptions extends FastifyServerOptions {
4
+ uWebSocketsEnabled?: boolean;
4
5
  }
5
- declare class FastifyInstance {
6
- constructor();
6
+ interface LoadRoutesOptions {
7
+ directory: string;
7
8
  }
8
- declare class Oweb extends FastifyInstance {
9
- constructor();
10
- loadRoutes({ routeDir }: {
11
- routeDir: any;
12
- }): Promise<void>;
9
+ interface _FastifyInstance extends FastifyInstance {
10
+ }
11
+ declare class _FastifyInstance {
12
+ }
13
+ declare class Oweb extends _FastifyInstance {
14
+ constructor(options?: OwebOptions);
15
+ loadRoutes({ directory }: LoadRoutesOptions): Promise<void>;
16
+ start(listenOptions?: FastifyListenOptions): Promise<{
17
+ err: Error;
18
+ address: string;
19
+ }>;
13
20
  }
14
21
 
15
- export { Oweb as default };
22
+ export { LoadRoutesOptions, OwebOptions, Oweb as default };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{b as o}from"./chunk-JSRKSHP6.js";import"./chunk-OR3GJT5E.js";import"./chunk-XR5MHIBF.js";import{a as s}from"./chunk-2HA4XQFN.js";import n from"fastify";var a=n(),c=class{static{s(this,"FastifyInstance")}constructor(){Object.assign(this,a)}},t=class extends c{static{s(this,"Oweb")}constructor(){super()}loadRoutes({routeDir:e}){return o(e,a)}};export{t as default};
1
+ import{a as i}from"./chunk-VLHAZXJ6.js";import{b as n}from"./chunk-JSRKSHP6.js";import"./chunk-OR3GJT5E.js";import"./chunk-XR5MHIBF.js";import"./chunk-2WXLF7QU.js";import"./chunk-2D3NDWTU.js";import"./chunk-Z23QA6PX.js";import"./chunk-7JAXN5IF.js";import"./chunk-ARAMBVQ3.js";import{a as r}from"./chunk-2HA4XQFN.js";import u from"fastify";var a=i({}),f=r((e,t)=>(a.on("request",e),a),"serverFactory"),m=class{static{r(this,"_FastifyInstance")}},o=class extends m{static{r(this,"Oweb")}constructor(t={}){super();let s=t??{};s.uWebSocketsEnabled&&(s.serverFactory=f),Object.assign(this,u(s))}loadRoutes({directory:t}){return n(t,this)}start(t={port:3e3,host:"127.0.0.1"}){return new Promise(s=>{this.listen({port:+t.port},(c,p)=>s({err:c,address:p}))})}};export{o as default};
@@ -0,0 +1 @@
1
+ import{a}from"../chunk-2WXLF7QU.js";import"../chunk-2D3NDWTU.js";import"../chunk-2HA4XQFN.js";export{a as default};
@@ -0,0 +1 @@
1
+ import{a}from"../chunk-Z23QA6PX.js";import"../chunk-7JAXN5IF.js";import"../chunk-ARAMBVQ3.js";import"../chunk-2HA4XQFN.js";export{a as default};
@@ -0,0 +1 @@
1
+ import{a}from"../chunk-7JAXN5IF.js";import"../chunk-2HA4XQFN.js";export{a as default};
@@ -0,0 +1 @@
1
+ import{a}from"../chunk-VLHAZXJ6.js";import"../chunk-2WXLF7QU.js";import"../chunk-2D3NDWTU.js";import"../chunk-Z23QA6PX.js";import"../chunk-7JAXN5IF.js";import"../chunk-ARAMBVQ3.js";import"../chunk-2HA4XQFN.js";export{a as default};
@@ -0,0 +1 @@
1
+ import{a}from"../../chunk-2D3NDWTU.js";import"../../chunk-2HA4XQFN.js";export{a as forEach};
@@ -0,0 +1 @@
1
+ import{a,b}from"../../chunk-ARAMBVQ3.js";import"../../chunk-2HA4XQFN.js";export{b as toLowerCase,a as toString};
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,32 +1,32 @@
1
- {
2
- "name": "owebjs",
3
- "version": "1.0.2",
4
- "description": "",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "scripts": {
8
- "start": "node .",
9
- "build": "tsup",
10
- "dev": "tsup && node .",
11
- "test": "tsup && node test/index.js",
12
- "format": "prettier --write . --ignore-path .gitignore"
13
- },
14
- "keywords": [],
15
- "author": "owebjs",
16
- "license": "MIT",
17
- "dependencies": {
18
- "fastify": "^4.23.2",
19
- "jose": "^4.14.6",
20
- "jsonwebtoken": "^9.0.2"
21
- },
22
- "devDependencies": {
23
- "@swc/core": "^1.3.85",
24
- "@types/jsonwebtoken": "^9.0.3",
25
- "@types/node": "^20.6.2",
26
- "prettier": "^3.0.3",
27
- "tslib": "^2.6.2",
28
- "tsup": "^7.2.0",
29
- "typescript": "^5.2.2"
30
- },
31
- "type": "module"
32
- }
1
+ {
2
+ "name": "owebjs",
3
+ "version": "1.0.4",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "start": "node .",
9
+ "build": "tsup",
10
+ "dev": "tsup && node .",
11
+ "test": "tsup && node scripts/copyBinaries && node test/index.js",
12
+ "format": "prettier --write . --ignore-path .gitignore"
13
+ },
14
+ "keywords": [],
15
+ "author": "owebjs",
16
+ "license": "MIT",
17
+ "dependencies": {
18
+ "fastify": "^4.23.2",
19
+ "jsonwebtoken": "^9.0.2"
20
+ },
21
+ "devDependencies": {
22
+ "@swc/core": "^1.3.85",
23
+ "@types/jsonwebtoken": "^9.0.3",
24
+ "@types/node": "^20.6.2",
25
+ "prettier": "^3.0.3",
26
+ "tslib": "^2.6.2",
27
+ "tsup": "^7.2.0",
28
+ "typescript": "^5.2.2",
29
+ "uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.10.0"
30
+ },
31
+ "type": "module"
32
+ }
@@ -0,0 +1,11 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+
4
+ for (const file of fs.readdirSync('node_modules/uWebSockets.js')) {
5
+ if (file.endsWith('.node')) {
6
+ fs.copyFileSync(
7
+ path.resolve('node_modules/uWebSockets.js/' + file),
8
+ path.resolve('dist/' + file),
9
+ );
10
+ }
11
+ }