mirror of
https://github.com/withastro/astro.git
synced 2024-12-23 21:53:55 -05:00
b8c6dabfb7
* enabling eslint on the all packages and tests * enabling for all packages * TEMP: adding an only() test to verify it fails CI * using our eslint config and ignore in CI * removing the temporary .only() test * update lock file * lint: fixing new test with a no-shadow warning * chore: update lock file |
||
---|---|---|
.. | ||
src | ||
test | ||
CHANGELOG.md | ||
package.json | ||
readme.md | ||
tsconfig.json |
@astrojs/deno
A server-side rendering adapter for use with Deno targets. Write your code in Astro/Node and deploy to Deno servers.
In your astro.config.mjs use:
import { defineConfig } from 'astro/config';
import deno from '@astrojs/deno';
export default defineConfig({
adapter: deno()
});
After performing a build there will be a dist/server/entry.mjs
module. You can start a server simply by importing this module:
import './dist/entry.mjs';
API
Adapter options
This adapter automatically starts a server when it is imported. You can configure this through options:
import { defineConfig } from 'astro/config';
import deno from '@astrojs/deno';
export default defineConfig({
adapter: deno({
start: false
})
});
If disabling start you need to write your own web server and use handle
to render requests:
import { serve } from "https://deno.land/std@0.132.0/http/server.ts";
import { handle } from './dist/entry.mjs';
serve((req: Request) => {
// Check the request, maybe do static file handling here.
return handle(req);
});
You an also pass in a port/hostname to use:
import { defineConfig } from 'astro/config';
import deno from '@astrojs/deno';
export default defineConfig({
adapter: deno({
port: 8081,
hostname: 'myhost'
})
});