Skip to content

Commit b690b8c

Browse files
committed
chore: wip
1 parent 7d20ddd commit b690b8c

File tree

3 files changed

+192
-0
lines changed

3 files changed

+192
-0
lines changed

app/Models/AccessToken.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { faker } from '@stacksjs/faker'
2+
import type { Model } from '@stacksjs/types'
3+
import { schema } from '@stacksjs/validation'
4+
5+
export default {
6+
name: 'AccessToken', // defaults to the sanitized file name
7+
table: 'access_tokens', // defaults to the lowercase, plural name of the model
8+
primaryKey: 'id', // defaults to `id`
9+
autoIncrement: true, // defaults to true
10+
11+
hasOne: ['Team'],
12+
13+
traits: {
14+
useTimestamps: true, // defaults to true
15+
useSeeder: {
16+
// defaults to a count of 10
17+
count: 10,
18+
},
19+
},
20+
21+
attributes: {
22+
name: {
23+
validator: {
24+
rule: schema.string(),
25+
message: '`name` must be a string',
26+
},
27+
28+
factory: () => faker.lorem.sentence({ min: 3, max: 6 }),
29+
},
30+
31+
token: {
32+
unique: true,
33+
validator: {
34+
rule: schema.string(),
35+
message: '`token` must be a string',
36+
},
37+
38+
factory: () => faker.random.uuid(),
39+
},
40+
},
41+
} satisfies Model

app/Models/Project.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { faker } from '@stacksjs/faker'
2+
import type { Model } from '@stacksjs/types'
3+
import { schema } from '@stacksjs/validation'
4+
5+
export default {
6+
name: 'Project', // defaults to the sanitized file name
7+
table: 'projects', // defaults to the lowercase, plural name of the model
8+
primaryKey: 'id', // defaults to `id`
9+
autoIncrement: true, // defaults to true
10+
11+
traits: {
12+
useTimestamps: true, // defaults to true
13+
useSeeder: {
14+
// defaults to a count of 10
15+
count: 10,
16+
},
17+
},
18+
19+
attributes: {
20+
name: {
21+
validator: {
22+
rule: schema.string(),
23+
message: '`name` must be a string',
24+
},
25+
26+
factory: () => faker.lorem.sentence({ min: 3, max: 6 }),
27+
},
28+
29+
description: {
30+
validator: {
31+
rule: schema.string(),
32+
message: '`description` must be a string',
33+
},
34+
35+
factory: () => faker.lorem.sentence({ min: 10, max: 10 }),
36+
},
37+
38+
url: {
39+
validator: {
40+
rule: schema.string(),
41+
message: '`url` must be a string',
42+
},
43+
44+
factory: () => faker.internet.url(),
45+
},
46+
47+
status: {
48+
validator: {
49+
rule: schema.string(),
50+
message: '`status` must be a string',
51+
},
52+
53+
factory: () => faker.random.arrayElement(['active', 'inactive']),
54+
},
55+
},
56+
} satisfies Model

app/Models/Team.ts

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import { faker } from '@stacksjs/faker'
2+
import type { Model } from '@stacksjs/types'
3+
import { schema } from '@stacksjs/validation'
4+
5+
export default {
6+
name: 'Team', // defaults to the sanitized file name
7+
table: 'teams', // defaults to the lowercase, plural name of the model
8+
primaryKey: 'id', // defaults to `id`
9+
autoIncrement: true, // defaults to true
10+
11+
traits: {
12+
useTimestamps: true, // defaults to true
13+
useSeeder: {
14+
// defaults to a count of 10
15+
count: 10,
16+
},
17+
},
18+
19+
attributes: {
20+
name: {
21+
validator: {
22+
rule: schema.string(),
23+
message: '`name` must be a string',
24+
},
25+
26+
factory: () => faker.lorem.sentence({ min: 3, max: 6 }),
27+
},
28+
29+
companyName: {
30+
validator: {
31+
rule: schema.string(),
32+
message: '`companyName` must be a string',
33+
},
34+
35+
factory: () => faker.company.companyName(),
36+
},
37+
38+
email: {
39+
validator: {
40+
rule: schema.string().email(),
41+
message: '`email` must be a string',
42+
},
43+
44+
factory: () => faker.internet.email(),
45+
},
46+
47+
billingEmail: {
48+
validator: {
49+
rule: schema.string().email(),
50+
message: '`billingEmail` must be a string',
51+
},
52+
53+
factory: () => faker.internet.email(),
54+
},
55+
56+
status: {
57+
validator: {
58+
rule: schema.string(),
59+
message: '`status` must be a string',
60+
},
61+
62+
factory: () => faker.random.arrayElement(['deployed', 'inactive']),
63+
},
64+
65+
description: {
66+
validator: {
67+
rule: schema.string(),
68+
message: '`description` must be a string',
69+
},
70+
71+
factory: () => faker.lorem.sentence({ min: 10, max: 30 }),
72+
},
73+
74+
path: {
75+
validator: {
76+
rule: schema.string(),
77+
message: '`path` must be a string',
78+
},
79+
80+
factory: () =>
81+
faker.random.arrayElement([
82+
`/Users/chrisbreuer/Code/${faker.lorem.words().toLowerCase().replace(/\s+/g, '-')}`,
83+
]),
84+
},
85+
86+
isPersonal: {
87+
validator: {
88+
rule: schema.boolean(),
89+
message: '`isPersonal` must be a boolean',
90+
},
91+
92+
factory: () => faker.random.boolean(),
93+
},
94+
},
95+
} satisfies Model

0 commit comments

Comments
 (0)