@muhgholy/next-drive 0.1.1 → 1.0.1

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
@@ -73,15 +73,16 @@ export const drive = driveConfiguration({
73
73
 
74
74
  Set up the API route handler that `next-drive` will use to communicate with the client.
75
75
 
76
- ```typescript
77
- // pages/api/drive.ts (Pages Router)
78
- // or app/api/drive/route.ts (App Router)
76
+ **Important:** The API route must be in the `pages` folder (Pages Router) for Next.js to handle the request properly.
79
77
 
80
- import { drive } from "@/lib/drive";
78
+ ```typescript
79
+ // pages/api/drive.ts
80
+ import "@/lib/drive";
81
81
  import { driveAPIHandler } from "@muhgholy/next-drive/server";
82
+ import type { NextApiRequest, NextApiResponse } from "next";
82
83
 
83
- export default function handler(req, res) {
84
- return driveAPIHandler(drive, req, res);
84
+ export default async function handler(req: NextApiRequest, res: NextApiResponse) {
85
+ return driveAPIHandler(req, res);
85
86
  }
86
87
  ```
87
88
 
@@ -125,6 +126,24 @@ function MyForm() {
125
126
  }
126
127
  ```
127
128
 
129
+ **Zod Validation:**
130
+
131
+ You can use the exported `driveFileSchemaZod` to validate file data in your forms or API routes.
132
+
133
+ ```typescript
134
+ import { z } from "zod";
135
+ import { driveFileSchemaZod } from "@muhgholy/next-drive/server";
136
+
137
+ // Use in your form schema
138
+ const myFormSchema = z.object({
139
+ asset: driveFileSchemaZod,
140
+ title: z.string(),
141
+ description: z.string().optional(),
142
+ });
143
+
144
+ type MyFormData = z.infer<typeof myFormSchema>;
145
+ ```
146
+
128
147
  ## Key Capabilities
129
148
 
130
149
  ### Server-Side File Access
@@ -111,11 +111,6 @@ declare const DriveUpload: (props: Readonly<{
111
111
  onComplete?: (item: unknown) => void;
112
112
  }>) => React.JSX.Element;
113
113
 
114
- declare const DriveFilePreview: (props: Readonly<{
115
- item: TDatabaseDrive;
116
- onClose: () => void;
117
- }>) => React.JSX.Element | null;
118
-
119
114
  declare const DriveStorageIndicator: (props: Readonly<{
120
115
  compact?: boolean;
121
116
  className?: string;
@@ -125,4 +120,4 @@ declare const DriveHeader: () => React.JSX.Element;
125
120
 
126
121
  declare const DriveSidebar: () => React.JSX.Element;
127
122
 
128
- export { DriveExplorer, DriveFileChooser, DriveFilePreview, DriveHeader, DrivePathBar, DriveProvider, DriveSidebar, DriveStorageIndicator, DriveUpload, type TDriveContext, TDriveFile, useDrive, useUpload };
123
+ export { DriveExplorer, DriveFileChooser, DriveHeader, DrivePathBar, DriveProvider, DriveSidebar, DriveStorageIndicator, DriveUpload, type TDriveContext, TDriveFile, useDrive, useUpload };