owebjs 1.0.0 → 1.0.2
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 +13 -0
- package/dist/chunk-2HA4XQFN.js +1 -0
- package/dist/chunk-JSRKSHP6.js +1 -0
- package/dist/chunk-OR3GJT5E.js +1 -0
- package/dist/chunk-XR5MHIBF.js +1 -0
- package/dist/helpers/JwtAuth.js +1 -0
- package/dist/helpers/PluginRegistrar.js +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +1 -0
- package/dist/utils/assignRoutes.js +1 -0
- package/dist/utils/utils.js +1 -0
- package/dist/utils/walk.js +1 -0
- package/package.json +32 -11
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Oweb
|
|
2
|
+
|
|
3
|
+
Flexible route handler that built on top of Fastify
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
npm i owebjs
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
This package is still WIP. However, if you want to check out the usage head over to [test directory](https://github.com/owebjs/oweb/tree/main/test)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c=Object.defineProperty;var d=(a,b)=>c(a,"name",{value:b,configurable:!0});export{d as a};
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as c}from"./chunk-XR5MHIBF.js";import{a as l}from"./chunk-2HA4XQFN.js";import{readdirSync as k,statSync as _}from"node:fs";import a from"node:path";import{fileURLToPath as d}from"node:url";var S=a.dirname(d(import.meta.url)),v=l((s,r)=>{if(r.startsWith(s)){let e=a.relative(s,r);return e.split(a.sep).length>2||e==""||e.length>0}return!1},"isParentOrGrandparent"),p=new Set,P=l(async(s,r=[])=>{let e=[],i=k(s);i.sort((t,o)=>t.startsWith("_")&&!o.startsWith("_")?-1:!t.startsWith("_")&&o.startsWith("_")?1:t.localeCompare(o));for(let t of i){let o=a.join(s,t),h=a.resolve(s);if(t=="_hooks.js"||t=="_hooks.ts"){p.add(h);continue}if(_(o).isDirectory())e.push(...await P(o,[...r,t]));else{let u=[...p].filter(n=>v(n,h)).map(n=>new URL(n,`file://${S}`).pathname.replaceAll("\\","/")+"/_hooks.js"),f=[];for(let n of u){let m=await import(n);m?.default&&f.push(m.default)}e.push({name:t,path:s,hooks:f,rel:c(...r,t),filePath:o})}}return e},"walk");export{P as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as n}from"./chunk-2HA4XQFN.js";var a=n((...t)=>"/"+t.map(e=>e.replace(/^\/|\/$/g,"")).filter(e=>e!=="").join("/"),"mergePaths"),c=/\[([^}]*)\]/g,i=n(t=>c.test(t)?t.replace(c,(e,o)=>`:${o}`):t,"transformBrackets"),m=n(t=>{let e=[];for(let o of t.split("/"))e.push(i(o));return a(...e)},"convertParamSyntax"),h=n(t=>t.replace(/:\.\.\.\w+/g,"*"),"convertCatchallSyntax"),l=n(t=>{let e=t.dir===t.root?"":t.dir,o=t.name.startsWith("index")?t.name.replace("index",""):`/${t.name}`;return e+o},"buildRoutePath"),u=n(t=>{let e="get",o=m(t),r=h(o);for(let s of[".DELETE",".POST",".PATCH",".GET",".PUT"])if(t.endsWith(s)||t.endsWith(s.toLowerCase())){e=s.toLowerCase().slice(1),r=r.slice(0,r.length-s.length);break}return{url:r,method:e}},"buildRouteURL");export{a,m as b,h as c,l as d,u as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"../chunk-2HA4XQFN.js";import a from"jsonwebtoken";var f=e(({secret:r,onError:i})=>function(n){return class extends n{static{e(this,"JWT")}constructor(o,s){super();let t=o?.headers?.authorization;if(t&&(t=t.trim(),t=t.slice(Math.max(t.lastIndexOf(" "),0))),r)try{this.jwtResult=a.verify(t,r)}catch{i&&i(o,s)}else throw new Error("JWT Secret not provided!")}}},"JwtAuth");export{f as JwtAuth};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as s}from"../chunk-2HA4XQFN.js";var r=s((e,t)=>t(e),"creator"),c=class{static{s(this,"BaseRequest")}constructor(){}},a=s((...e)=>e.reduce(r,c),"register");export{a as register};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FastifyInstance as FastifyInstance$1 } from 'fastify';
|
|
2
|
+
|
|
3
|
+
interface FastifyInstance extends FastifyInstance$1 {
|
|
4
|
+
}
|
|
5
|
+
declare class FastifyInstance {
|
|
6
|
+
constructor();
|
|
7
|
+
}
|
|
8
|
+
declare class Oweb extends FastifyInstance {
|
|
9
|
+
constructor();
|
|
10
|
+
loadRoutes({ routeDir }: {
|
|
11
|
+
routeDir: any;
|
|
12
|
+
}): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { Oweb as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"../chunk-JSRKSHP6.js";import"../chunk-OR3GJT5E.js";import"../chunk-XR5MHIBF.js";import"../chunk-2HA4XQFN.js";export{b as assignRoutes,a as generateRoutes};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e}from"../chunk-XR5MHIBF.js";import"../chunk-2HA4XQFN.js";export{d as buildRoutePath,e as buildRouteURL,c as convertCatchallSyntax,b as convertParamSyntax,a as mergePaths};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../chunk-OR3GJT5E.js";import"../chunk-XR5MHIBF.js";import"../chunk-2HA4XQFN.js";export{a as walk};
|
package/package.json
CHANGED
|
@@ -1,11 +1,32 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
}
|