New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

astro-adapter-fastify

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

astro-adapter-fastify

Deploy your Astro site to a Fastify server

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

astro-adapter-fastify

An experimental server-side rendering adapter for use with Fastify servers.

In your astro.config.mjs use:

import { defineConfig } from 'astro/config';
import fastify from 'astro-adapter-fastify';

export default defineConfig({
  adapter: fastify()
});

After performing a build there will be a dist/server/entry.mjs module that works like a handler function. For example, you can do:

import path from 'path';
import Fastify from 'fastify';
import { handler as ssrHandler } from '../dist/server/entry.mjs';

const server = Fastify({});

const start = async () => {
  try {
    server.register(
      import('@fastify/static'),
      {
        root: path.resolve('./dist/client'),
      },
    );
    server.get('/', ssrHandler);
    await server.listen(3000)
  } catch (err) {
    server.log.error(err)
    process.exit(1)
  }
};
start();

Keywords

astro

FAQs

Package last updated on 17 May 2022

Related posts