vite-elysia-forge 1.0.2 → 1.0.4

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/README.md CHANGED
@@ -18,7 +18,7 @@ bun install vite-elysia-forge
18
18
 
19
19
  ### 2.1 Create Your API Handler
20
20
 
21
- Place your Elysia handler at `src/server/api.ts` (default path):
21
+ Place your Elysia handler at `server/api.ts` (default path):
22
22
 
23
23
  ```ts
24
24
  import { Elysia } from "elysia";
@@ -43,7 +43,7 @@ import elysiaPlugin from "vite-elysia-forge";
43
43
  export default defineConfig({
44
44
  plugins: [
45
45
  elysiaPlugin({
46
- serverFile: "./src/server/api.ts",
46
+ serverFile: "./server/api.ts",
47
47
  }),
48
48
  ],
49
49
  });
@@ -126,7 +126,7 @@ To enable WebSocket support, set `ws: true`:
126
126
 
127
127
  ```ts
128
128
  elysiaPlugin({
129
- serverFile: "./src/server/api.ts",
129
+ serverFile: "./server/api.ts",
130
130
  ws: true, // Enable WebSocket support
131
131
  backendPort: 3001, // API runs on this port (default: 3001)
132
132
  });
@@ -144,7 +144,7 @@ This ensures full Bun runtime support for WebSockets, even if Vite itself runs u
144
144
 
145
145
  ### 5.2 Production
146
146
 
147
- In production, the built server (`dist/server.js` or the compiled binary) runs your Elysia app directly with full WebSocket support—no proxy needed.
147
+ In production, the built server (`build/server.js` or the compiled binary) runs your Elysia app directly with full WebSocket support—no proxy needed.
148
148
 
149
149
  ## 6. Integration with @elysiajs/openapi
150
150
 
@@ -176,139 +176,144 @@ const app = new Elysia().use(
176
176
 
177
177
  ## 7. Production Deployment
178
178
 
179
- The CLI provides several build commands to bundle your frontend and Elysia backend for production.
179
+ The CLI provides a `build` command for building your Elysia API server. Frontend assets should be built separately using Vite's standard build process (`vite build`).
180
180
 
181
- By default, the CLI looks for your API at `src/server/api.ts`. You can specify a custom path with the `--api` flag:
181
+ By default, the CLI looks for your API at `server/api.ts`. You can specify a custom path with the `--entry` flag.
182
+
183
+ ### 7.1 Frontend Build
184
+
185
+ Build your frontend using Vite directly:
182
186
 
183
187
  ```bash
184
- vite-elysia-forge build --api server/api.ts
188
+ vite build
189
+ ```
190
+
191
+ **Output:**
192
+
193
+ ```
194
+ dist/
195
+ ├── index.html
196
+ └── assets/
185
197
  ```
186
198
 
187
- ### 7.1 Standard Build (`build`)
199
+ Deploy to any static host (Cloudflare Pages, Netlify, Vercel, etc.)
188
200
 
189
- Builds the frontend with Vite and bundles the Elysia server into a single JavaScript file.
201
+ ### 7.2 Server Build (`--outDir`)
202
+
203
+ Build the Elysia API server into a standalone JavaScript bundle.
190
204
 
191
205
  ```bash
192
- vite-elysia-forge build
206
+ vite-elysia-forge build --outDir dist
193
207
  ```
194
208
 
195
209
  **What it does:**
196
210
 
197
- 1. Runs `vite build` to compile your frontend to `dist/`
198
- 2. Generates a production entry file that imports your API
199
- 3. Bundles the server into `dist/server.js`
211
+ 1. Generates a production entry file that imports your API
212
+ 2. Bundles the server into `dist/server.js`
200
213
 
201
214
  **package.json:**
202
215
 
203
216
  ```json
204
217
  {
205
218
  "scripts": {
206
- "build": "vite-elysia-forge build",
219
+ "build:server": "vite-elysia-forge build --outDir dist",
207
220
  "start": "bun dist/server.js"
208
221
  }
209
222
  }
210
223
  ```
211
224
 
212
- ### 7.2 Compiled Binary (`build-compile`)
225
+ **With custom entry and target:**
213
226
 
214
- Builds everything and compiles the server into a **standalone executable** (no Bun runtime required on the target machine).
227
+ ```bash
228
+ vite-elysia-forge build --entry src/my-api.ts --outDir .output --target node
229
+ ```
230
+
231
+ ### 7.3 Compiled Binary (`--outFile`)
232
+
233
+ Build and compile the server into a **standalone executable** (no Bun runtime required).
215
234
 
216
235
  ```bash
217
- vite-elysia-forge build-compile
236
+ vite-elysia-forge build --outFile server
218
237
  ```
219
238
 
220
239
  **What it does:**
221
240
 
222
- 1. Performs the standard build
223
- 2. Compiles `dist/server.js` into a native binary at `dist/server`
241
+ 1. Bundles the server code
242
+ 2. Compiles into a native binary at the specified path
224
243
 
225
244
  **package.json:**
226
245
 
227
246
  ```json
228
247
  {
229
248
  "scripts": {
230
- "build": "vite-elysia-forge build-compile",
249
+ "build:server": "vite-elysia-forge build --outFile dist/server",
231
250
  "start": "./dist/server"
232
251
  }
233
252
  }
234
253
  ```
235
254
 
236
- ### 7.3 Separate Outputs (`--static` / `--server`)
255
+ ### 7.4 CLI Reference
237
256
 
238
- Build the frontend and backend to **separate directories** for independent deployment (e.g., static assets to a CDN, server to a VPS).
257
+ **Command:**
239
258
 
240
259
  ```bash
241
- vite-elysia-forge build --static dist --server .output
242
- ```
243
-
244
- **Output structure:**
245
-
246
- ```
247
- project/
248
- ├── dist/ # Static assets (deploy to CDN)
249
- │ ├── index.html
250
- │ └── assets/
251
- └── .output/ # Server bundle (deploy to server)
252
- └── server.js
260
+ vite-elysia-forge build [options]
253
261
  ```
254
262
 
255
- **Use cases:**
263
+ **Options:**
256
264
 
257
- - Deploying static assets to Cloudflare Pages, Netlify, Vercel, etc.
258
- - Running the Elysia server on a separate VPS or Docker container
259
- - CI/CD pipelines that deploy frontend and backend independently
265
+ | Option | Short | Default | Description |
266
+ | :------------------ | :---: | :-------------- | :----------------------------------------- |
267
+ | `--entry <path>` | `-e` | `server/api.ts` | Path to API entry file |
268
+ | `--outDir <dir>` | `-d` | `dist` | Output directory for bundled `server.js` |
269
+ | `--outFile <file>` | `-o` | — | Output path for compiled standalone binary |
270
+ | `--target <target>` | `-t` | `bun` | Build target: `bun`, `node`, or `browser` |
271
+ | `--no-minify` | — | — | Disable minification |
260
272
 
261
- **package.json:**
262
-
263
- ```json
264
- {
265
- "scripts": {
266
- "build": "vite-elysia-forge build --static dist --server .output",
267
- "start": "bun .output/server.js"
268
- }
269
- }
270
- ```
273
+ > **Note:** `--outDir` and `--outFile` are mutually exclusive. Use `--outDir` for a bundled JS file, or `--outFile` for a compiled binary.
271
274
 
272
- Override the static assets path at runtime:
275
+ **Examples:**
273
276
 
274
277
  ```bash
275
- STATIC_DIR=/path/to/static bun .output/server.js
276
- ```
278
+ # Bundle server to dist/server.js
279
+ vite-elysia-forge build --outDir dist
277
280
 
278
- ### 7.4 Frontend Only (`build-static`)
281
+ # Bundle with node target
282
+ vite-elysia-forge build --outDir dist --target node
279
283
 
280
- Build only the frontend, skipping the server bundle.
284
+ # Compile to standalone binary
285
+ vite-elysia-forge build --outFile server
281
286
 
282
- ```bash
283
- vite-elysia-forge build-static
284
- ```
287
+ # Compile with custom entry
288
+ vite-elysia-forge build --entry src/api/index.ts --outFile myserver
285
289
 
286
- Useful for rebuilding just the frontend without touching the server.
290
+ # Bundle without minification
291
+ vite-elysia-forge build --outDir dist --no-minify
292
+ ```
287
293
 
288
- ### 7.5 Server Only (`build-server`)
294
+ ### 7.5 Deployment Architecture
289
295
 
290
- Build only the server bundle, skipping the Vite frontend build.
296
+ **Separate deployment (recommended):**
291
297
 
292
- ```bash
293
- vite-elysia-forge build-server --server .output --static dist
298
+ ```
299
+ ┌─────────────────┐ ┌──────────────────┐
300
+ │ Static Host │ │ API Server │
301
+ │ (CDN/Pages) │◄────────┤ (VPS/Cloud) │
302
+ │ │ CORS │ │
303
+ │ dist/ │ │ dist/server.js │
304
+ └─────────────────┘ └──────────────────┘
294
305
  ```
295
306
 
296
- Useful when the frontend is already built or deployed separately.
297
-
298
- ### 7.6 CLI Reference
307
+ - Frontend: Build with `vite build` and deploy to Cloudflare Pages, Netlify, Vercel, etc.
308
+ - Backend: Build with `vite-elysia-forge build --outDir dist` and deploy to any server with Bun installed, or use the compiled binary
299
309
 
300
- | Option | Short | Default | Description |
301
- | :--------------- | :---: | :------------------ | :------------------------------------------ |
302
- | `--api <path>` | `-a` | `src/server/api.ts` | Path to API entry file |
303
- | `--static <dir>` | `-s` | `dist` | Output directory for static frontend assets |
304
- | `--server <dir>` | `-o` | Same as `--static` | Output directory for server bundle |
305
- | `--skip-vite` | | `false` | Skip the Vite frontend build |
306
- | `--skip-server` | | `false` | Skip the server build |
310
+ **API-only deployment:**
307
311
 
308
- **Example with custom API path:**
312
+ If you have no frontend, just build and deploy the server:
309
313
 
310
314
  ```bash
311
- vite-elysia-forge build --api src/my-api.ts
315
+ vite-elysia-forge build --outDir dist
316
+ bun dist/server.js
312
317
  ```
313
318
 
314
319
  ## 8. Troubleshooting
@@ -349,7 +354,7 @@ If you see `Current adapter doesn't support WebSocket`, you need to enable WS mo
349
354
 
350
355
  ```ts
351
356
  elysiaPlugin({
352
- serverFile: "./src/server/api.ts",
357
+ serverFile: "./server/api.ts",
353
358
  ws: true,
354
359
  });
355
360
  ```
package/dist/cli.d.ts CHANGED
@@ -1,39 +1,38 @@
1
1
  #!/usr/bin/env bun
2
2
  /**
3
- * Build options for customizing output directories.
3
+ * Bun build target options.
4
+ */
5
+ type BuildTarget = "bun" | "node" | "browser";
6
+ /**
7
+ * Build options for the server bundle.
4
8
  */
5
9
  interface BuildOptions {
6
10
  /**
7
11
  * Path to the API entry file.
8
- * @default "src/server/api.ts"
12
+ * @default "server/api.ts"
9
13
  */
10
- apiEntry?: string;
14
+ entry?: string;
11
15
  /**
12
- * Output directory for the Vite/frontend static assets.
13
- * @default "dist"
16
+ * Output directory for the server bundle (used with --outDir).
17
+ * Mutually exclusive with outFile.
14
18
  */
15
- staticDir?: string;
19
+ outDir?: string;
16
20
  /**
17
- * Output directory for the Elysia server bundle.
18
- * When set to a different value than staticDir, the server and static assets
19
- * will be built to separate directories.
20
- * @default "dist" (same as staticDir)
21
+ * Output file path for compiled standalone binary (used with --outFile).
22
+ * Mutually exclusive with outDir.
21
23
  */
22
- serverDir?: string;
24
+ outFile?: string;
23
25
  /**
24
- * Whether to skip the Vite frontend build.
25
- * Useful when you only want to rebuild the server.
26
- * @default false
26
+ * Build target for Bun.build.
27
+ * @default "bun"
27
28
  */
28
- skipVite?: boolean;
29
+ target?: BuildTarget;
29
30
  /**
30
- * Whether to skip the server build.
31
- * Useful when you only want to rebuild the frontend.
32
- * @default false
31
+ * Whether to minify the output.
32
+ * @default true
33
33
  */
34
- skipServer?: boolean;
34
+ minify?: boolean;
35
35
  }
36
- declare function build(options?: BuildOptions | string): Promise<void>;
37
- declare function buildCompile(options?: BuildOptions | string): Promise<void>;
36
+ declare function build(options?: BuildOptions): Promise<void>;
38
37
 
39
- export { type BuildOptions, build, buildCompile };
38
+ export { type BuildOptions, type BuildTarget, build };
package/dist/cli.js CHANGED
@@ -1,13 +1,15 @@
1
1
  #!/usr/bin/env bun
2
- import {spawnSync}from'child_process';import {existsSync,mkdirSync,writeFileSync,unlinkSync,rmSync}from'fs';import {resolve,relative,sep}from'path';async function v(r={}){let s=typeof r=="string"?{apiEntry:r}:r,t=s.apiEntry||"src/server/api.ts",e=s.staticDir||"dist",o=s.serverDir||e,u=s.skipVite||false,y=s.skipServer||false,b=e!==o,m=resolve(process.cwd(),t);if(!y&&!existsSync(m)&&(console.error(`\u274C API entry file "${t}" not found.`),console.error(' By default, vite-elysia-forge looks for "src/server/api.ts".'),console.error(" If your API is located elsewhere, please specify the path:"),console.error(" $ vite-elysia-forge build --api <path-to-your-api-file>"),process.exit(1)),!u){console.log(`\u{1F4E6} Building frontend to "${e}"...`);let i=spawnSync("bun",["x","vite","build","--outDir",e],{stdio:"inherit",env:{...process.env,NODE_ENV:"production"}});i.status!==0&&(console.error("\u274C Vite build failed"),process.exit(i.status||1)),console.log(`\u2705 Frontend built to "${e}"`);}if(y){console.log("\u23ED\uFE0F Skipping server build (--skip-server)");return}let c=resolve(process.cwd(),".output");existsSync(c)||mkdirSync(c,{recursive:true});let d=resolve(c,".temp-prod.ts"),a=relative(c,m);a=a.split(sep).join("/"),a.startsWith(".")||(a="./"+a);let n;if(b){let i=resolve(process.cwd(),o),g=resolve(process.cwd(),e);n=relative(i,g),n.startsWith(".")||(n="./"+n),n=n.split(sep).join("/");}else n=".";let O=`
3
- import { startServer } from "vite-elysia-forge/production";
4
- import { api } from ${JSON.stringify(a)};
2
+ import {spawnSync}from'child_process';import {existsSync,mkdirSync,writeFileSync,unlinkSync,rmSync}from'fs';import {resolve,relative,sep,dirname}from'path';async function w(t={}){let o=t.entry||"server/api.ts",r=t.target||"bun",n=t.minify!==false,e=resolve(process.cwd(),o);existsSync(e)||(console.error(`\u274C API entry file "${o}" not found.`),console.error(' By default, vite-elysia-forge looks for "server/api.ts".'),console.error(" If your API is located elsewhere, please specify the path:"),console.error(" $ vite-elysia-forge build --entry <path-to-your-api-file>"),process.exit(1));let s=resolve(process.cwd(),".vef-temp");existsSync(s)||mkdirSync(s,{recursive:true});let i=resolve(s,".temp-prod.ts"),l=relative(s,e);l=l.split(sep).join("/"),l.startsWith(".")||(l="./"+l);let p=`
3
+ import { Elysia } from "elysia";
4
+ import { api } from ${JSON.stringify(l)};
5
5
 
6
- startServer({
7
- api,
8
- port: process.env.PORT ? parseInt(process.env.PORT) : 3000,
9
- distDir: process.env.STATIC_DIR || ${JSON.stringify(n)},
10
- });
11
- `;writeFileSync(d,O);let h=resolve(process.cwd(),o);existsSync(h)||mkdirSync(h,{recursive:true}),console.log(`\u{1F4E6} Building server to "${o}"...`);try{let i=await Bun.build({entrypoints:[d],outdir:o,target:"bun",minify:!0,naming:"server.js"});if(!i.success){console.error("\u274C Server build failed");for(let g of i.logs)console.error(g);process.exit(1);}console.log(`\u2705 Server built to "${o}/server.js"`);}catch(i){console.error("\u274C Failed to build server. Ensure you are running this command with Bun."),console.error(i),process.exit(1);}finally{existsSync(d)&&unlinkSync(d),existsSync(c)&&rmSync(c,{recursive:true,force:true});}b&&(console.log(`
12
- \u{1F4C1} Output structure:`),console.log(` Static assets: ${e}/`),console.log(` Server bundle: ${o}/server.js`),console.log(`
13
- \u{1F4A1} To run: cd ${o} && bun server.js`),console.log(" Or set STATIC_DIR to override the static assets path"));}async function x(r={}){let s=typeof r=="string"?{apiEntry:r}:r,t=s.serverDir||s.staticDir||"dist";await v(s),console.log("\u{1F527} Compiling server to standalone binary...");let e=resolve(process.cwd(),t,"server.js"),o=resolve(process.cwd(),t,"server"),u=spawnSync("bun",["build","--compile",e,"--outfile",o],{stdio:"inherit",env:{...process.env,NODE_ENV:"production"}});u.status!==0&&(console.error("\u274C Bun compile failed"),process.exit(u.status||1)),console.log(`\u2705 Compiled standalone binary: ${t}/server`);}function f(r){let s={};for(let t=0;t<r.length;t++){let e=r[t],o=r[t+1];switch(e){case "--api":case "-a":o&&!o.startsWith("-")&&(s.apiEntry=o,t++);break;case "--static":case "-s":o&&!o.startsWith("-")&&(s.staticDir=o,t++);break;case "--server":case "-o":o&&!o.startsWith("-")&&(s.serverDir=o,t++);break;case "--skip-vite":s.skipVite=true;break;case "--skip-server":s.skipServer=true;break;default:e&&!e.startsWith("-")&&!s.apiEntry&&(s.apiEntry=e);}}return s}if(import.meta.main){let r=process.argv.slice(2),s=r[0],t=r.slice(1);if(s==="build"){let e=f(t);v(e);}else if(s==="build-compile"){let e=f(t);x(e);}else if(s==="build-static"){let e=f(t);e.skipServer=true,v(e);}else if(s==="build-server"){let e=f(t);e.skipVite=true,v(e);}else console.log("Usage: vite-elysia-forge <command> [options]"),console.log(""),console.log("Commands:"),console.log(" build Build frontend + bundle server"),console.log(" build-compile Build and compile a standalone server binary"),console.log(" build-static Build only the frontend (skip server)"),console.log(" build-server Build only the server (skip frontend)"),console.log(""),console.log("Options:"),console.log(" --api, -a <path> Path to API entry file (default: src/server/api.ts)"),console.log(" --static, -s <dir> Output directory for static assets (default: dist)"),console.log(" --server, -o <dir> Output directory for server bundle (default: same as --static)"),console.log(" --skip-vite Skip the Vite frontend build"),console.log(" --skip-server Skip the server build"),console.log(""),console.log("Examples:"),console.log(" # Build everything to 'dist/' (default)"),console.log(" vite-elysia-forge build"),console.log(""),console.log(" # Build with separate output directories"),console.log(" vite-elysia-forge build --static dist --server .output"),console.log(""),console.log(" # Build only the frontend"),console.log(" vite-elysia-forge build-static --static public"),console.log(""),console.log(" # Build only the server to a separate folder"),console.log(" vite-elysia-forge build-server --server .output --static dist");}export{v as build,x as buildCompile};
6
+ const app = new Elysia();
7
+ if (api) app.use(api);
8
+
9
+ const port = process.env.PORT ? parseInt(process.env.PORT) : 3000;
10
+ app.listen(port);
11
+
12
+ console.log(\`Production server running at http://\${app?.server?.hostname}:\${app?.server?.port}\`);
13
+ `;writeFileSync(i,p);try{if(t.outFile)await D(i,t.outFile,r,n);else {let u=t.outDir||"dist";await x(i,u,r,n);}}finally{existsSync(i)&&unlinkSync(i),existsSync(s)&&rmSync(s,{recursive:true,force:true});}}async function x(t,o,r,n){let e=resolve(process.cwd(),o);existsSync(e)||mkdirSync(e,{recursive:true}),console.log(`\u{1F4E6} Building server to "${o}/" (target: ${r})...`);try{let s=await Bun.build({entrypoints:[t],outdir:e,target:r,minify:n,naming:"server.js"});if(!s.success){console.error("\u274C Server build failed");for(let i of s.logs)console.error(i);process.exit(1);}console.log(`\u2705 Server built to "${o}/server.js"`),console.log(`
14
+ \u{1F4A1} To run: bun ${o}/server.js`);}catch(s){console.error("\u274C Failed to build server. Ensure you are running this command with Bun."),console.error(s),process.exit(1);}}async function D(t,o,r,n){let e=resolve(process.cwd(),o),s=dirname(e);existsSync(s)||mkdirSync(s,{recursive:true});let i=resolve(process.cwd(),".vef-temp-bundle");existsSync(i)||mkdirSync(i,{recursive:true}),console.log(`\u{1F4E6} Building and compiling server to "${o}" (target: ${r})...`);try{let l=await Bun.build({entrypoints:[t],outdir:i,target:r,minify:n,naming:"server.js"});if(!l.success){console.error("\u274C Server build failed");for(let f of l.logs)console.error(f);process.exit(1);}let p=resolve(i,"server.js"),u=spawnSync("bun",["build","--compile",p,"--outfile",e],{stdio:"inherit",env:{...process.env,NODE_ENV:"production"}});u.status!==0&&(console.error("\u274C Bun compile failed"),process.exit(u.status||1)),console.log(`\u2705 Compiled standalone binary: ${o}`),console.log(`
15
+ \u{1F4A1} To run: ./${o}`);}catch(l){console.error("\u274C Failed to compile server. Ensure you are running this command with Bun."),console.error(l),process.exit(1);}finally{existsSync(i)&&rmSync(i,{recursive:true,force:true});}}function O(t){let o={};for(let r=0;r<t.length;r++){let n=t[r],e=t[r+1];switch(n){case "--entry":case "-e":e&&!e.startsWith("-")&&(o.entry=e,r++);break;case "--outDir":case "-d":e&&!e.startsWith("-")&&(o.outDir=e,r++);break;case "--outFile":case "-o":e&&!e.startsWith("-")&&(o.outFile=e,r++);break;case "--target":case "-t":e&&!e.startsWith("-")&&(o.target=e,r++);break;case "--no-minify":o.minify=false;break}}return o}if(import.meta.main){let t=process.argv.slice(2),o=t[0],r=t.slice(1);if(o==="build"){let n=O(r);n.outDir&&n.outFile&&(console.error("\u274C Cannot use both --outDir and --outFile. Choose one."),process.exit(1)),w(n);}else console.log("Usage: vite-elysia-forge build [options]"),console.log(""),console.log("Build the Elysia server for production."),console.log(""),console.log("Options:"),console.log(" --entry, -e <path> Path to API entry file (default: server/api.ts)"),console.log(" --outDir, -d <dir> Output directory for bundled server.js"),console.log(" --outFile, -o <file> Output path for compiled standalone binary"),console.log(" --target, -t <target> Build target: bun, node, browser (default: bun)"),console.log(" --no-minify Disable minification"),console.log(""),console.log("Examples:"),console.log(" # Bundle server to dist/server.js"),console.log(" vite-elysia-forge build --outDir dist"),console.log(""),console.log(" # Bundle with node target"),console.log(" vite-elysia-forge build --outDir dist --target node"),console.log(""),console.log(" # Compile to standalone binary"),console.log(" vite-elysia-forge build --outFile server"),console.log(""),console.log(" # Compile with custom entry"),console.log(" vite-elysia-forge build --entry src/api/index.ts --outFile myserver");}export{w as build};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-elysia-forge",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "A Vite plugin to seamlessly integrate ElysiaJS for full-stack development with Bun runtime.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -36,10 +36,6 @@
36
36
  "types": "./dist/index.d.ts",
37
37
  "import": "./dist/index.js",
38
38
  "require": "./dist/index.cjs"
39
- },
40
- "./production": {
41
- "types": "./dist/production.d.ts",
42
- "import": "./dist/production.js"
43
39
  }
44
40
  },
45
41
  "files": [
@@ -1,43 +0,0 @@
1
- /**
2
- * Options for starting the production server.
3
- */
4
- interface ProductionOptions {
5
- /**
6
- * The port to listen on.
7
- * @default 3000
8
- */
9
- port?: number;
10
- /**
11
- * The directory containing the built frontend assets.
12
- * @default "dist"
13
- */
14
- distDir?: string;
15
- /**
16
- * The name of the HTML entry file.
17
- * @default "index.html"
18
- */
19
- htmlFile?: string;
20
- /**
21
- * The prefix for API routes. Requests starting with this prefix will be handled by the Elysia app.
22
- * @default "/api"
23
- */
24
- apiPrefix?: string;
25
- /**
26
- * The Elysia app instance or an object with a `handle` method.
27
- */
28
- api: {
29
- handle: (request: Request) => Promise<Response>;
30
- } | any;
31
- }
32
- /**
33
- * Starts a production server using Bun.serve.
34
- *
35
- * This function serves the static frontend assets from the distribution directory
36
- * and handles API requests using the provided Elysia app instance.
37
- *
38
- * @param options - Configuration options for the production server.
39
- * @throws {Error} If not running in a Bun environment.
40
- */
41
- declare const startServer: (options: ProductionOptions) => void;
42
-
43
- export { type ProductionOptions, startServer };