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.0-beta to 1.1.1-beta

5

package.json
{
"name": "vite-plugin-api-routes",
"version": "1.1.0-beta",
"version": "1.1.1-beta",
"type": "module",

@@ -38,2 +38,5 @@ "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.",

},
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {

@@ -40,0 +43,0 @@ ".": {

56

README.md

@@ -272,42 +272,38 @@ # vite-plugin-api-routes

```typescript
import { NextFunction, Request, Response, } from "express";
import express from "express";
import { CallbackHook, StatusHook, ServerHook, HandlerHook, ViteServerHook } from "vite-plugin-api-routes/model";
// WARNING: Please don't include the VITE TYPES here, because it has a problem when you build the project
const devServerBefore = (viteServer: any, vite: any): void => {
console.log("devServerBefore");
export const viteServerBefore: ViteServerHook = (server, viteServer) => {
console.log("VITEJS SERVER");
server.use(express.json());
server.use(express.urlencoded({ extended: true }));
};
const serverBefore = (server: Express) => {
console.log("serverBefore");
export const viteServerAfter: ViteServerHook = (server, viteServer) => {
};
const serverAfter = (server: Express) => {
console.log("serverAfter");
}
export const serverBefore: ServerHook = (server) => {
server.use(express.json());
server.use(express.urlencoded({ extended: true }));
};
const handlerBefore = (handler: Express) => {
handler.use(express.json());
handler.use(express.urlencoded({ extended: true }));
export const serverAfter: ServerHook = (server) => {
};
const handlerAfter = (server: Express) => {
console.log("handlerAfter");
}
export const handlerBefore: HandlerHook = (handler) => {
};
type RouteModule = (req: Request, res: Response, next: NextFunction) => void;
export const handlerAfter: HandlerHook = (server) => {
};
const callbackBefore = (callback: RouteModule, route: any) => {
console.log("callbackBefore", callback);
export const callbackBefore: CallbackHook = (callback, route) => {
return callback;
};
export default {
devServerBefore,
serverBefore,
serverAfter,
handlerBefore,
handlerAfter,
callbackBefore,
}
export const serverListening: StatusHook = (server) => {
};
export const serverError: StatusHook = (server, error) => {
};
```

@@ -349,5 +345,11 @@

## WARNING:
Be cautious when configuring the `viteServerBefore` and `viteServerAfter` methods. These methods interact with viteServer, and if not configured correctly, they can lead to issues. Specifically, including a direct reference to the Vite.js library within these methods can cause problems during the build process. Although these methods themselves are not included in the final build output, any import references associated with the vitejs libraries can generate unexpected problems.
## TO DO:
- Duplicate declaration (**GET** in _/user.ts_ and _/user/index.ts_). Handler definition is required.
- Extend the `mapper` attribute to support custom HTTP methods using a header attribute.
- Implement fs-visitor for optimize the scan files process
- express.on("error", callback) don't works
- Set default error handling to `server After` or `handler After`
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