@deessejs/server-next 0.0.0
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/createNextHandler.d.ts +19 -0
- package/dist/createNextHandler.d.ts.map +1 -0
- package/dist/createNextHandler.js +18 -0
- package/dist/createNextHandler.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +17 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +39 -0
- package/src/createNextHandler.ts +32 -0
- package/src/index.ts +2 -0
- package/tests/createNextHandler.test.ts +38 -0
- package/tsconfig.json +18 -0
- package/vitest.config.ts +7 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { handle } from "hono/vercel";
|
|
2
|
+
import type { HTTPClient } from "@deessejs/server-hono";
|
|
3
|
+
/**
|
|
4
|
+
* Next.js handler object with HTTP methods
|
|
5
|
+
*/
|
|
6
|
+
export interface NextHandler {
|
|
7
|
+
GET: typeof handle;
|
|
8
|
+
POST: typeof handle;
|
|
9
|
+
PUT: typeof handle;
|
|
10
|
+
PATCH: typeof handle;
|
|
11
|
+
DELETE: typeof handle;
|
|
12
|
+
OPTIONS: typeof handle;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Creates a Next.js handler from a deesse API client
|
|
16
|
+
* Uses Hono internally via the handle() function from hono/vercel
|
|
17
|
+
*/
|
|
18
|
+
export declare function createNextHandler(client: HTTPClient): NextHandler;
|
|
19
|
+
//# sourceMappingURL=createNextHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createNextHandler.d.ts","sourceRoot":"","sources":["../src/createNextHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,OAAO,MAAM,CAAC;IACnB,IAAI,EAAE,OAAO,MAAM,CAAC;IACpB,GAAG,EAAE,OAAO,MAAM,CAAC;IACnB,KAAK,EAAE,OAAO,MAAM,CAAC;IACrB,MAAM,EAAE,OAAO,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,WAAW,CAWjE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { handle } from "hono/vercel";
|
|
2
|
+
import { createHonoHandler } from "@deessejs/server-hono";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a Next.js handler from a deesse API client
|
|
5
|
+
* Uses Hono internally via the handle() function from hono/vercel
|
|
6
|
+
*/
|
|
7
|
+
export function createNextHandler(client) {
|
|
8
|
+
const app = createHonoHandler(client);
|
|
9
|
+
return {
|
|
10
|
+
GET: handle(app),
|
|
11
|
+
POST: handle(app),
|
|
12
|
+
PUT: handle(app),
|
|
13
|
+
PATCH: handle(app),
|
|
14
|
+
DELETE: handle(app),
|
|
15
|
+
OPTIONS: handle(app),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=createNextHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createNextHandler.js","sourceRoot":"","sources":["../src/createNextHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAe1D;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAkB;IAClD,MAAM,GAAG,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAEtC,OAAO;QACL,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC;QACjB,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC;KACrB,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { HTTPClient } from "@deessejs/server-hono";
|
|
2
|
+
/**
|
|
3
|
+
* HTTP client interface returned by createPublicAPI
|
|
4
|
+
*/
|
|
5
|
+
export type NextClient = HTTPClient;
|
|
6
|
+
/**
|
|
7
|
+
* Next.js handler object with HTTP methods
|
|
8
|
+
*/
|
|
9
|
+
export interface NextHandler {
|
|
10
|
+
GET: (req: Request, context: any) => Promise<Response>;
|
|
11
|
+
POST: (req: Request, context: any) => Promise<Response>;
|
|
12
|
+
PUT: (req: Request, context: any) => Promise<Response>;
|
|
13
|
+
PATCH: (req: Request, context: any) => Promise<Response>;
|
|
14
|
+
DELETE: (req: Request, context: any) => Promise<Response>;
|
|
15
|
+
OPTIONS: (req: Request, context: any) => Promise<Response>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvD,IAAI,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxD,GAAG,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvD,KAAK,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACzD,MAAM,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC1D,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC5D"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@deessejs/server-next",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Next.js App Router adapter for @deessejs/server using Hono",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"dev": "tsc --watch",
|
|
18
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
19
|
+
"typecheck": "tsc --noEmit",
|
|
20
|
+
"test": "vitest run",
|
|
21
|
+
"clean": "rm -rf dist"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@deessejs/server-hono": "workspace:*",
|
|
25
|
+
"hono": "^4.0.0"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@deessejs/server": "*",
|
|
29
|
+
"next": "^14.0.0 || ^15.0.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@deessejs/server": "workspace:*",
|
|
33
|
+
"@deessejs/server-hono": "workspace:*",
|
|
34
|
+
"@deessejs/fp": "^3.0.0",
|
|
35
|
+
"typescript": "^5.0.0",
|
|
36
|
+
"vitest": "^2.0.0",
|
|
37
|
+
"zod": "^3.0.0"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { handle } from "hono/vercel";
|
|
2
|
+
import { createHonoHandler } from "@deessejs/server-hono";
|
|
3
|
+
import type { HTTPClient } from "@deessejs/server-hono";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Next.js handler object with HTTP methods
|
|
7
|
+
*/
|
|
8
|
+
export interface NextHandler {
|
|
9
|
+
GET: typeof handle;
|
|
10
|
+
POST: typeof handle;
|
|
11
|
+
PUT: typeof handle;
|
|
12
|
+
PATCH: typeof handle;
|
|
13
|
+
DELETE: typeof handle;
|
|
14
|
+
OPTIONS: typeof handle;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Creates a Next.js handler from a deesse API client
|
|
19
|
+
* Uses Hono internally via the handle() function from hono/vercel
|
|
20
|
+
*/
|
|
21
|
+
export function createNextHandler(client: HTTPClient): NextHandler {
|
|
22
|
+
const app = createHonoHandler(client);
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
GET: handle(app),
|
|
26
|
+
POST: handle(app),
|
|
27
|
+
PUT: handle(app),
|
|
28
|
+
PATCH: handle(app),
|
|
29
|
+
DELETE: handle(app),
|
|
30
|
+
OPTIONS: handle(app),
|
|
31
|
+
};
|
|
32
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { defineContext, createPublicAPI, ok } from "@deessejs/server";
|
|
3
|
+
import { createNextHandler } from "../src/index";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
|
|
6
|
+
describe("createNextHandler", () => {
|
|
7
|
+
it("should create a Next.js handler object", () => {
|
|
8
|
+
const { t, createAPI } = defineContext({
|
|
9
|
+
context: { name: "test" },
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const getUser = t.query({
|
|
13
|
+
args: z.object({ id: z.number() }),
|
|
14
|
+
handler: async (ctx, args) => {
|
|
15
|
+
return ok({ id: args.id, name: ctx.name });
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const api = createAPI({
|
|
20
|
+
router: t.router({
|
|
21
|
+
users: {
|
|
22
|
+
get: getUser,
|
|
23
|
+
},
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const client = createPublicAPI(api);
|
|
28
|
+
const handler = createNextHandler(client);
|
|
29
|
+
|
|
30
|
+
expect(handler).toBeDefined();
|
|
31
|
+
expect(typeof handler.GET).toBe("function");
|
|
32
|
+
expect(typeof handler.POST).toBe("function");
|
|
33
|
+
expect(typeof handler.PUT).toBe("function");
|
|
34
|
+
expect(typeof handler.PATCH).toBe("function");
|
|
35
|
+
expect(typeof handler.DELETE).toBe("function");
|
|
36
|
+
expect(typeof handler.OPTIONS).toBe("function");
|
|
37
|
+
});
|
|
38
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["ES2022"],
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"declarationMap": true,
|
|
9
|
+
"sourceMap": true,
|
|
10
|
+
"outDir": "./dist",
|
|
11
|
+
"rootDir": "./src",
|
|
12
|
+
"strict": true,
|
|
13
|
+
"esModuleInterop": true,
|
|
14
|
+
"skipLibCheck": true,
|
|
15
|
+
"forceConsistentCasingInFileNames": true
|
|
16
|
+
},
|
|
17
|
+
"include": ["src"]
|
|
18
|
+
}
|