UNPKG

seia.js

Version:

Lightweight SSR framework for React Server Components

29 lines (28 loc) 1.02 kB
import process from 'node:process'; import { Flags } from '@oclif/core'; import { SeiaCommand } from '../command.js'; import { extendResolvedSeiaConfig, resolvedSeiaConfigSchema } from '../config.js'; import { serve } from '../server.js'; export default class Start extends SeiaCommand { static args = {}; static description = 'Starts SSR and RSC server. The project should be compiled with `seia build` first.'; static examples = [ '<%= config.bin %> <%= command.id %>' ]; static flags = { port: Flags.integer({ char: 'p', description: resolvedSeiaConfigSchema.shape.serve.removeDefault().shape.port.description }) }; async run() { const { flags: { port } } = await this.parse(Start); // HACK: Force server to run in production mode process.env.NODE_ENV = 'production'; await serve(extendResolvedSeiaConfig(this.resolvedConfig, { serve: { port } })); } }