@markitdownjs/api 0.1.1 → 0.1.3

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/dist/app.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Hono } from 'hono';
1
+ import { Hono } from "hono";
2
2
  declare const app: Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
3
3
  export default app;
4
4
  //# sourceMappingURL=app.d.ts.map
package/dist/app.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAI5B,QAAA,MAAM,GAAG,4EAAa,CAAC;AAyCvB,eAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAI5B,QAAA,MAAM,GAAG,4EAAa,CAAC;AAsCvB,eAAe,GAAG,CAAC"}
package/dist/app.js CHANGED
@@ -1,23 +1,23 @@
1
- import { Hono } from 'hono';
2
- import { cors } from 'hono/cors';
3
- import { getSupportedExtensions, getSupportedMimeTypes } from '@markitdownjs/shared';
1
+ import { Hono } from "hono";
2
+ import { cors } from "hono/cors";
3
+ import { getSupportedExtensions, getSupportedMimeTypes } from "@markitdownjs/shared";
4
4
  const app = new Hono();
5
- app.use('/*', cors());
6
- app.get('/health', (c) => c.json({ status: 'ok', timestamp: new Date().toISOString() }));
7
- app.get('/formats', async (c) => {
5
+ app.use("/*", cors());
6
+ app.get("/health", (c) => c.json({ status: "ok", timestamp: new Date().toISOString() }));
7
+ app.get("/formats", async (c) => {
8
8
  return c.json({
9
9
  extensions: getSupportedExtensions(),
10
10
  mimeTypes: getSupportedMimeTypes(),
11
11
  });
12
12
  });
13
- app.post('/convert', async (c) => {
13
+ app.post("/convert", async (c) => {
14
14
  try {
15
15
  const body = await c.req.parseBody();
16
- const file = body['file'];
16
+ const file = body["file"];
17
17
  if (!file || !(file instanceof File)) {
18
- return c.json({ error: 'No file provided' }, 400);
18
+ return c.json({ error: "No file provided" }, 400);
19
19
  }
20
- const { MarkItDown } = await import('@markitdownjs/core');
20
+ const { MarkItDown } = await import("@markitdownjs/core");
21
21
  const parser = new MarkItDown();
22
22
  const arrayBuffer = await file.arrayBuffer();
23
23
  const result = await parser.convert({
@@ -28,7 +28,7 @@ app.post('/convert', async (c) => {
28
28
  return c.json(result);
29
29
  }
30
30
  catch (error) {
31
- return c.json({ error: error instanceof Error ? error.message : 'Conversion failed' }, 500);
31
+ return c.json({ error: error instanceof Error ? error.message : "Conversion failed" }, 500);
32
32
  }
33
33
  });
34
34
  export default app;
package/dist/app.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAErF,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;AAEvB,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAEtB,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC;AAEzF,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC9B,OAAO,CAAC,CAAC,IAAI,CAAC;QACZ,UAAU,EAAE,sBAAsB,EAAE;QACpC,SAAS,EAAE,qB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W,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;QAC7C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;YAClC,IAAI,EAAE,IAAI,UAAU,CAAC,WAAW,CAAC;YACjC,QAAQ,EAAE,IAAI,CAAC,IAAI;YACnB,QAAQ,EAAE,IAAI,CAAC,IAAI,IAAI,SAAS;SACjC,CAAC,CAAC;QAEH,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB,EAAE,EAAE,GAAG,CAAC,CAAC;IAC9F,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,eAAe,GAAG,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { default as app } from './app.js';
2
- export { rateLimit, validateFileSize } from './middleware.js';
1
+ export { default as app } from "./app.js";
2
+ export { rateLimit, validateFileSize } from "./middleware.js";
3
3
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { default as app } from './app.js';
2
- export { rateLimit, validateFileSize } from './middleware.js';
1
+ export { default as app } from "./app.js";
2
+ export { rateLimit, validateFileSize } from "./middleware.js";
3
3
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import type { Context, Next } from 'hono';
1
+ import type { Context, Next } from "hono";
2
2
  export declare function rateLimit(options?: {
3
3
  windowMs?: number;
4
4
  max?: number;
@@ -3,7 +3,7 @@ export function rateLimit(options = {}) {
3
3
  const windowMs = options.windowMs ?? 60_000;
4
4
  const max = options.max ?? 100;
5
5
  return async (c, next) => {
6
- const ip = c.req.header('x-forwarded-for') ?? c.req.header('x-real-ip') ?? 'unknown';
6
+ const ip = c.req.header("x-forwarded-for") ?? c.req.header("x-real-ip") ?? "unknown";
7
7
  const now = Date.now();
8
8
  const record = requestCounts.get(ip);
9
9
  if (!record || now > record.resetTime) {
@@ -12,16 +12,16 @@ export function rateLimit(options = {}) {
12
12
  }
13
13
  record.count++;
14
14
  if (record.count > max) {
15
- return c.json({ error: 'Too many requests' }, 429);
15
+ return c.json({ error: "Too many requests" }, 429);
16
16
  }
17
17
  return next();
18
18
  };
19
19
  }
20
20
  const MAX_FILE_SIZE = 50 * 1024 * 1024;
21
21
  export async function validateFileSize(c, next) {
22
- const contentLength = c.req.header('content-length');
22
+ const contentLength = c.req.header("content-length");
23
23
  if (contentLength && parseInt(contentLength, 10) > MAX_FILE_SIZE) {
24
- return c.json({ error: 'File too large. Maximum size is 50MB' }, 413);
24
+ return c.json({ error: "File too large. Maximum size is 50MB" }, 413);
25
25
  }
26
26
  return next();
27
27
  }
package/dist/server.js CHANGED
@@ -1,6 +1,6 @@
1
- import { serve } from '@hono/node-server';
2
- import app from './app.js';
3
- const port = parseInt(process.env.PORT ?? '3000', 10);
1
+ import { serve } from "@hono/node-server";
2
+ import app from "./app.js";
3
+ const port = parseInt(process.env.PORT ?? "3000", 10);
4
4
  serve({ fetch: app.fetch, port }, (info) => {
5
5
  console.log(`MarkItDownJS API server running on http://localhost:${info.port}`);
6
6
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markitdownjs/api",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "HTTP API server for MarkItDownJS document conversion",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -17,14 +17,14 @@
17
17
  "dist"
18
18
  ],
19
19
  "dependencies": {
20
- "hono": "^4.0.0",
21
- "@markitdownjs/core": "0.1.1",
22
- "@markitdownjs/shared": "0.1.1"
20
+ "hono": "^4.12.25",
21
+ "@markitdownjs/core": "0.3.0",
22
+ "@markitdownjs/shared": "0.3.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "typescript": "^5.5.0",
26
26
  "@hono/node-server": "^1.0.0",
27
- "@types/node": "^20.0.0"
27
+ "@types/node": "^20.19.43"
28
28
  },
29
29
  "scripts": {
30
30
  "build": "tsc --project tsconfig.json",