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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@zentrax/sdk

v0.2.0

Published

SDK Node.js/TypeScript oficial para a API v1 do Zentrax

Downloads

409

Readme

@zentrax/sdk

SDK Node.js/TypeScript não-oficial para a API v1 do Zentrax (/v1/apps, /v1/databases, /v1/account).

  • ✅ 100% TypeScript, com tipos completos para todas as respostas
  • ✅ Zero dependências em runtime (usa fetch nativo — Node.js 18+)
  • ✅ Suporte a CJS e ESM
  • ✅ Erros tipados (ZentraxAuthError, ZentraxNotFoundError, ZentraxValidationError, ...)

Instalação

npm install @zentrax/sdk

Uso básico

import { ZentraxSDK } from '@zentrax/sdk';

const zentrax = new ZentraxSDK({
  apiToken: process.env.ZENTRAX_API_TOKEN!,
  // baseUrl: 'https://api.myzentrax.lat', // opcional, esse é o padrão
});

const apps = await zentrax.apps.list();
console.log(apps);

Configuração do cliente

new ZentraxSDK({
  apiToken: 'seu-token',   // obrigatório
  baseUrl: 'https://...',  // opcional
  timeoutMs: 30_000,       // opcional, padrão 30s
  headers: {},             // opcional, headers extras
  fetch: customFetch,      // opcional, para ambientes sem fetch global
});

Recursos disponíveis

zentrax.apps

| Método | Rota | Descrição | |---|---|---| | apps.list() | GET /v1/apps | Lista todas as aplicações | | apps.get(appId) | GET /v1/apps/:id | Detalhes de uma aplicação | | apps.stats(appId) | GET /v1/apps/:id/stats | Uso de CPU/RAM/rede | | apps.logs(appId, { tail }) | GET /v1/apps/:id/logs | Últimas linhas de log | | apps.start(appId) | POST /v1/apps/:id/start | Inicia a aplicação | | apps.stop(appId) | POST /v1/apps/:id/stop | Para a aplicação | | apps.restart(appId) | POST /v1/apps/:id/restart | Reinicia a aplicação | | apps.delete(appId) | POST /v1/apps/:id/delete | Remove a aplicação | | apps.rebuild(appId) | POST /v1/apps/:id/rebuild | Reconstrói a imagem | | apps.backup(appId) | POST /v1/apps/:id/backup | Gera e baixa um backup .zip (retorna Buffer) | | apps.commit(appId, zip) | POST /v1/apps/:id/commit | Substitui o código por um novo .zip | | apps.upload(zip, opts) | POST /v1/apps/upload | Cria uma aplicação a partir de um .zip | | apps.listFiles(appId, path?) | GET /v1/apps/:id/files | Lista arquivos/diretórios | | apps.readFile(appId, path) | GET /v1/apps/:id/files/content | Lê conteúdo de um arquivo | | apps.writeFile(appId, path, content) | PUT /v1/apps/:id/files/content | Escreve conteúdo (máx 2 MB) | | apps.renameFile(appId, oldPath, newPath) | PUT /v1/apps/:id/files/rename | Renomeia/move | | apps.createFolder(appId, path) | POST /v1/apps/:id/files/mkdir | Cria diretório | | apps.deleteFile(appId, path) | POST /v1/apps/:id/files/delete | Remove arquivo/diretório |

zentrax.databases

| Método | Rota | Descrição | |---|---|---| | databases.create(params) | POST /v1/databases | Cria uma database | | databases.list() | GET /v1/databases | Lista databases | | databases.get(id) | GET /v1/databases/:id | Detalhes + credenciais | | databases.delete(id) | DELETE /v1/databases/:id | Remove a database | | databases.start(id) | POST /v1/databases/:id/start | Inicia | | databases.stop(id) | POST /v1/databases/:id/stop | Para | | databases.restart(id) | POST /v1/databases/:id/restart | Reinicia | | databases.logs(id, { tail }) | GET /v1/databases/:id/logs | Logs | | databases.stats(id) | GET /v1/databases/:id/stats | Uso de recursos |

zentrax.account

| Método | Rota | Descrição | |---|---|---| | account.get() | GET /v1/account | Usuário, plano e aplicações |

Exemplos

Criar e acompanhar uma database

const db = await zentrax.databases.create({
  name: 'meu-banco',
  engine: 'postgresql',
  memoryMb: 256,
});

console.log(db.connectionString);

const stats = await zentrax.databases.stats(db.id);
console.log(stats);

Deploy de uma aplicação a partir de um zip local

import { readFile } from 'node:fs/promises';

const zipBuffer = await readFile('./meu-app.zip');

const result = await zentrax.apps.upload(zipBuffer, {
  appName: 'minha-api',
  language: 'node',
  command: 'node index.js',
  memory: 512,
}, 'meu-app.zip');

console.log(result.appId, result.status);

Editar um arquivo remoto

await zentrax.apps.writeFile(appId, '/app/src/config.json', JSON.stringify({ foo: 'bar' }));

Tratamento de erros

import { ZentraxNotFoundError, ZentraxApiError } from '@zentrax/sdk';

try {
  await zentrax.apps.get('id-invalido');
} catch (err) {
  if (err instanceof ZentraxNotFoundError) {
    console.log('Aplicação não encontrada');
  } else if (err instanceof ZentraxApiError) {
    console.log('Erro da API:', err.status, err.body);
  } else {
    throw err;
  }
}

Estrutura do projeto

src/
  client.ts           -> classe ZentraxSDK (ponto de entrada)
  http-client.ts       -> cliente HTTP interno (fetch, auth, erros)
  errors.ts            -> classes de erro tipadas
  resources/
    apps.ts             -> recurso `zentrax.apps`
    databases.ts         -> recurso `zentrax.databases`
    account.ts           -> recurso `zentrax.account`
  types/
    apps.ts, databases.ts, account.ts -> tipos de request/response
  index.ts              -> exports públicos

Build

npm install
npm run build     # gera dist/ (CJS + ESM + .d.ts) via tsup
npm run typecheck  # apenas checa tipos