Getting Started
Welcome to Lucent.
Lucent is an Elysia plugin that generates CRUD, auth, migrations, and OpenAPI from your collection definitions.
Create a Project
bun create lucent my-project
cd my-project
bun install
You can also use the CLI directly:
lucent init my-project
Minimal Setup
- Configure the environment:
DATABASE_URL=postgresql://postgres:password@localhost:5432/lucent_example
JWT_SECRET=dev-secret-change-before-production-123
SESSION_SECRET=dev-session-secret-change-before-prod-123
See Environment for the canonical env reference.
- Define your config:
import { defineLucentConfig } from "@codesordinatestudio/lucent";
import { Collections } from "./collections";
export default defineLucentConfig({
db: {
adapter: "postgres",
url: process.env.DATABASE_URL,
},
auth: {
strategies: ["jwt"],
jwt: {
secret: process.env.JWT_SECRET,
},
},
collections: Collections,
});
- Define a collection:
import { defineCollection } from "@codesordinatestudio/lucent";
export const Users = defineCollection({
slug: "users",
auth: true,
fields: [
{ name: "email", type: "email", required: true, unique: true },
{ name: "password", type: "password", required: true },
{ name: "name", type: "text" },
],
});
- Start development:
lucent dev
- Generate types or run migrations manually when needed:
lucent typegen
lucent migrate --dry-run
lucent migrate