npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@thunderfat/backend-sdk

v0.0.2

Published

TypeScript SDK for ThunderFat Nutrition Management API

Readme

ThunderFat Backend SDK

TypeScript/JavaScript SDK for the ThunderFat Nutrition Management API (vv1.0.0).

Installation

npm install @thunderfat/backend-sdk

Quick Start

import { ThunderFatApi } from '@thunderfat/backend-sdk';

// Create API client
const api = new ThunderFatApi({
  BASE: 'https://your-api-domain.com',
  TOKEN: 'your-jwt-token'
});

// Example: Authentication
const authResult = await api.authApi.authenticate({
  username: 'your-username',
  password: 'your-password'
});

// Example: Get all patients
const patients = await api.pacienteApi.getAllPacientes();

// Example: Create a new patient
const newPatient = await api.pacienteApi.createPaciente({
  nombre: 'John',
  apellido: 'Doe',
  email: '[email protected]'
});

Configuration

Basic Configuration

const api = new ThunderFatApi({
  BASE: 'https://api.thunderfat.com/api/v1',
  TOKEN: 'your-jwt-token'
});

Advanced Configuration

const api = new ThunderFatApi({
  BASE: 'https://api.thunderfat.com/api/v1',
  TOKEN: 'your-jwt-token',
  TIMEOUT: 30000, // 30 seconds
  WITH_CREDENTIALS: true,
  HEADERS: {
    'Custom-Header': 'value'
  }
});

Environment-based Configuration

const config = {
  development: {
    BASE: 'http://localhost:8080/api/v1'
  },
  production: {
    BASE: 'https://api.thunderfat.com/api/v1'
  }
};

const api = new ThunderFatApi({
  ...config[process.env.NODE_ENV || 'development'],
  TOKEN: process.env.THUNDERFAT_TOKEN
});

API Services

This SDK provides the following API services:

  • AuthApi: Authentication and authorization
  • PacienteApi: Patient management
  • NutricionistaApi: Nutritionist management
  • PlanDietaApi: Diet plan management
  • AlimentoApi: Food database management
  • CitaApi: Appointment scheduling
  • ChatApi: Real-time messaging

Error Handling

try {
  const patient = await api.pacienteApi.getPacienteById(123);
} catch (error) {
  if (error.status === 404) {
    console.log('Patient not found');
  } else if (error.status === 401) {
    console.log('Authentication required');
  } else {
    console.log('Unexpected error:', error.message);
  }
}

TypeScript Support

This SDK is written in TypeScript and provides comprehensive type definitions:

import { PacienteDTO, CreatePacienteRequest } from '@thunderfat/backend-sdk';

const createPatient = async (data: CreatePacienteRequest): Promise<PacienteDTO> => {
  return await api.pacienteApi.createPaciente(data);
};

Pagination

Many endpoints support pagination:

const paginatedPatients = await api.pacienteApi.getAllPacientes({
  page: 0,
  size: 20,
  sort: 'nombre,asc'
});

console.log('Total patients:', paginatedPatients.totalElements);
console.log('Current page:', paginatedPatients.content);

Authentication Flow

// Login and get token
const authResult = await api.authApi.authenticate({
  username: 'your-username',
  password: 'your-password'
});

// Update API client with token
api.request.config.TOKEN = authResult.token;

// Now you can make authenticated requests
const profile = await api.authApi.getCurrentUserProfile();

Examples

Managing Patients

// Get all patients
const patients = await api.pacienteApi.getAllPacientes();

// Get patient by ID
const patient = await api.pacienteApi.getPacienteById(1);

// Create new patient
const newPatient = await api.pacienteApi.createPaciente({
  nombre: 'Jane',
  apellido: 'Smith',
  email: '[email protected]',
  telefono: '+1-555-0123'
});

// Update patient
const updatedPatient = await api.pacienteApi.updatePaciente(1, {
  telefono: '+1-555-9876'
});

Working with Diet Plans

// Get diet plans for a patient
const dietPlans = await api.planDietaApi.getPlanDietasByPacienteId(1);

// Create new diet plan
const newPlan = await api.planDietaApi.createPlanDieta({
  pacienteId: 1,
  nutricionistaId: 2,
  fechaInicio: '2025-01-01',
  fechaFin: '2025-03-31',
  objetivo: 'Weight loss'
});

Contributing

Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For support, please contact us at [email protected] or create an issue in our GitHub repository.