Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed May 17, 2024
1 parent 7d20ddd commit b690b8c
Show file tree
Hide file tree
Showing 3 changed files with 192 additions and 0 deletions.
41 changes: 41 additions & 0 deletions app/Models/AccessToken.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { faker } from '@stacksjs/faker'
import type { Model } from '@stacksjs/types'
import { schema } from '@stacksjs/validation'

export default {
name: 'AccessToken', // defaults to the sanitized file name
table: 'access_tokens', // defaults to the lowercase, plural name of the model
primaryKey: 'id', // defaults to `id`
autoIncrement: true, // defaults to true

hasOne: ['Team'],

traits: {
useTimestamps: true, // defaults to true
useSeeder: {
// defaults to a count of 10
count: 10,
},
},

attributes: {
name: {
validator: {
rule: schema.string(),
message: '`name` must be a string',
},

factory: () => faker.lorem.sentence({ min: 3, max: 6 }),
},

token: {
unique: true,
validator: {
rule: schema.string(),
message: '`token` must be a string',
},

factory: () => faker.random.uuid(),
},
},
} satisfies Model
56 changes: 56 additions & 0 deletions app/Models/Project.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { faker } from '@stacksjs/faker'
import type { Model } from '@stacksjs/types'
import { schema } from '@stacksjs/validation'

export default {
name: 'Project', // defaults to the sanitized file name
table: 'projects', // defaults to the lowercase, plural name of the model
primaryKey: 'id', // defaults to `id`
autoIncrement: true, // defaults to true

traits: {
useTimestamps: true, // defaults to true
useSeeder: {
// defaults to a count of 10
count: 10,
},
},

attributes: {
name: {
validator: {
rule: schema.string(),
message: '`name` must be a string',
},

factory: () => faker.lorem.sentence({ min: 3, max: 6 }),
},

description: {
validator: {
rule: schema.string(),
message: '`description` must be a string',
},

factory: () => faker.lorem.sentence({ min: 10, max: 10 }),
},

url: {
validator: {
rule: schema.string(),
message: '`url` must be a string',
},

factory: () => faker.internet.url(),
},

status: {
validator: {
rule: schema.string(),
message: '`status` must be a string',
},

factory: () => faker.random.arrayElement(['active', 'inactive']),
},
},
} satisfies Model
95 changes: 95 additions & 0 deletions app/Models/Team.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import { faker } from '@stacksjs/faker'
import type { Model } from '@stacksjs/types'
import { schema } from '@stacksjs/validation'

export default {
name: 'Team', // defaults to the sanitized file name
table: 'teams', // defaults to the lowercase, plural name of the model
primaryKey: 'id', // defaults to `id`
autoIncrement: true, // defaults to true

traits: {
useTimestamps: true, // defaults to true
useSeeder: {
// defaults to a count of 10
count: 10,
},
},

attributes: {
name: {
validator: {
rule: schema.string(),
message: '`name` must be a string',
},

factory: () => faker.lorem.sentence({ min: 3, max: 6 }),
},

companyName: {
validator: {
rule: schema.string(),
message: '`companyName` must be a string',
},

factory: () => faker.company.companyName(),
},

email: {
validator: {
rule: schema.string().email(),
message: '`email` must be a string',
},

factory: () => faker.internet.email(),
},

billingEmail: {
validator: {
rule: schema.string().email(),
message: '`billingEmail` must be a string',
},

factory: () => faker.internet.email(),
},

status: {
validator: {
rule: schema.string(),
message: '`status` must be a string',
},

factory: () => faker.random.arrayElement(['deployed', 'inactive']),
},

description: {
validator: {
rule: schema.string(),
message: '`description` must be a string',
},

factory: () => faker.lorem.sentence({ min: 10, max: 30 }),
},

path: {
validator: {
rule: schema.string(),
message: '`path` must be a string',
},

factory: () =>
faker.random.arrayElement([
`/Users/chrisbreuer/Code/${faker.lorem.words().toLowerCase().replace(/\s+/g, '-')}`,
]),
},

isPersonal: {
validator: {
rule: schema.boolean(),
message: '`isPersonal` must be a boolean',
},

factory: () => faker.random.boolean(),
},
},
} satisfies Model

0 comments on commit b690b8c

Please sign in to comment.