Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vite-plugin-api-routes

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-api-routes - npm Package Compare versions

Comparing version 1.1.3-beta to 1.1.4-beta

6

dist/index.js

@@ -1,2 +0,2 @@

var U=Object.defineProperty;var $=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable;var j=(r,e,o)=>e in r?U(r,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[e]=o,A=(r,e)=>{for(var o in e||(e={}))W.call(e,o)&&j(r,o,e[o]);if($)for(var o of $(e))N.call(e,o)&&j(r,o,e[o]);return r};import a from"slash-path";import I from"slash-path";import{build as ee}from"vite";import Z from"fs";import z from"fs";var w=(r,e)=>{let{configureFile:o,cacheDir:t}=r;if(!o.startsWith(t))return!1;let s=`
var U=Object.defineProperty;var F=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable;var j=(r,e,o)=>e in r?U(r,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[e]=o,A=(r,e)=>{for(var o in e||(e={}))W.call(e,o)&&j(r,o,e[o]);if(F)for(var o of F(e))N.call(e,o)&&j(r,o,e[o]);return r};import a from"slash-path";import I from"slash-path";import{build as ee}from"vite";import Z from"fs";import z from"fs";var w=(r,e)=>{let{configureFile:o,cacheDir:t}=r;if(!o.startsWith(t))return!1;let s=`
import express from "express";

@@ -89,3 +89,3 @@

cb : ${i.cb},
}`,l=u.map(i=>`import * as ${i.name} from "/${i.file}";`).join(`
}`,l=u.map(i=>`import * as ${i.name} from "${o}/root/${i.file}";`).join(`
`),p=c.map(i=>n(i)).join(`,

@@ -163,2 +163,2 @@ `),m=`

}
`;Q.writeFileSync(t,s)};var y=(r,e)=>{Z.mkdirSync(r.cacheDir,{recursive:!0}),w(r,e),B(r,e),k(r,e),H(r,e),b(r,e)},b=(r,e)=>{E(r,e)};var T=r=>{let e=t=>(t=I.slash(t),r.watcherList.find(s=>t.startsWith(s))),o={};return{name:"vite-plugin-rest-api",enforce:"pre",config:()=>({resolve:{alias:{[`${r.moduleId}/server`]:r.serverFile,[`${r.moduleId}/handler`]:r.handlerFile,[`${r.moduleId}/routers`]:r.routersFile,[`${r.moduleId}/configure`]:r.configureFile}}}),configResolved:t=>{o=t,y(r,o)},handleHotUpdate:async t=>{if(e(t.file))return[]},configureServer:async t=>{var f,h;let{watcher:s,middlewares:u,ssrLoadModule:c,ssrFixStacktrace:n,restart:l}=t,p=g=>{e(g)&&(b(r,o),s.off("add",p),s.off("change",p),l(!0))};s.on("add",p),s.on("change",p);let m=I.join(o.base,r.routeBase),i=await c(r.configure,{fixStacktrace:!0});(f=i.viteServerBefore)==null||f.call(i,t.middlewares,t,o),u.use(m,async(g,C,v)=>{try{(await c(r.handler,{fixStacktrace:!0})).handler(g,C,v)}catch(x){n(x),process.exitCode=1,v(x)}}),(h=i.viteServerAfter)==null||h.call(i,t.middlewares,t,o)},writeBundle:async()=>{var m,i;if(process.env.IS_API_BUILD)return;y(r,o),process.env.IS_API_BUILD="true";let{root:t,outDir:s,minify:u,preBuild:c,routeBase:n}=r,l=I.relative(s,o.build.outDir),p=await c({root:t,mode:o.mode,publicDir:"private",define:{"import.meta.env.PUBLIC_DIR":l,"import.meta.env.BASE":o.base,"import.meta.env.BASE_API":I.join(o.base,n)},build:{outDir:s,ssr:!0,minify:u,target:"es2020",assetsDir:"",emptyOutDir:!0,rollupOptions:{input:{app:r.server},external:(i=(m=o.build)==null?void 0:m.rollupOptions)==null?void 0:i.external,output:{format:"es"},onwarn:(f,h)=>{f.code==="MISSING_EXPORT"&&f.id.startsWith(r.cacheDir)||h(f)}}}});await ee(p)}}};var F=(r={})=>{let{moduleId:e="@api",cacheDir:o=".api",root:t=process.cwd(),server:s=a.join(o,"server.js"),handler:u=a.join(o,"handler.js"),configure:c=a.join(o,"configure.js"),routeBase:n="api",dirs:l=[{dir:"src/api",route:"",exclude:[]}],include:p=["**/*.ts","**/*.js"],exclude:m=[],mapper:i={},outDir:f="dist/server",minify:h=!0,preBuild:g=d=>d}=r;l=l.map(d=>(d.dir=a.join(t,d.dir),d)),i=A({default:"use",GET:"get",PUT:"put",POST:"post",PATCH:"patch",DELETE:"delete"},i),n=a.join("/",n),f=a.join(t,f),o=a.join(t,o);let C=a.join(t,s),v=a.join(t,u),x=a.join(o,"routers.js"),L=a.join(o,"types.d.ts"),_=a.join(t,c),M=Object.entries(i).filter(d=>d[1]).map(([d,O])=>({name:d,method:O})),P=l.map(d=>d.dir);return P.push(o),P.push(C),P.push(v),T({moduleId:e,server:s,handler:u,configure:c,root:t,serverFile:C,handlerFile:v,routersFile:x,typesFile:L,configureFile:_,routeBase:n,dirs:l,include:p,exclude:m,mapper:i,mapperList:M,watcherList:P,outDir:f,cacheDir:o,minify:h,preBuild:g})},De=F,Ee=F,ke=F;export{Ee as createAPI,ke as default,De as pluginAPI,F as pluginAPIRoutes};
`;Q.writeFileSync(t,s)};var y=(r,e)=>{Z.mkdirSync(r.cacheDir,{recursive:!0}),w(r,e),B(r,e),k(r,e),H(r,e),$(r,e)},$=(r,e)=>{E(r,e)};var T=r=>{let e=t=>(t=I.slash(t),r.watcherList.find(s=>t.startsWith(s))),o={};return{name:"vite-plugin-rest-api",enforce:"pre",config:()=>({resolve:{alias:{[`${r.moduleId}/root`]:r.root,[`${r.moduleId}/server`]:r.serverFile,[`${r.moduleId}/handler`]:r.handlerFile,[`${r.moduleId}/routers`]:r.routersFile,[`${r.moduleId}/configure`]:r.configureFile}}}),configResolved:t=>{o=t,y(r,o)},handleHotUpdate:async t=>{if(e(t.file))return[]},configureServer:async t=>{var f,h;let{watcher:s,middlewares:u,ssrLoadModule:c,ssrFixStacktrace:n,restart:l}=t,p=g=>{e(g)&&($(r,o),s.off("add",p),s.off("change",p),l(!0))};s.on("add",p),s.on("change",p);let m=I.join(o.base,r.routeBase),i=await c(r.configure,{fixStacktrace:!0});(f=i.viteServerBefore)==null||f.call(i,t.middlewares,t,o),u.use(m,async(g,C,v)=>{try{(await c(r.handler,{fixStacktrace:!0})).handler(g,C,v)}catch(x){n(x),process.exitCode=1,v(x)}}),(h=i.viteServerAfter)==null||h.call(i,t.middlewares,t,o)},writeBundle:async()=>{var m,i;if(process.env.IS_API_BUILD)return;y(r,o),process.env.IS_API_BUILD="true";let{root:t,outDir:s,minify:u,preBuild:c,routeBase:n}=r,l=I.relative(s,o.build.outDir),p=await c({root:t,mode:o.mode,publicDir:"private",define:{"import.meta.env.PUBLIC_DIR":l,"import.meta.env.BASE":o.base,"import.meta.env.BASE_API":I.join(o.base,n)},build:{outDir:s,ssr:!0,minify:u,target:"es2020",assetsDir:"",emptyOutDir:!0,rollupOptions:{input:{app:r.server},external:(i=(m=o.build)==null?void 0:m.rollupOptions)==null?void 0:i.external,output:{format:"es"},onwarn:(f,h)=>{f.code==="MISSING_EXPORT"&&f.id.startsWith(r.cacheDir)||h(f)}}}});await ee(p)}}};var b=(r={})=>{let{moduleId:e="@api",cacheDir:o=".api",root:t=process.cwd(),server:s=a.join(o,"server.js"),handler:u=a.join(o,"handler.js"),configure:c=a.join(o,"configure.js"),routeBase:n="api",dirs:l=[{dir:"src/api",route:"",exclude:[]}],include:p=["**/*.ts","**/*.js"],exclude:m=[],mapper:i={},outDir:f="dist/server",minify:h=!0,preBuild:g=d=>d}=r;l=l.map(d=>(d.dir=a.join(t,d.dir),d)),i=A({default:"use",GET:"get",PUT:"put",POST:"post",PATCH:"patch",DELETE:"delete"},i),n=a.join("/",n),f=a.join(t,f),o=a.join(t,o);let C=a.join(t,s),v=a.join(t,u),x=a.join(o,"routers.js"),L=a.join(o,"types.d.ts"),_=a.join(t,c),M=Object.entries(i).filter(d=>d[1]).map(([d,O])=>({name:d,method:O})),P=l.map(d=>d.dir);return P.push(o),P.push(C),P.push(v),T({moduleId:e,server:s,handler:u,configure:c,root:t,serverFile:C,handlerFile:v,routersFile:x,typesFile:L,configureFile:_,routeBase:n,dirs:l,include:p,exclude:m,mapper:i,mapperList:M,watcherList:P,outDir:f,cacheDir:o,minify:h,preBuild:g})},De=b,Ee=b,ke=b;export{Ee as createAPI,ke as default,De as pluginAPI,b as pluginAPIRoutes};
{
"name": "vite-plugin-api-routes",
"version": "1.1.3-beta",
"version": "1.1.4-beta",
"type": "module",

@@ -5,0 +5,0 @@ "description": "A Vite.js plugin that creates API routes by mapping the directory structure, similar to Next.js API Routes. This plugin enhances the functionality for backend development using Vite.",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc