mirror of
https://github.com/nestriness/nestri.git
synced 2025-12-12 08:45:38 +02:00
✨ feat: Add auth flow (#146)
This adds a simple way to incorporate a centralized authentication flow. The idea is to have the user, API and SSH (for machine authentication) all in one place using `openauthjs` + `SST` We also have a database now :) > We are using InstantDB as it allows us to authenticate a use with just the email. Plus it is super simple simple to use _of course after the initial fumbles trying to design the db and relationships_
This commit is contained in:
80
packages/core/instant.schema.ts
Normal file
80
packages/core/instant.schema.ts
Normal file
@@ -0,0 +1,80 @@
|
||||
import { i } from "@instantdb/core";
|
||||
|
||||
const _schema = i.schema({
|
||||
// This section lets you define entities: think `posts`, `comments`, etc
|
||||
// Take a look at the docs to learn more:
|
||||
// https://www.instantdb.com/docs/modeling-data#2-attributes
|
||||
entities: {
|
||||
$users: i.entity({
|
||||
email: i.string().unique().indexed(),
|
||||
}),
|
||||
// This is here because the $users entity has no more than 1 property; email
|
||||
// profiles: i.entity({
|
||||
// name: i.string(),
|
||||
// location: i.string(),
|
||||
// createdAt: i.date(),
|
||||
// deletedAt: i.date().optional()
|
||||
// }),
|
||||
machines: i.entity({
|
||||
hostname: i.string(),
|
||||
location: i.string(),
|
||||
fingerprint: i.string().indexed(),
|
||||
createdAt: i.date(),
|
||||
deletedAt: i.date().optional().indexed()
|
||||
}),
|
||||
// teams: i.entity({
|
||||
// name: i.string(),
|
||||
// type: i.string(), // "Personal" or "Family"
|
||||
// createdAt: i.date(),
|
||||
// deletedAt: i.date().optional()
|
||||
// }),
|
||||
// subscriptions: i.entity({
|
||||
// quantity: i.number(),
|
||||
// polarOrderID: i.string(),
|
||||
// frequency: i.string(),
|
||||
// next: i.date().optional(),
|
||||
// }),
|
||||
// productVariants: i.entity({
|
||||
// name: i.string(),
|
||||
// price: i.number()
|
||||
// })
|
||||
},
|
||||
// links: {
|
||||
// userProfiles: {
|
||||
// forward: { on: 'profiles', has: 'one', label: 'owner' },
|
||||
// reverse: { on: '$users', has: 'one', label: 'profile' },
|
||||
// },
|
||||
// machineOwners: {
|
||||
// forward: { on: 'machines', has: 'one', label: 'owner' },
|
||||
// reverse: { on: '$users', has: 'many', label: 'machinesOwned' },
|
||||
// },
|
||||
// machineTeams: {
|
||||
// forward: { on: 'machines', has: 'one', label: 'team' },
|
||||
// reverse: { on: 'teams', has: 'many', label: 'machines' },
|
||||
// },
|
||||
// userTeams: {
|
||||
// forward: { on: 'teams', has: 'one', label: 'owner' },
|
||||
// reverse: { on: '$users', has: 'many', label: 'teamsOwned' },
|
||||
// },
|
||||
// teamMembers: {
|
||||
// forward: { on: 'teams', has: 'many', label: 'members' },
|
||||
// reverse: { on: '$users', has: 'many', label: 'teams' },
|
||||
// },
|
||||
// subscribedProduct: {
|
||||
// forward: { on: "subscriptions", has: "one", label: "productVariant" },
|
||||
// reverse: { on: "productVariants", has: "many", label: "subscriptions" }
|
||||
// },
|
||||
// subscribedUser: {
|
||||
// forward: { on: "subscriptions", has: "one", label: "owner" },
|
||||
// reverse: { on: "$users", has: "many", label: "subscriptions" }
|
||||
// }
|
||||
// }
|
||||
});
|
||||
|
||||
// This helps Typescript display nicer intellisense
|
||||
type _AppSchema = typeof _schema;
|
||||
interface AppSchema extends _AppSchema { }
|
||||
const schema: AppSchema = _schema;
|
||||
|
||||
export type { AppSchema };
|
||||
export default schema;
|
||||
Reference in New Issue
Block a user