efaturaefatura

Adapters

The package exposes optional HTTP adapters through subpath exports. They live in src/presentation and depend on the public Efatura facade.

Express

import express from 'express';
import { createEfatura } from '@akira-io/efatura';
import { efaturaRoutes } from '@akira-io/efatura/express';

const app = express();
const efatura = createEfatura(config, dependencies);

app.use('/efatura', efaturaRoutes(efatura));

Fastify

import Fastify from 'fastify';
import { createEfatura } from '@akira-io/efatura';
import { efaturaFastifyPlugin } from '@akira-io/efatura/fastify';

const fastify = Fastify();
const efatura = createEfatura(config, dependencies);

await fastify.register(efaturaFastifyPlugin, { efatura });

Nest

import { Module } from '@nestjs/common';
import { createEfatura } from '@akira-io/efatura';
import { EfaturaModule } from '@akira-io/efatura/nest';

@Module({
  imports: [EfaturaModule.forRoot({ efatura: createEfatura(config, dependencies) })],
})
export class AppModule {}

Routes

Adapters expose the same route set:

MethodPathPurpose
POST/dfe/xmlBuild DFE XML from invoice data and options
POST/event/xmlBuild official Event XML for FDC or UDN events
POST/dfe/zipBuild a ZIP payload from { iud, xml } files
POST/dfe/submit/middlewareSubmit a ZIP payload through the configured middleware transport
POST/dfe/validate/fiscal-readinessValidate local invoice rules plus optional PE/DNRE readiness checks
GET/dfa/:iudRender a DFA PDF for an IUD

Request payloads are validated with the shared Zod schemas documented in Validation And Zod.

Fiscal readiness accepts { invoice, options }. Without options.accessToken, external PE/DNRE checks return skipped; with a token, the configured fiscal authority clients validate taxpayers, registered software, and emitter authorization.