UNPKG

@das3mical/adonis-mercure

Version:

Mercure Hub integration for AdonisJS v6 — publish real-time updates via Server-Sent Events (SSE)

35 lines (34 loc) 1.34 kB
/* |-------------------------------------------------------------------------- | Configure hook |-------------------------------------------------------------------------- | | The configure hook is called when someone runs "node ace configure <package>" | command. You are free to perform any operations inside this function to | configure the package. | | To make things easier, you have access to the underlying "ConfigureCommand" | instance and you can use codemods to modify the source files. | */ import { stubsRoot } from './stubs/main.js'; export async function configure(_command) { const codemods = await _command.createCodemods(); await codemods.makeUsingStub(stubsRoot, 'config/mercure.stub', {}); await codemods.defineEnvVariables({ MERCURE_ENDPOINT: 'http://localhost:3000/.well-known/mercure', MERCURE_ADMIN_JWT: '', MERCURE_JWT_SECRET: '', }); await codemods.defineEnvValidations({ variables: { MERCURE_ENDPOINT: `Env.schema.string({ format: 'url' })`, MERCURE_ADMIN_JWT: `Env.schema.string()`, MERCURE_JWT_SECRET: `Env.schema.string()`, }, leadingComment: 'Mercure configuration', }); await codemods.updateRcFile((rcFile) => { rcFile.addProvider('@das3mical/adonis-mercure/mercure_provider'); }); }