create-better-notify 0.0.2-alpha.0 → 0.0.3-alpha.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/index.js CHANGED
@@ -30034,7 +30034,7 @@ create("create-better-notify", {
30034
30034
  s.start(`Installing dependencies with ${options.pm}...`);
30035
30035
  installDeps(destDir, options.pm);
30036
30036
  s.stop("Dependencies installed.");
30037
- ye(`Done! cd ${options.path} && ${options.pm} run dev`);
30037
+ ye(`Done! cd ${options.path} && ${options.pm} run dev\n\nAPI Playground will be available at http://localhost:3000/api/docs`);
30038
30038
  return {
30039
30039
  name: options.name,
30040
30040
  framework: options.framework,
@@ -13,7 +13,9 @@
13
13
  "@betternotify/resend": "0.0.4-alpha.0",
14
14
  "@betternotify/smtp": "0.0.4-alpha.0",
15
15
  "@hono/node-server": "2.0.1",
16
- "@orpc/server": "1.14.1",
16
+ "@orpc/openapi": "1.14.2",
17
+ "@orpc/server": "1.14.2",
18
+ "@orpc/zod": "1.14.2",
17
19
  "hono": "4.12.17",
18
20
  "react": "19.2.5",
19
21
  "react-email": "6.0.8",
@@ -11,9 +11,9 @@ const base = os.use(injectNotify);
11
11
  export const sendWelcome = base
12
12
  .input(
13
13
  z.object({
14
- to: z.string().email(),
14
+ to: z.email(),
15
15
  name: z.string(),
16
- verifyUrl: z.string().url(),
16
+ verifyUrl: z.url(),
17
17
  }),
18
18
  )
19
19
  .handler(async ({ input, context }) => {
@@ -1,16 +1,19 @@
1
1
  import { Hono } from 'hono';
2
2
  import { serve } from '@hono/node-server';
3
3
  import { RPCHandler } from '@orpc/server/fetch';
4
+ import { OpenAPIHandler } from '@orpc/openapi/fetch';
5
+ import { OpenAPIReferencePlugin } from '@orpc/openapi/plugins';
6
+ import { ZodSmartCoercionPlugin, ZodToJsonSchemaConverter } from '@orpc/zod/zod4';
4
7
  import { router } from './rpc';
5
8
 
6
9
  const app = new Hono();
7
10
 
8
11
  app.get('/', (c) => c.json({ status: 'ok', message: 'better-notify + hono + orpc' }));
9
12
 
10
- const handler = new RPCHandler(router);
13
+ const rpcHandler = new RPCHandler(router);
11
14
 
12
15
  app.use('/rpc/*', async (c, next) => {
13
- const { matched, response } = await handler.handle(c.req.raw, {
16
+ const { matched, response } = await rpcHandler.handle(c.req.raw, {
14
17
  prefix: '/rpc',
15
18
  });
16
19
 
@@ -21,7 +24,36 @@ app.use('/rpc/*', async (c, next) => {
21
24
  await next();
22
25
  });
23
26
 
27
+ const openAPIHandler = new OpenAPIHandler(router, {
28
+ plugins: [
29
+ new ZodSmartCoercionPlugin(),
30
+ new OpenAPIReferencePlugin({
31
+ clientPath: '/docs',
32
+ schemaConverters: [new ZodToJsonSchemaConverter()],
33
+ specGenerateOptions: {
34
+ info: {
35
+ title: '{{name}} API',
36
+ version: '0.0.1',
37
+ },
38
+ },
39
+ }),
40
+ ],
41
+ });
42
+
43
+ app.use('/api/*', async (c, next) => {
44
+ const { matched, response } = await openAPIHandler.handle(c.req.raw, {
45
+ prefix: '/api',
46
+ });
47
+
48
+ if (matched) {
49
+ return c.newResponse(response.body, response);
50
+ }
51
+
52
+ await next();
53
+ });
54
+
24
55
  const port = Number(process.env.PORT ?? 3000);
25
56
 
26
57
  console.log(`Server running at http://localhost:${port}`);
58
+ console.log(`API Playground at http://localhost:${port}/api/docs`);
27
59
  serve({ fetch: app.fetch, port });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-better-notify",
3
- "version": "0.0.2-alpha.0",
3
+ "version": "0.0.3-alpha.0",
4
4
  "description": "Scaffold a better-notify project with your preferred framework and RPC layer.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -26,8 +26,8 @@
26
26
  "tsx": "4.21.0",
27
27
  "typescript": "6.0.3",
28
28
  "vitest": "2.1.9",
29
- "@internal/rolldown-config": "0.0.0",
30
- "@internal/tsconfig": "0.0.0"
29
+ "@internal/tsconfig": "0.0.0",
30
+ "@internal/rolldown-config": "0.0.0"
31
31
  },
32
32
  "engines": {
33
33
  "node": ">=22"