Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true,
"defaultBranch": "main"
},
"files": {
"ignore": ["./components/ui", "./migrations", "instant.schema.ts", "instant.perms.ts"]
},
"formatter": {
"indentStyle": "space",
"indentWidth": 4,
"lineWidth": 100
},
"linter": {
"rules": {
"a11y": {
"noSvgWithoutTitle": "off",
"useGenericFontNames": "off"
},
"suspicious": {
"noArrayIndexKey": "off",
"noDoubleEquals": {
"fix": "safe",
"level": "warn",
"options": {}
}
},
"style": {
"noNonNullAssertion": "off",
"useSelfClosingElements": {
"fix": "safe",
"level": "warn"
},
"useTemplate": {
"fix": "safe",
"level": "warn"
}
},
"correctness": {
"noUnusedImports": "info"
},
"nursery": {
"useSortedClasses": {
"fix": "safe",
"level": "info",
"options": {
"functions": ["cn"]
}
}
}
}
},
"javascript": {
"formatter": {
"semicolons": "asNeeded",
"trailingCommas": "none"
}
}
}
25 changes: 9 additions & 16 deletions instant.perms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,15 @@
import type { InstantRules } from "@instantdb/react";

const rules = {
/**
* Welcome to Instant's permission system!
* Right now your rules are empty. To start filling them in, check out the docs:
* https://www.instantdb.com/docs/permissions
*
* Here's an example to give you a feel:
* posts: {
* allow: {
* view: "true",
* create: "isOwner",
* update: "isOwner",
* delete: "isOwner",
* },
* bind: ["isOwner", "auth.id != null && auth.id == data.ownerId"],
* },
*/
todos: {
bind: ["isOwner", "auth.id != null && auth.id == data.userId"],
allow: {
view: "isOwner",
create: "isOwner",
delete: "isOwner",
update: "isOwner",
},
},
} satisfies InstantRules;

export default rules;
26 changes: 26 additions & 0 deletions instant.schema.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,38 @@
// Docs: https://www.instantdb.com/docs/modeling-data

import { i } from "@instantdb/react";

const _schema = i.schema({
entities: {
$files: i.entity({
path: i.string().unique().indexed(),
url: i.any(),
}),
$users: i.entity({
email: i.string().unique().indexed(),
}),
todos: i.entity({
body: i.string(),
title: i.string(),
userId: i.string().indexed(),
}),
},
links: {
todosUser: {
forward: {
on: "todos",
has: "one",
label: "user",
onDelete: "cascade",
},
reverse: {
on: "$users",
has: "many",
label: "todos",
},
},
},
rooms: {},
});

// This helps Typescript display nicer intellisense
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"@instantdb/admin": "^0.18.1",
"@instantdb/core": "*",
"@instantdb/react": "*",
"@tailwindcss/vite": "^4.0.6",
Expand Down
Loading