@markitdownjs/next 0.1.0 → 0.1.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/LICENSE +21 -0
- package/README.md +60 -0
- package/package.json +3 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 MarkItDownJS Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# @markitdownjs/next
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@markitdownjs/next)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
Next.js integration for [MarkItDownJS](https://github.com/markitdownjs/markitdownjs). Provides Server Actions, Route Handlers, and streaming upload support.
|
|
7
|
+
|
|
8
|
+
**Peer dependency:** `next >= 14.0.0`
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @markitdownjs/next @markitdownjs/core
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
### Route Handler (App Router)
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
// app/api/convert/route.ts
|
|
22
|
+
import { createConvertRouteHandler } from "@markitdownjs/next";
|
|
23
|
+
import { MarkItDown } from "@markitdownjs/core";
|
|
24
|
+
import { PdfConverter } from "@markitdownjs/pdf";
|
|
25
|
+
|
|
26
|
+
const parser = new MarkItDown();
|
|
27
|
+
parser.registerConverter(new PdfConverter());
|
|
28
|
+
|
|
29
|
+
export const POST = createConvertRouteHandler({ parser });
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Server Action
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
"use server";
|
|
36
|
+
import { createConvertServerAction } from "@markitdownjs/next";
|
|
37
|
+
import { MarkItDown } from "@markitdownjs/core";
|
|
38
|
+
|
|
39
|
+
const parser = new MarkItDown();
|
|
40
|
+
export const convertDocument = createConvertServerAction({ parser });
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Upload Handler
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import { createUploadHandler } from "@markitdownjs/next";
|
|
47
|
+
export const POST = createUploadHandler({ parser, maxSizeMb: 20 });
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## API
|
|
51
|
+
|
|
52
|
+
| Export | Description |
|
|
53
|
+
|--------|-------------|
|
|
54
|
+
| `createConvertRouteHandler(opts)` | Returns a Next.js `POST` handler for `multipart/form-data` uploads |
|
|
55
|
+
| `createConvertServerAction(opts)` | Returns a Server Action accepting a `File` or `FormData` |
|
|
56
|
+
| `createUploadHandler(opts)` | Returns a handler with size limits and streaming support |
|
|
57
|
+
|
|
58
|
+
## Part of the MarkItDownJS Monorepo
|
|
59
|
+
|
|
60
|
+
[https://github.com/markitdownjs/markitdownjs](https://github.com/markitdownjs/markitdownjs)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markitdownjs/next",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Next.js integration for MarkItDownJS document conversion",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@markitdownjs/shared": "0.1.
|
|
20
|
+
"@markitdownjs/shared": "0.1.1"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"next": ">=14.0.0"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"typescript": "^5.5.0",
|
|
27
27
|
"next": "^14.0.0",
|
|
28
|
-
"@markitdownjs/core": "0.1.
|
|
28
|
+
"@markitdownjs/core": "0.1.1"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "tsc --project tsconfig.json",
|