@devlider001/washlab-backend
v1.1.51
Published
Washlab backend - Convex API package for Lider Technology Ltd
Maintainers
Readme
Washlab Backend
Convex backend package for Washlab. This package provides type-safe access to all Convex functions, mutations, queries, and data models.
Installation
yarn add @lider-technology-ltd/washlab-backend
# or
npm install @lider-technology-ltd/washlab-backend
# or
pnpm add @lider-technology-ltd/washlab-backendPrerequisites
This package requires convex to be installed in your client application:
yarn add convex
# or
npm install convexUsage
React/Next.js (Recommended)
import { ConvexProvider, ConvexReactClient } from "convex/react";
import { api } from "@lider-technology-ltd/washlab-backend";
// Initialize the Convex client with your deployment URL
const convex = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL!);
function App() {
return (
<ConvexProvider client={convex}>
{/* Your app components */}
<MyComponent />
</ConvexProvider>
);
}
// In your components
import { useQuery, useMutation } from "convex/react";
import { api } from "@lider-technology-ltd/washlab-backend";
function MyComponent() {
// Use queries
const users = useQuery(api.users.list, {});
// Use mutations
const createUser = useMutation(api.users.create);
return (
<div>
{/* Your UI */}
</div>
);
}HTTP Client (Node.js/Server-side)
import { ConvexHttpClient } from "convex/browser";
import { api } from "@lider-technology-ltd/washlab-backend";
const convex = new ConvexHttpClient(process.env.CONVEX_URL!);
// Use queries
const users = await convex.query(api.users.list, {});
// Use mutations
const userId = await convex.mutation(api.users.create, {
email: "[email protected]",
password: "securepassword"
});Direct API Type Import
You can also import types directly:
import type { api } from "@lider-technology-ltd/washlab-backend";
import type { Doc, Id } from "@lider-technology-ltd/washlab-backend";
// Use the types for type-safe function references
type User = Doc<"users">;
type UserId = Id<"users">;Alternative Import Paths
You can also import from specific paths:
// Import API types only
import type { api } from "@lider-technology-ltd/washlab-backend/api";
// Import data model types only
import type { DataModel, Doc, Id } from "@lider-technology-ltd/washlab-backend/dataModel";Environment Variables
Make sure to set your Convex deployment URL:
# For browser/client applications
NEXT_PUBLIC_CONVEX_URL=https://your-deployment.convex.cloud
# For server-side applications
CONVEX_URL=https://your-deployment.convex.cloudYou can get your deployment URL from the Convex Dashboard.
Type Safety
All function references, arguments, and return types are fully typed. TypeScript will provide autocomplete and type checking for:
- Function names (queries, mutations, actions)
- Function arguments
- Return types
- Document types from your schema
- ID types for each table
Development
To build this package:
yarn buildTo publish to npm:
npm publishNote: While this package uses yarn for development, you still use npm publish to publish to the npm registry.
License
ISC
