alchemy 0.2.1 → 0.2.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.
Files changed (84) hide show
  1. package/lib/alchemy.d.ts +1 -0
  2. package/lib/alchemy.js +84 -8
  3. package/lib/apply.d.ts +1 -1
  4. package/lib/apply.js +13 -10
  5. package/lib/aws/bucket.d.ts +1 -1
  6. package/lib/aws/function.d.ts +1 -1
  7. package/lib/aws/oidc/oidc-provider.d.ts +1 -1
  8. package/lib/aws/policy-attachment.d.ts +1 -1
  9. package/lib/aws/policy.d.ts +1 -1
  10. package/lib/aws/queue.d.ts +1 -1
  11. package/lib/aws/role.d.ts +1 -1
  12. package/lib/aws/ses.d.ts +1 -1
  13. package/lib/aws/table.d.ts +1 -1
  14. package/lib/cloudflare/bucket.d.ts +1 -1
  15. package/lib/cloudflare/kv-namespace.d.ts +1 -1
  16. package/lib/cloudflare/static-site.d.ts +1 -1
  17. package/lib/cloudflare/worker.d.ts +1 -1
  18. package/lib/cloudflare/wrangler.json.d.ts +1 -1
  19. package/lib/cloudflare/zone.d.ts +1 -1
  20. package/lib/context.d.ts +9 -4
  21. package/lib/context.js +4 -2
  22. package/lib/destroy.js +8 -7
  23. package/lib/docs/document.d.ts +123 -0
  24. package/lib/docs/document.js +67 -0
  25. package/lib/docs/index.d.ts +1 -0
  26. package/lib/docs/index.js +1 -0
  27. package/lib/esbuild/bundle.d.ts +1 -1
  28. package/lib/fs/file.d.ts +30 -3
  29. package/lib/fs/file.js +63 -3
  30. package/lib/fs/folder.d.ts +3 -3
  31. package/lib/fs/folder.js +2 -1
  32. package/lib/github/secret.d.ts +1 -1
  33. package/lib/resource.d.ts +2 -2
  34. package/lib/resource.js +4 -0
  35. package/lib/scope.d.ts +1 -1
  36. package/lib/scope.js +6 -6
  37. package/lib/shadcn/component.d.ts +29 -0
  38. package/lib/shadcn/component.js +31 -0
  39. package/lib/shadcn/index.d.ts +1 -0
  40. package/lib/shadcn/index.js +1 -0
  41. package/lib/state.d.ts +1 -1
  42. package/lib/state.js +8 -1
  43. package/lib/stripe/price.d.ts +1 -1
  44. package/lib/stripe/product.d.ts +1 -1
  45. package/lib/stripe/webhook.d.ts +1 -1
  46. package/lib/util/serde.d.ts +3 -1
  47. package/lib/util/serde.js +6 -4
  48. package/lib/vite/vite.d.ts +90 -0
  49. package/lib/vite/vite.js +228 -0
  50. package/lib/vitepress/dependencies.d.ts +16 -0
  51. package/lib/vitepress/dependencies.js +35 -0
  52. package/lib/vitepress/home-page.d.ts +133 -0
  53. package/lib/vitepress/home-page.js +11 -0
  54. package/lib/vitepress/index.d.ts +2 -0
  55. package/lib/vitepress/index.js +2 -0
  56. package/lib/vitepress/vitepress.d.ts +60 -0
  57. package/lib/vitepress/vitepress.js +260 -0
  58. package/package.json +19 -11
  59. package/src/alchemy.ts +105 -13
  60. package/src/apply.ts +25 -13
  61. package/src/context.ts +30 -10
  62. package/src/destroy.ts +10 -7
  63. package/src/docs/document.ts +225 -0
  64. package/src/docs/index.ts +1 -0
  65. package/src/fs/file.ts +114 -6
  66. package/src/fs/folder.ts +2 -1
  67. package/src/resource.ts +7 -2
  68. package/src/scope.ts +9 -9
  69. package/src/shadcn/component.ts +80 -0
  70. package/src/shadcn/index.ts +1 -0
  71. package/src/state.ts +9 -2
  72. package/src/util/serde.ts +13 -4
  73. package/src/vite/vite.ts +406 -0
  74. package/src/vitepress/dependencies.ts +68 -0
  75. package/src/vitepress/home-page.ts +166 -0
  76. package/src/vitepress/index.md +75 -0
  77. package/src/vitepress/index.ts +2 -0
  78. package/src/vitepress/vitepress.ts +361 -0
  79. package/lib/project/vite.d.ts +0 -39
  80. package/lib/project/vite.js +0 -68
  81. package/src/project/vite.ts +0 -152
  82. /package/lib/{project → vite}/index.d.ts +0 -0
  83. /package/lib/{project → vite}/index.js +0 -0
  84. /package/src/{project → vite}/index.ts +0 -0
@@ -0,0 +1,406 @@
1
+ import { exec } from "child_process";
2
+ import fs from "fs/promises";
3
+ import path from "path";
4
+ import { promisify } from "util";
5
+ import type { Context } from "../context";
6
+ import { Resource } from "../resource";
7
+ import { ShadcnComponent } from "../shadcn/component";
8
+ import { rm } from "../util/rm";
9
+
10
+ const execAsync = promisify(exec);
11
+
12
+ type ViteTemplate =
13
+ | "vanilla"
14
+ | "vanilla-ts"
15
+ | "vue"
16
+ | "vue-ts"
17
+ | "react"
18
+ | "react-ts"
19
+ | "react-swc"
20
+ | "react-swc-ts"
21
+ | "preact"
22
+ | "preact-ts"
23
+ | "lit"
24
+ | "lit-ts"
25
+ | "svelte"
26
+ | "svelte-ts"
27
+ | "solid"
28
+ | "solid-ts"
29
+ | "qwik"
30
+ | "qwik-ts";
31
+
32
+ export interface ViteProjectProps {
33
+ /**
34
+ * The name/path of the project
35
+ */
36
+ name: string;
37
+ /**
38
+ * The Vite template to use
39
+ */
40
+ template: ViteTemplate;
41
+ /**
42
+ * The extends to add to the tsconfig.json file
43
+ */
44
+ extends?: string;
45
+ /**
46
+ * The references to add to the tsconfig.json file
47
+ */
48
+ references?: string[];
49
+ /**
50
+ * Add Tailwind CSS to the project
51
+ * @default false
52
+ */
53
+ tailwind?: boolean;
54
+ /**
55
+ * Add Tanstack Router to the project
56
+ * @default false
57
+ */
58
+ tanstack?: boolean;
59
+ /**
60
+ * Add Shadcn UI to the project
61
+ * @default false
62
+ */
63
+ shadcn?: {
64
+ /**
65
+ * The base color to use
66
+ * @default "neutral"
67
+ */
68
+ baseColor?: "neutral" | "gray" | "zinc" | "stone" | "slate";
69
+ /**
70
+ * Use default configuration
71
+ * @default false
72
+ */
73
+ defaults?: boolean;
74
+
75
+ /**
76
+ * Force overwrite of existing configuration
77
+ * @default false
78
+ */
79
+ force?: boolean;
80
+
81
+ /**
82
+ * The working directory
83
+ * @default current directory
84
+ */
85
+ cwd?: string;
86
+
87
+ /**
88
+ * Mute output
89
+ * @default false
90
+ */
91
+ silent?: boolean;
92
+
93
+ /**
94
+ * Use the src directory when creating a new project
95
+ * @default false
96
+ */
97
+ srcDir?: boolean;
98
+
99
+ /**
100
+ * Use css variables for theming
101
+ * @default true
102
+ */
103
+ cssVariables?: boolean;
104
+
105
+ /**
106
+ * The components to add
107
+ */
108
+ components?: string[];
109
+ };
110
+ /**
111
+ * Force overwrite the project config files during the update phase
112
+ *
113
+ * @default false
114
+ */
115
+ overwrite?: boolean;
116
+ }
117
+
118
+ export interface ViteProject extends ViteProjectProps, Resource {
119
+ /**
120
+ * The name/path of the project
121
+ */
122
+ name: string;
123
+ }
124
+
125
+ export const ViteProject = Resource(
126
+ "project::ViteProject",
127
+ {
128
+ alwaysUpdate: true,
129
+ },
130
+ async function (
131
+ this: Context<ViteProject>,
132
+ id: string,
133
+ props: ViteProjectProps,
134
+ ): Promise<ViteProject> {
135
+ const phase = this.phase;
136
+ if (this.phase === "delete") {
137
+ try {
138
+ if (await fs.exists(props.name)) {
139
+ // TODO: OS agnostic - fs.rm is slow to delete node_modules/
140
+ await execAsync("rm -rf " + props.name);
141
+ }
142
+ } catch (error) {
143
+ console.error(`Error deleting project ${id}:`, error);
144
+ }
145
+ return this.destroy();
146
+ }
147
+
148
+ if (this.phase === "update") {
149
+ if (props.overwrite) {
150
+ await modifyConfig(props);
151
+ } else {
152
+ console.warn(
153
+ "ViteProject does not support updates - the project must be recreated to change the template",
154
+ );
155
+ }
156
+ } else {
157
+ await execAsync(`bun create vite ${id} --template ${props.template}`);
158
+
159
+ await modifyConfig(props);
160
+ }
161
+
162
+ return this(props);
163
+
164
+ async function modifyConfig(props: ViteProjectProps) {
165
+ const tailwind = props.tailwind ?? false;
166
+ const tanstack = props.tanstack ?? false;
167
+
168
+ const plugins = [
169
+ tailwind && "tailwindcss()",
170
+ tanstack &&
171
+ "TanStackRouterVite({ target: 'react', autoCodeSplitting: true })",
172
+ "react()",
173
+ ].filter((s) => typeof s === "string");
174
+
175
+ const cwd = path.resolve(process.cwd(), props.name);
176
+
177
+ const exec = (command: string) => execAsync(command, { cwd });
178
+
179
+ if (phase === "create" || props.overwrite) {
180
+ await removeUnnecessaryFiles();
181
+ }
182
+
183
+ await patchTsConfig();
184
+
185
+ if (props.tailwind) {
186
+ await installTailwind();
187
+ }
188
+
189
+ if (props.tanstack) {
190
+ await installTanstack();
191
+ }
192
+
193
+ if (props.shadcn !== undefined) {
194
+ await installShadcn();
195
+ }
196
+
197
+ await build();
198
+
199
+ async function build() {
200
+ // tsc -b will fail if we have not invoked tan stacks' code gen
201
+ await execAsync(`bun vite build`, { cwd: props.name });
202
+ }
203
+
204
+ async function installTailwind() {
205
+ await exec(`bun add tailwindcss @tailwindcss/vite`);
206
+
207
+ await fs.writeFile(
208
+ path.join(props.name, "vite.config.ts"),
209
+ `import path from "path";
210
+ import react from "@vitejs/plugin-react";
211
+ import { defineConfig } from "vite";
212
+ ${tailwind ? "import tailwindcss from '@tailwindcss/vite';" : ""}
213
+ ${tanstack ? 'import { TanStackRouterVite } from "@tanstack/router-plugin/vite";' : ""}
214
+
215
+ // https://vite.dev/config/
216
+ export default defineConfig({
217
+ plugins: [${plugins.join(", ")}],
218
+ resolve: {
219
+ alias: {
220
+ "@": path.resolve(__dirname, "./src"),
221
+ },
222
+ },
223
+ });`,
224
+ );
225
+
226
+ // Add Tailwind CSS import to index.css
227
+ const indexCssPath = path.join(props.name, "src", "index.css");
228
+ const currentCss = await fs.readFile(indexCssPath, "utf-8");
229
+ if (!currentCss.includes('@import "tailwindcss";')) {
230
+ await fs.writeFile(
231
+ indexCssPath,
232
+ '@import "tailwindcss";\n\n' + currentCss,
233
+ );
234
+ }
235
+ }
236
+
237
+ async function installShadcn() {
238
+ await exec("bun add -D @types/node");
239
+
240
+ // Build the shadcn init command with all options
241
+ const shadcnOptions = props.shadcn;
242
+ const initCommand = [
243
+ "bunx --bun shadcn@latest init",
244
+ shadcnOptions?.baseColor && `-b ${shadcnOptions.baseColor}`,
245
+ shadcnOptions?.defaults && "-d",
246
+ shadcnOptions?.force && "-f",
247
+ shadcnOptions?.cwd && `-c ${shadcnOptions.cwd}`,
248
+ shadcnOptions?.silent && "-s",
249
+ shadcnOptions?.srcDir && "--src-dir",
250
+ shadcnOptions?.cssVariables === false && "--no-css-variables",
251
+ ]
252
+ .filter(Boolean)
253
+ .join(" ");
254
+
255
+ await exec(initCommand);
256
+
257
+ // Install requested components using the ShadcnComponent resource
258
+ for (const componentName of props.shadcn?.components ?? []) {
259
+ await ShadcnComponent(`shadcn-component-${componentName}`, {
260
+ name: componentName,
261
+ cwd: props.name,
262
+ force: props.shadcn?.force,
263
+ silent: props.shadcn?.silent,
264
+ });
265
+ }
266
+ }
267
+
268
+ async function installTanstack() {
269
+ await exec(`bun add @tanstack/react-router`);
270
+ await exec(
271
+ `bun add -D @tanstack/router-plugin @tanstack/react-router-devtools`,
272
+ );
273
+
274
+ const src = path.join(props.name, "src");
275
+ const routes = path.join(src, "routes");
276
+ await fs.mkdir(routes, { recursive: true });
277
+ await fs.writeFile(
278
+ path.join(routes, "__root.tsx"),
279
+ `import { Link, Outlet, createRootRoute } from "@tanstack/react-router";
280
+ import { TanStackRouterDevtools } from "@tanstack/react-router-devtools";
281
+
282
+ export const Route = createRootRoute({
283
+ component: () => (
284
+ <div className="w-full min-h-screen flex flex-col">
285
+ <div className="p-2 flex gap-2">
286
+ <Link to="/" className="[&.active]:font-bold">
287
+ Home
288
+ </Link>{" "}
289
+ <Link to="/about" className="[&.active]:font-bold">
290
+ About
291
+ </Link>
292
+ </div>
293
+ <hr />
294
+ <Outlet />
295
+ <TanStackRouterDevtools />
296
+ </div>
297
+ ),
298
+ });
299
+ `,
300
+ );
301
+
302
+ await fs.writeFile(
303
+ path.join(routes, "index.tsx"),
304
+ `import { createLazyFileRoute } from '@tanstack/react-router'
305
+
306
+ export const Route = createLazyFileRoute('/')({
307
+ component: Index,
308
+ })
309
+
310
+ function Index() {
311
+ return (
312
+ <div className="p-2">
313
+ <h3>Welcome Home!</h3>
314
+ </div>
315
+ )
316
+ }`,
317
+ );
318
+
319
+ await fs.writeFile(
320
+ path.join(routes, "about.tsx"),
321
+ `import { createLazyFileRoute } from '@tanstack/react-router'
322
+
323
+ export const Route = createLazyFileRoute('/about')({
324
+ component: About,
325
+ })
326
+
327
+ function About() {
328
+ return <div className="p-2">Hello from About!</div>
329
+ }`,
330
+ );
331
+
332
+ await fs.writeFile(
333
+ path.join(src, "main.tsx"),
334
+ `import { StrictMode } from 'react'
335
+ import ReactDOM from 'react-dom/client'
336
+ import { RouterProvider, createRouter } from '@tanstack/react-router'
337
+ import './index.css'
338
+
339
+ // Import the generated route tree
340
+ import { routeTree } from './routeTree.gen'
341
+
342
+ // Create a new router instance
343
+ const router = createRouter({ routeTree })
344
+
345
+ // Register the router instance for type safety
346
+ declare module '@tanstack/react-router' {
347
+ interface Register {
348
+ router: typeof router
349
+ }
350
+ }
351
+
352
+ // Render the app
353
+ const rootElement = document.getElementById('root')!
354
+ if (!rootElement.innerHTML) {
355
+ const root = ReactDOM.createRoot(rootElement)
356
+ root.render(
357
+ <StrictMode>
358
+ <RouterProvider router={router} />
359
+ </StrictMode>,
360
+ )
361
+ }`,
362
+ );
363
+ }
364
+
365
+ async function removeUnnecessaryFiles() {
366
+ await Promise.all([
367
+ rm(path.join(props.name, "src", "App.tsx")),
368
+ rm(path.join(props.name, "src", "App.css")),
369
+ ]);
370
+ }
371
+
372
+ async function patchTsConfig() {
373
+ await Promise.all([
374
+ rm(path.join(props.name, "tsconfig.app.json")),
375
+ rm(path.join(props.name, "tsconfig.node.json")),
376
+ fs.writeFile(
377
+ path.join(props.name, "tsconfig.json"),
378
+ JSON.stringify(
379
+ {
380
+ extends: props.extends,
381
+ compilerOptions: {
382
+ baseUrl: ".",
383
+ paths: {
384
+ "@/*": ["./src/*"],
385
+ },
386
+ types: ["@cloudflare/workers-types"],
387
+ allowImportingTsExtensions: true,
388
+ jsx: "react-jsx",
389
+ },
390
+ include: [
391
+ "vite/*.ts",
392
+ "src/**/*.ts",
393
+ "src/**/*.tsx",
394
+ "src/env.d.ts",
395
+ ],
396
+ references: props.references?.map((path) => ({ path })),
397
+ },
398
+ null,
399
+ 2,
400
+ ),
401
+ ),
402
+ ]);
403
+ }
404
+ }
405
+ },
406
+ );
@@ -0,0 +1,68 @@
1
+ import { exec } from "child_process";
2
+ import { promisify } from "util";
3
+ import type { Context } from "../context";
4
+ import { Resource } from "../resource";
5
+
6
+ const execAsync = promisify(exec);
7
+
8
+ export type InstallDependencies = Resource<"project::InstallDependencies">;
9
+
10
+ export const InstallDependencies = Resource(
11
+ "project::InstallDependencies",
12
+ {
13
+ alwaysUpdate: true,
14
+ },
15
+ async function (
16
+ this: Context<InstallDependencies>,
17
+ id: string,
18
+ {
19
+ cwd,
20
+ dependencies,
21
+ devDependencies,
22
+ }: {
23
+ cwd: string;
24
+ dependencies?: Record<string, string>;
25
+ devDependencies?: Record<string, string>;
26
+ },
27
+ ) {
28
+ if (this.phase === "delete") {
29
+ return this.destroy();
30
+ }
31
+
32
+ await installDependencies(cwd, dependencies);
33
+ await installDependencies(cwd, devDependencies, "-D");
34
+ await execAsync("bun install", { cwd });
35
+
36
+ return this({});
37
+ },
38
+ );
39
+
40
+ function isInstallableVersion(version: string) {
41
+ // TODO: file:// ?
42
+ return !version.startsWith("workspace:");
43
+ }
44
+
45
+ export function fixedDependencies(dependencies?: Record<string, string>) {
46
+ if (!dependencies) return {};
47
+ return Object.fromEntries(
48
+ Object.entries(dependencies).filter(
49
+ ([, value]) => !isInstallableVersion(value),
50
+ ),
51
+ );
52
+ }
53
+
54
+ export async function installDependencies(
55
+ cwd: string,
56
+ dependencies: Record<string, string> | undefined,
57
+ ...args: string[]
58
+ ) {
59
+ if (!dependencies) return;
60
+ const deps = Object.entries(dependencies)
61
+ .filter(([, value]) => isInstallableVersion(value))
62
+ .map(([pkg, version]) => `${pkg}@${version}`)
63
+ .join(" ");
64
+
65
+ const cmd = `bun add ${args.join(" ")} ${deps}`;
66
+ console.log(cmd);
67
+ await execAsync(cmd, { cwd });
68
+ }
@@ -0,0 +1,166 @@
1
+ import yaml from "yaml";
2
+
3
+ /**
4
+ * Image that can be themed for light/dark mode
5
+ */
6
+ export interface ThemeableImage {
7
+ /**
8
+ * Image source URL
9
+ */
10
+ src?: string;
11
+
12
+ /**
13
+ * Image alt text
14
+ */
15
+ alt?: string;
16
+
17
+ /**
18
+ * Light theme image URL
19
+ */
20
+ light?: string;
21
+
22
+ /**
23
+ * Dark theme image URL
24
+ */
25
+ dark?: string;
26
+ }
27
+
28
+ /**
29
+ * Hero action button configuration
30
+ */
31
+ export interface HeroAction {
32
+ /**
33
+ * Color theme of the button
34
+ * @default "brand"
35
+ */
36
+ theme?: "brand" | "alt";
37
+
38
+ /**
39
+ * Label of the button
40
+ */
41
+ text: string;
42
+
43
+ /**
44
+ * Destination link of the button
45
+ */
46
+ link: string;
47
+
48
+ /**
49
+ * Link target attribute
50
+ */
51
+ target?: string;
52
+
53
+ /**
54
+ * Link rel attribute
55
+ */
56
+ rel?: string;
57
+ }
58
+
59
+ /**
60
+ * Hero section configuration
61
+ */
62
+ export interface Hero {
63
+ /**
64
+ * The string shown top of text. Comes with brand color
65
+ * and expected to be short, such as product name.
66
+ */
67
+ name?: string;
68
+
69
+ /**
70
+ * The main text for the hero section. This will be defined
71
+ * as h1 tag.
72
+ */
73
+ text: string;
74
+
75
+ /**
76
+ * Tagline displayed below text
77
+ */
78
+ tagline?: string;
79
+
80
+ /**
81
+ * The image displayed next to the text and tagline area
82
+ */
83
+ image?: string | ThemeableImage;
84
+
85
+ /**
86
+ * Action buttons to display in home hero section
87
+ */
88
+ actions?: HeroAction[];
89
+ }
90
+
91
+ /**
92
+ * Feature item configuration
93
+ */
94
+ export interface Feature {
95
+ /**
96
+ * Show icon on each feature box
97
+ */
98
+ icon?: string | ThemeableImage;
99
+
100
+ /**
101
+ * Title of the feature
102
+ */
103
+ title: string;
104
+
105
+ /**
106
+ * Details of the feature
107
+ */
108
+ details: string;
109
+
110
+ /**
111
+ * Link when clicked on feature component
112
+ */
113
+ link?: string;
114
+
115
+ /**
116
+ * Link text to be shown inside feature component
117
+ */
118
+ linkText?: string;
119
+
120
+ /**
121
+ * Link rel attribute
122
+ */
123
+ rel?: string;
124
+
125
+ /**
126
+ * Link target attribute
127
+ */
128
+ target?: string;
129
+ }
130
+
131
+ /**
132
+ * VitePress home page configuration
133
+ */
134
+ export interface HomePage {
135
+ /**
136
+ * Use home page layout
137
+ */
138
+ layout: "home";
139
+
140
+ /**
141
+ * Hero section configuration
142
+ */
143
+ hero?: Hero;
144
+
145
+ /**
146
+ * Features section configuration
147
+ */
148
+ features?: Feature[];
149
+
150
+ /**
151
+ * Whether to apply default markdown styles
152
+ * @default true
153
+ */
154
+ markdownStyles?: boolean;
155
+ }
156
+
157
+ /**
158
+ * Parse YAML frontmatter to home page config
159
+ */
160
+ export function parseHomePage(content: string): HomePage {
161
+ const match = content.match(/^---\n([\s\S]*?)\n---/);
162
+ if (!match) {
163
+ throw new Error("Invalid frontmatter format");
164
+ }
165
+ return yaml.parse(match[1]) as HomePage;
166
+ }
@@ -0,0 +1,75 @@
1
+ # Docs Index
2
+
3
+ ```ts twoslash
4
+ // @noErrors
5
+ import path from "path";
6
+
7
+ import alchemy, { Resource, Context } from "alchemy";
8
+
9
+ import { Zone } from "alchemy/cloudflare";
10
+
11
+ type alchemy = any;
12
+
13
+ await using app = alchemy("github:alchemy", {
14
+ // ^?
15
+ stage: "prod",
16
+ phase: process.argv.includes("--destroy") ? "destroy" : "up",
17
+ // pass the password in (you can get it from anywhere, e.g. stdin)
18
+ password: process.env.SECRET_PASSPHRASE,
19
+ quiet: process.argv.includes("--verbose") ? false : true,
20
+ });
21
+
22
+ export interface Product {}
23
+
24
+ export const Product = Resource(
25
+ "stripe::Product",
26
+ async function (
27
+ this: Context<any>,
28
+ id: string,
29
+ props: any,
30
+ ): Promise<Product> {
31
+ this.
32
+ // ^|
33
+ }
34
+ );
35
+ ```
36
+
37
+ ```ts twoslash
38
+ // @noErrors
39
+ // @esModuleInterop
40
+ import express from "express"
41
+ const app = {
42
+ get(path: string, fn: (req: any, res: { send(): void }))
43
+ }
44
+ app.get("/", function (req, res) {
45
+ res.sen
46
+ // ^|
47
+ })
48
+ app.listen(3000)
49
+ ```
50
+
51
+ ```ts twoslash
52
+ // @module: esnext
53
+ // @filename: maths.ts
54
+ export function absolute(num: number) {
55
+ if (num < 0) return num * -1;
56
+ return num;
57
+ }
58
+ // @filename: index.ts
59
+ import { absolute } from "./maths";
60
+ const value = absolute(-1);
61
+ ```
62
+
63
+ ```ts twoslash
64
+ // @module: esnext
65
+ // @filename: maths.ts
66
+ export function absolute(num: number) {
67
+ if (num < 0) return num * -1;
68
+ return num;
69
+ }
70
+ // @filename: index.ts
71
+ // ---cut---
72
+ import { absolute } from "./maths";
73
+ const value = absolute(-1);
74
+ // ^?
75
+ ```
@@ -0,0 +1,2 @@
1
+ export * from "./home-page";
2
+ export * from "./vitepress";