UNPKG

@spotable/attio-sdk

Version:
41 lines (32 loc) 1.08 kB
import { writeGeneratedFile } from "../helpers/fs"; import { generateFileHeader } from "./types/fileHeader"; const SERVICE_FILE_NAME = "attio.service.ts"; const MODULE_FILE_NAME = "attio.module.ts"; export function generateNestjsFiles(outputDir: string): void { const serviceContent = `${generateFileHeader(SERVICE_FILE_NAME)} import { Injectable } from "@nestjs/common"; import { AttioClient } from "./attioClient"; @Injectable() export class AttioService extends AttioClient { constructor() { if (!process.env.ATTIO_API_KEY) { throw new Error("ATTIO_API_KEY environment variable is not set"); } super({ apiKey: process.env.ATTIO_API_KEY, }); } } `; writeGeneratedFile(outputDir, SERVICE_FILE_NAME, serviceContent); const moduleContent = `${generateFileHeader(MODULE_FILE_NAME)} import { Module } from "@nestjs/common"; import { AttioService } from "./attio.service"; @Module({ providers: [AttioService], exports: [AttioService], }) export class AttioModule {} `; writeGeneratedFile(outputDir, MODULE_FILE_NAME, moduleContent); }