vanestack_client 0.1.1 copy "vanestack_client: ^0.1.1" to clipboard
vanestack_client: ^0.1.1 copied to clipboard

HTTP client SDK for interacting with VaneStack backend servers.

VaneStack Logo

vanestack_client

Typed HTTP client SDK for VaneStack servers.

Website · Documentation


Getting Started #

import 'package:vanestack_client/vanestack_client.dart';

final client = VaneStackClient(
  baseUrl: 'http://localhost:8080',
  authStorage: MemoryAuthStorage(),
);
await client.initialize();

Authentication #

// Sign in
final auth = await client.auth.signInWithEmailAndPassword(
  email: 'user@example.com',
  password: 'password',
);
print(auth.user.email);

// Listen to auth state changes
client.onUserChanges.listen((user) {
  print('Auth state changed: ${user?.email}');
});

// Sign out
await client.auth.logout();

Documents #

// Create
final doc = await client.documents.create(
  collectionName: 'posts',
  data: {'title': 'Hello World', 'published': true},
);

// Read
final post = await client.documents.get(
  collectionName: 'posts',
  documentId: doc.id,
);

// List with filtering and sorting
final result = await client.documents.list(
  collectionName: 'posts',
  filter: Filter.and([
    Filter.where('published', isEqualTo: true),
    Filter.where('views', isGreaterThan: 100),
  ]),
  orderBy: OrderBy('createdAt', direction: SortDirection.desc),
);

// Update
await client.documents.update(
  collectionName: 'posts',
  documentId: doc.id,
  data: {'title': 'Updated Title'},
);

// Delete
await client.documents.delete(
  collectionName: 'posts',
  documentId: doc.id,
);

File Storage #

// Upload
await client.files.upload(
  bucket: 'images',
  file: MultipartFile.fromPath('photo', '/path/to/image.png'),
);

// Get download URL
final url = await client.files.getDownloadUrl(
  bucket: 'images',
  fileId: 'file-id',
);

Realtime #

final (stream, unsubscribe) = await client.realtime.subscribe(
  channel: Channel.collection('posts', type: DocumentEventType.create),
);

stream.listen((event) {
  print('New post created: ${event.data}');
});

// When done
unsubscribe();

Auth Storage #

Implement AuthStorage for persistent token storage (e.g. with shared_preferences):

abstract class AuthStorage {
  Future<void> save(String key, String value);
  Future<String?> read(String key);
  Future<void> delete(String key);
}

MemoryAuthStorage is included for testing and non-persistent use.

Features #

  • Automatic token refresh on 401 responses
  • Retry with backoff on 503
  • SSE-based realtime subscriptions with channel filtering
  • User state stream via client.onUserChanges
  • Multipart file uploads
  • Typed filter and sort builders
Package Description
vanestack Server framework
vanestack_common Shared models and types
vanestack_annotation @Route annotation and HttpMethod enum
vanestack_generator Build runner code generator
0
likes
0
points
22
downloads

Publisher

verified publishervanestack.dev

Weekly Downloads

HTTP client SDK for interacting with VaneStack backend servers.

Homepage
Repository (GitHub)
View/report issues

Topics

#http-client #api-client #server

License

unknown (license)

Dependencies

crypto, http, http_parser, sse_channel, vanestack_common

More

Packages that depend on vanestack_client