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

chadstart-sdk

v1.0.0

Published

Official JavaScript/TypeScript SDK for Chadstart BaaS

Readme

@chadstart/sdk

Official JavaScript/TypeScript SDK for Chadstart — the YAML-first Backend as a Service.

Works in any JS/TS project: browsers, React, Vue, Svelte, Angular, Astro, Node.js, and more.


Installation

npm install @chadstart/sdk

Quick Start

import Chadstart from '@chadstart/sdk'

// Initialize with your backend URL (defaults to http://localhost:3000)
const client = new Chadstart('https://your-chadstart-backend.com')

Collections

List items (paginated)

// Fetch all posts (returns paginated result)
const result = await client.from('posts').find()
// { data: [...], currentPage: 1, lastPage: 1, total: 10, perPage: 10, from: 1, to: 10 }

// With pagination
const result = await client.from('posts').find({ page: 2, perPage: 20 })

Filtering

const posts = await client
  .from('posts')
  .where('published = true')
  .andWhere('views > 100')
  .find()

Supported operators:

| Operator | Description | Example | | -------- | --------------------- | -------------------------------- | | = | equals | .where('isActive = true') | | != | not equals | .where('status != draft') | | > | greater than | .where('age > 18') | | >= | greater than or equal | .where('price >= 10') | | < | less than | .where('stock < 5') | | <= | less than or equal | .where('amount <= 400') | | like | pattern match | .where('name like %jo%') | | in | included in | .where('status in new,active') |

Ordering

const posts = await client
  .from('posts')
  .orderBy('createdAt', { desc: true })
  .find()

Relations

const posts = await client
  .from('posts')
  .with(['author', 'tags'])
  .find()

// Nested relations
const cities = await client
  .from('cities')
  .with(['region', 'region.country'])
  .find()

Get a single item by ID

const post = await client.from('posts').findOneById('2c4e6a8b-...')

Create an item

const newPost = await client.from('posts').create({
  title: 'Hello World',
  published: true,
})

Update an item (full replace — PUT)

const updated = await client.from('posts').update('2c4e6a8b-...', {
  title: 'Updated Title',
  published: false,
})

Patch an item (partial update — PATCH)

const patched = await client.from('posts').patch('2c4e6a8b-...', {
  published: true,
})

Delete an item

const deleted = await client.from('posts').delete('2c4e6a8b-...')

Singles

Singles are entities with only one record (e.g. homepage content, site settings).

// Get
const homepage = await client.single('homepage').get()

// Full replace (PUT)
const updated = await client.single('homepage').update({
  title: 'Welcome!',
  description: 'My awesome site',
})

// Partial update (PATCH)
const patched = await client.single('homepage').patch({ title: 'New Title' })

Authentication

Chadstart supports multiple authenticable entity types.

// Sign up
const { token, user } = await client.auth('customers').signup({
  email: '[email protected]',
  password: 'secret',
  name: 'Alice',
})
// Token is stored automatically

// Log in
const { token, user } = await client.auth('customers').login({
  email: '[email protected]',
  password: 'secret',
})
// Token is stored automatically

// Get current user (requires a stored token)
const me = await client.auth('customers').me()

// Log out
client.auth('customers').logout()

Manual token management

// Store a token manually (e.g. from localStorage)
client.setToken(localStorage.getItem('token'))

// Clear the token
client.clearToken()

Error Handling

All methods throw a ChadstartError on non-2xx responses.

import Chadstart, { ChadstartError } from '@chadstart/sdk'

try {
  const post = await client.from('posts').findOneById('missing-id')
} catch (err) {
  if (err instanceof ChadstartError) {
    console.log(err.status) // e.g. 404
    console.log(err.message) // e.g. "Not found"
    console.log(err.data)   // raw response body
  }
}

TypeScript

Full TypeScript support is included out of the box.

import Chadstart from '@chadstart/sdk'

interface Post {
  id: string
  title: string
  published: boolean
}

const client = new Chadstart('https://api.example.com')

const { data } = await client.from<Post>('posts').find()
//     ^? Post[]

const post = await client.from<Post>('posts').findOneById('abc')
//    ^? Post

CommonJS usage

const Chadstart = require('@chadstart/sdk')
const client = new Chadstart('http://localhost:3000')

API Reference

new Chadstart(baseUrl?)

| Parameter | Type | Default | Description | | --------- | -------- | -------------------------- | ------------------------ | | baseUrl | string | 'http://localhost:3000' | Your Chadstart server URL |

client.from(slug)CollectionQuery

| Method | Description | | --------------------------- | ------------------------------------ | | .where(condition) | Add a filter | | .andWhere(condition) | Add an additional filter | | .with(relations) | Load relations | | .orderBy(field, options?) | Order results | | .find(params?) | Fetch paginated list | | .findOneById(id) | Fetch one item by ID | | .create(data) | Create a new item | | .update(id, data) | Replace an item (PUT) | | .patch(id, data) | Partially update an item (PATCH) | | .delete(id) | Delete an item |

client.single(slug)SingleQuery

| Method | Description | | --------------- | -------------------------------- | | .get() | Fetch the single entity | | .update(data) | Replace the single entity (PUT) | | .patch(data) | Partially update it (PATCH) |

client.auth(slug)AuthQuery

| Method | Description | | --------------- | ---------------------------------------------------- | | .signup(data) | Register a user; auto-stores the returned token | | .login(data) | Log in a user; auto-stores the returned token | | .me() | Get the currently authenticated user | | .logout() | Clear the stored token |


License

ISC