Skip to content

Commit c8e1c63

Browse files
authored
manually run format
1 parent a51c76c commit c8e1c63

File tree

3 files changed

+47
-47
lines changed

3 files changed

+47
-47
lines changed

package/src/index.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,21 @@ export function getAdapter(args: InternalOptions): AstroAdapter {
2929

3030
export default (options?: Options): AstroIntegration => {
3131
if (options) {
32-
if (options.cluster && typeof options.cluster !== "boolean") {
33-
throw new Error(`[${packageName}] options.cluster must be a boolean, but the adapter was provided with ${options.cluster} instead.`)
32+
if (options.cluster && typeof options.cluster !== 'boolean') {
33+
throw new Error(
34+
`[${packageName}] options.cluster must be a boolean, but the adapter was provided with ${options.cluster} instead.`,
35+
);
3436
}
35-
if (options.unix && typeof options.unix !== "string") {
36-
throw new Error(`[${packageName}] options.unix must be a string, but the adapter was provided with ${options.unix} instead.`)
37+
if (options.unix && typeof options.unix !== 'string') {
38+
throw new Error(
39+
`[${packageName}] options.unix must be a string, but the adapter was provided with ${options.unix} instead.`,
40+
);
3741
}
3842
}
3943
return {
4044
name: packageName,
4145
hooks: {
42-
'astro:config:done': params => {
46+
'astro:config:done': (params) => {
4347
params.setAdapter(
4448
getAdapter({
4549
cluster: options?.cluster,
@@ -53,5 +57,5 @@ export default (options?: Options): AstroIntegration => {
5357
);
5458
},
5559
},
56-
}
57-
}
60+
};
61+
};

package/src/server/index.ts

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import type { Server } from 'bun';
1212

1313
import type { CreateExports, InternalOptions } from '~/types.ts';
1414

15-
export function createExports(manifest: SSRManifest, options: InternalOptions): CreateExports {
15+
export function createExports(
16+
manifest: SSRManifest,
17+
options: InternalOptions,
18+
): CreateExports {
1619
return {
1720
handle: handler(manifest, options),
1821
running: () => _server !== null,
@@ -29,7 +32,7 @@ let _server: Server | null = null;
2932
export function start(manifest: SSRManifest, options: InternalOptions): void {
3033
const hostname = process.env.HOST ?? extractHostname(options.host);
3134
const port = process.env.PORT ? Number.parseInt(process.env.PORT) : options.port;
32-
const unix = process.env.UNIX ?? options.unix
35+
const unix = process.env.UNIX ?? options.unix;
3336

3437
if (cluster.isPrimary && options.cluster) {
3538
const numCPUs = os.cpus().length;
@@ -44,27 +47,21 @@ export function start(manifest: SSRManifest, options: InternalOptions): void {
4447
const app = new App(manifest);
4548
const logger = app.getAdapterLogger();
4649

47-
if (unix) {
48-
_server = Bun.serve({
49-
error: (error) =>
50-
new Response(`<pre>${error}\n${error.stack}</pre>`, {
51-
headers: { 'Content-Type': 'text/html' },
52-
}),
53-
fetch: handler(manifest, options),
54-
unix,
55-
});
56-
}
57-
else {
58-
_server = Bun.serve({
59-
error: (error) =>
60-
new Response(`<pre>${error}\n${error.stack}</pre>`, {
61-
headers: { 'Content-Type': 'text/html' },
50+
_server = Bun.serve({
51+
error: (error) =>
52+
new Response(`<pre>${error}\n${error.stack}</pre>`, {
53+
headers: { 'Content-Type': 'text/html' },
54+
}),
55+
fetch: handler(manifest, options),
56+
...(unix
57+
? {
58+
unix,
59+
}
60+
: {
61+
hostname,
62+
port,
6263
}),
63-
fetch: handler(manifest, options),
64-
hostname,
65-
port,
66-
});
67-
}
64+
});
6865

6966
function exit(): void {
7067
if (_server) _server.stop();

package/src/types.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,35 @@ export interface Options {
77
/**
88
* Create a cluster of bun servers listening on the same port,
99
* and automatically load-balance incoming requests across them.
10-
*
10+
*
1111
* Example:
1212
* ```ts
1313
* export default defineConfig({
1414
* adapter: bun({ cluster: true })
1515
* })
1616
* ```
17-
*
17+
*
1818
* Defaults to `false`
1919
*/
20-
cluster?: boolean
20+
cluster?: boolean;
2121
/**
2222
* The path to the unix socket on which to host the server.
23-
*
23+
*
2424
* This can provide better performance when Bun is running alongside
2525
* a local reverse proxy that supports unix sockets.
26-
*
26+
*
2727
* When a unix socket is provided, Bun does not bind to a TCP port,
2828
* and the options and environment variables for the hostname and port
2929
* are ignored.
30-
*
30+
*
3131
* Example:
3232
* ```ts
3333
* export default defineConfig({
3434
* adapter: bun({ unix: "/tmp/my-socket.sock" })
3535
* })
3636
* ```
3737
*/
38-
unix?: string
38+
unix?: string;
3939
}
4040

4141
// options provided by the user combined with other
@@ -44,43 +44,42 @@ export interface InternalOptions extends Options {
4444
/**
4545
* Name of the publicly exposed directory where all
4646
* static assets are put.
47-
*
47+
*
4848
* Astro defaults to `"_astro"`.
4949
*/
50-
assets: AstroConfig["build"]["assets"],
50+
assets: AstroConfig['build']['assets'];
5151
/**
5252
* The full file URL to where astro is configured to put
5353
* the client bundle and assets such as images, fonts,
5454
* stylesheets, and static html.
55-
*
55+
*
5656
* Astro defaults to `"<project root>/dist/client/"`.
5757
*/
58-
client: AstroConfig["build"]["server"]["href"],
58+
client: AstroConfig['build']['server']['href'];
5959
/**
6060
* The full file URL to where astro is configured to put
6161
* the server bundle.
62-
*
62+
*
6363
* Astro defaults to `"<project root>/dist/server/""`.
6464
*/
65-
server: AstroConfig["build"]["server"]["href"],
65+
server: AstroConfig['build']['server']['href'];
6666
/**
6767
* Network address where the astro dev server is
6868
* configured to listen for requests in addition to
6969
* `localhost`.
70-
*
70+
*
7171
* Astro defaults to `false`.
7272
*/
73-
host: AstroConfig["server"]["host"],
73+
host: AstroConfig['server']['host'];
7474
/**
7575
* Network port where the astro dev server is
7676
* configured to listen for requests.
77-
*
77+
*
7878
* Astro default to `4321`.
7979
*/
80-
port: AstroConfig["server"]["port"],
80+
port: AstroConfig['server']['port'];
8181
}
8282

83-
8483
export enum CreateExportsEnum {
8584
HANDLE = 'handle',
8685
RUNNING = 'running',

0 commit comments

Comments
 (0)