@okam/directus-next
Advanced tools
Comparing version
export * from './draft'; | ||
export { directusRouteRouter } from './lib/directusRouteRouter'; | ||
export { getJsonErrorResponse } from './response'; |
13
index.js
@@ -1,1 +0,12 @@ | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("next/headers"),A=require("next/navigation"),D=require("radash");function h(s,n){const a={"Content-Type":"text/json; charset=UTF-8"},o=JSON.stringify(s);return new Response(o,{status:n,headers:a})}function P(){return process.env.NEXT_API_DRAFT_SECRET||""}function R(s){const{searchParams:n}=new URL(s),a=n.get("secret")||"",o=n.get("languages"),u=n.get("urls"),e=n.get("routes"),f=n.get("pk"),t=n.get("version"),c={secret:"",languages:[],paths:[],routes:[],type:"",pk:"",version:""};if(!a||!o||!(u||e))return c;const i=typeof f=="string"?f:"",r=typeof t=="string"?t:"";try{const l=JSON.parse(o);if(e){const d=JSON.parse(e);return{secret:a,languages:l,paths:[],routes:d,type:"route",pk:i,version:r}}if(!u)return c;const m=JSON.parse(u);return{secret:a,languages:l,paths:m,routes:[],type:"path",pk:i,version:r}}catch{return c}}function S(s,n,a=0){const{searchParams:o}=new URL(n),u=[...s.matchAll(/\{\{([a-z]+)\}\}/gi)],e={};return u.forEach(f=>{const t=f[1]||"";if(!t)return;const c=`${t}s`,i=o.get(c);if(i)try{const r=JSON.parse(i);e[t]=r[a]||""}catch{e[t]=""}else{const r=o.get(t);e[t]=r||""}}),D.template(s,e)}function J({url:s,getDirectusLanguage:n,getDraftSecret:a,getJsonError:o}){const u=a||P,e=o||h,{secret:f,languages:t,paths:c,routes:i,type:r,version:l}=R(s);if(f!==u())return e({error:"Invalid argument"},401);if(r==="")return e({error:"Invalid argument"},400);if(!Array.isArray(t)||t.length<=0)return e({error:"Invalid languages argument"},400);if(r==="path"&&(!Array.isArray(c)||c.length<=0))return e({error:"Invalid paths argument"},400);if(r==="route"&&(!Array.isArray(i)||i.length<=0))return e({error:"Invalid routes argument"},400);const m=n(),d=t.indexOf(m),y=d!==-1?d:0;let g="";if(r==="path"){const p=c[y]||"";if(!p)return h({error:"Invalid path"},400);g=p}else if(r==="route"){const p=i[y]||"";if(!p)return h({error:"Invalid route"},400);const v=S(p,s,y);if(!v)return h({error:"Invalid route"},400);g=v}if(g&&l){const p=g.indexOf("?")!==-1;g=`${g}${p?"&":"?"}version=${encodeURIComponent(l)}`}I.draftMode().enable(),A.redirect(g)}exports.getDraftSecretDefault=P;exports.getJsonErrorResponse=h;exports.getPathFromRoute=S;exports.handleDraftRoute=J;exports.parseParams=R; | ||
"use strict"; | ||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); | ||
const route = require("./draft/route.js"); | ||
const env = require("./draft/env.js"); | ||
const directusRouteRouter = require("./lib/directusRouteRouter.js"); | ||
const response = require("./response.js"); | ||
exports.getPathFromRoute = route.getPathFromRoute; | ||
exports.handleDraftRoute = route.default; | ||
exports.parseParams = route.parseParams; | ||
exports.getDraftSecretDefault = env.getDraftSecretDefault; | ||
exports.directusRouteRouter = directusRouteRouter.directusRouteRouter; | ||
exports.getJsonErrorResponse = response.getJsonErrorResponse; |
{ | ||
"name": "@okam/directus-next", | ||
"main": "./index.js", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"types": "./index.d.ts", | ||
@@ -10,7 +10,8 @@ "exports": { | ||
"require": "./index.js" | ||
}, | ||
"./server": { | ||
"import": "./server.mjs", | ||
"require": "./server.js" | ||
} | ||
}, | ||
"publishConfig": { | ||
"registry": "https://registry.npmjs.org" | ||
}, | ||
"repository": { | ||
@@ -17,0 +18,0 @@ "url": "https://github.com/OKAMca/stack.git" |
Sorry, the diff of this file is not supported yet
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
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
20964
169.6%21
162.5%622
230.85%2
-33.33%1
-66.67%3
50%