@archlast/server
v0.1.8
Published
Archlast server library exports and Docker templates
Downloads
63
Readme
@archlast/server
Type-safe server definitions and runtime helpers for Archlast. This package is used to define schema, functions, and shared types, and it ships Docker templates for runtime deployment.
Install
npm install -D @archlast/serverLibrary vs runtime
This package is a dev-time library for schema and function definitions. The
runtime server is delivered via the Docker image (algochad/archlast-server) and managed
by the CLI (archlast start).
Schema
import { defineSchema, defineTable, v } from "@archlast/server/schema/definition";
export default defineSchema({
tasks: defineTable({
id: v.id(),
text: v.string(),
}),
});Functions
import { query, mutation } from "@archlast/server/functions/definition";
import { z } from "zod";
export const list = query({
handler: async (ctx) => ctx.db.table("tasks").findMany(),
});
export const create = mutation({
args: { text: z.string() },
handler: async (ctx, args) => ctx.db.table("tasks").insert({ text: args.text }),
});Other function types:
actionfor long running taskshttpfor explicit HTTP routeswebhookfor signed incoming eventsrpcfor tRPC-style public procedures
Auth and permissions
All functions default to auth: "required". You can mark functions public or
optional, and attach permissions.
export const publicPing = query({
auth: "public",
handler: async () => "pong",
});Runtime exports
Common entry points:
@archlast/server/schema/definitionand@archlast/server/schema/validators@archlast/server/functions/definitionand@archlast/server/functions/types@archlast/server/httpand@archlast/server/webhook@archlast/server/jobs@archlast/server/storage/types@archlast/server/context
Docker templates
Templates live under templates/ in this package:
docker-compose.yml,docker-compose.dev.yml,docker-compose.prod.yml.env.examplearchlast.config.js
The CLI uses these templates to generate a local Docker setup.
Environment configuration
Key variables used by the server runtime:
PORT(default: 4000)ARCHLAST_DB_ROOT(default:./data)ARCHLAST_ALLOWED_ORIGINS(CSV)ARCHLAST_CORS_ALLOW_CREDENTIALS(trueorfalse)STORAGE_ROOTandSTORAGE_SIGNING_SECRETS3_ENABLED,S3_BUCKET,S3_REGION,AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEYARCHLAST_ADMIN_TOKEN(deprecated),ARCHLAST_AUTH_TOKEN_PEPPERARCHLAST_DASHBOARD_DIRorARCHLAST_DASHBOARD_URLARCHLAST_STORE_PORT,ARCHLAST_STORE_NO_TLS
Publishing (maintainers)
See docs/npm-publishing.md for release and publish steps.
