Skip to content

Commit 53d8883

Browse files
chore: wip
1 parent af33bd3 commit 53d8883

File tree

17 files changed

+1398
-8
lines changed

17 files changed

+1398
-8
lines changed

app/Models/JudgeReview.ts

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
import type { Model } from '@stacksjs/types'
2+
import { schema } from '@stacksjs/validation'
3+
4+
export default {
5+
name: 'JudgeReview',
6+
table: 'judge_reviews',
7+
primaryKey: 'id',
8+
autoIncrement: true,
9+
10+
indexes: [
11+
{
12+
name: 'judge_reviews_title_index',
13+
columns: ['title'],
14+
},
15+
],
16+
17+
traits: {
18+
useUuid: true,
19+
useTimestamps: true,
20+
useSearch: {
21+
displayable: ['id', 'title', 'content', 'rating'],
22+
searchable: ['title', 'content'],
23+
sortable: ['created_at', 'updated_at', 'rating'],
24+
filterable: ['rating', 'status', 'type'],
25+
},
26+
27+
useSeeder: {
28+
count: 10,
29+
},
30+
31+
useApi: {
32+
uri: 'judge-reviews',
33+
routes: ['index', 'store', 'show'],
34+
},
35+
36+
observe: true,
37+
},
38+
39+
belongsTo: ['Judge', 'User'],
40+
41+
attributes: {
42+
title: {
43+
required: true,
44+
order: 1,
45+
fillable: true,
46+
validation: {
47+
rule: schema.string().min(3).max(255),
48+
message: {
49+
min: 'Title must have a minimum of 3 characters',
50+
max: 'Title must have a maximum of 255 characters',
51+
},
52+
},
53+
factory: faker => faker.lorem.sentence(),
54+
},
55+
56+
content: {
57+
required: true,
58+
order: 2,
59+
fillable: true,
60+
validation: {
61+
rule: schema.string().min(10).max(1000),
62+
message: {
63+
min: 'Content must have a minimum of 10 characters',
64+
max: 'Content must have a maximum of 1000 characters',
65+
},
66+
},
67+
factory: faker => faker.lorem.paragraphs(2),
68+
},
69+
70+
rating: {
71+
required: true,
72+
order: 3,
73+
fillable: true,
74+
validation: {
75+
rule: schema.number().min(1).max(5),
76+
message: {
77+
min: 'Rating must be at least 1',
78+
max: 'Rating cannot exceed 5',
79+
},
80+
},
81+
factory: faker => faker.number.int({ min: 1, max: 5 }),
82+
},
83+
84+
likes: {
85+
required: true,
86+
order: 4,
87+
fillable: true,
88+
validation: {
89+
rule: schema.number().min(0),
90+
message: {
91+
min: 'Likes cannot be negative',
92+
},
93+
},
94+
factory: faker => faker.number.int({ min: 0, max: 100 }),
95+
},
96+
97+
comments: {
98+
required: true,
99+
order: 5,
100+
fillable: true,
101+
validation: {
102+
rule: schema.number().min(0),
103+
message: {
104+
min: 'Comments cannot be negative',
105+
},
106+
},
107+
factory: faker => faker.number.int({ min: 0, max: 50 }),
108+
},
109+
110+
type: {
111+
required: true,
112+
order: 6,
113+
fillable: true,
114+
validation: {
115+
rule: schema.string(),
116+
message: {
117+
required: 'Type is required',
118+
},
119+
},
120+
factory: faker => faker.helpers.arrayElement(['positive', 'negative', 'neutral']),
121+
},
122+
123+
status: {
124+
required: true,
125+
order: 7,
126+
fillable: true,
127+
validation: {
128+
rule: schema.string(),
129+
message: {
130+
required: 'Status is required',
131+
},
132+
},
133+
factory: faker => faker.helpers.arrayElement(['published', 'pending', 'rejected']),
134+
},
135+
},
136+
137+
dashboard: {
138+
highlight: true,
139+
},
140+
} satisfies Model
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Action } from '@stacksjs/actions'
2+
import { response } from '@stacksjs/router'
3+
4+
export default new Action({
5+
name: 'JudgeReview Index',
6+
description: 'JudgeReview Index ORM Action',
7+
method: 'GET',
8+
async handle() {
9+
const results = await JudgeReview.all()
10+
11+
return response.json(results)
12+
},
13+
})
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { JudgeReviewRequestType } from '@stacksjs/orm'
2+
import { Action } from '@stacksjs/actions'
3+
4+
import { JudgeReview } from '@stacksjs/orm'
5+
import { response } from '@stacksjs/router'
6+
7+
export default new Action({
8+
name: 'JudgeReview Show',
9+
description: 'JudgeReview Show ORM Action',
10+
method: 'GET',
11+
async handle(request: JudgeReviewRequestType) {
12+
const id = request.getParam('id')
13+
14+
const model = await JudgeReview.findOrFail(id)
15+
16+
return response.json(model)
17+
},
18+
})
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { JudgeReviewRequestType } from '@stacksjs/orm'
2+
import { Action } from '@stacksjs/actions'
3+
4+
import { JudgeReview } from '@stacksjs/orm'
5+
import { response } from '@stacksjs/router'
6+
7+
export default new Action({
8+
name: 'JudgeReview Store',
9+
description: 'JudgeReview Store ORM Action',
10+
method: 'POST',
11+
async handle(request: JudgeReviewRequestType) {
12+
await request.validate()
13+
const model = await JudgeReview.create(request.all())
14+
15+
return response.json(model)
16+
},
17+
})

storage/framework/core/socials/src/drivers/twitter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { ProviderInterface, SocialUser, TwitterTokenResponse, TwitterUser } from '../types'
2+
import { Buffer } from 'node:buffer'
23
import { createHash, randomBytes } from 'node:crypto'
34
import { fetcher } from '@stacksjs/api'
45
import { config } from '@stacksjs/config'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export type ModelNames = 'CourtHouse' | 'Judge' | 'OauthAccessToken' | 'OauthClient' | 'EmailSubscription' | 'User' | 'PersonalAccessToken' | 'PrintDevice' | 'Category' | 'Payment' | 'Driver' | 'WaitlistProduct' | 'DigitalDelivery' | 'Manufacturer' | 'OrderItem' | 'ShippingZone' | 'Customer' | 'Product' | 'Receipt' | 'ProductVariant' | 'LicenseKey' | 'WaitlistRestaurant' | 'Review' | 'ProductUnit' | 'GiftCard' | 'Order' | 'Coupon' | 'TaxRate' | 'Transaction' | 'LoyaltyPoint' | 'ProductItem' | 'LoyaltyReward' | 'ShippingMethod' | 'ShippingRate' | 'Cart' | 'DeliveryRoute' | 'CartItem' | 'PaymentProduct' | 'FailedJob' | 'PaymentMethod' | 'Page' | 'Author' | 'Post' | 'PaymentTransaction' | 'Websocket' | 'Request' | 'Job' | 'Log' | 'Subscription' | 'Error'
1+
export type ModelNames = 'CourtHouse' | 'Judge' | 'JudgeReview' | 'OauthAccessToken' | 'OauthClient' | 'EmailSubscription' | 'User' | 'PersonalAccessToken' | 'PrintDevice' | 'Category' | 'Payment' | 'Driver' | 'WaitlistProduct' | 'DigitalDelivery' | 'Manufacturer' | 'OrderItem' | 'ShippingZone' | 'Customer' | 'Product' | 'Receipt' | 'ProductVariant' | 'LicenseKey' | 'WaitlistRestaurant' | 'Review' | 'ProductUnit' | 'GiftCard' | 'Order' | 'Coupon' | 'TaxRate' | 'Transaction' | 'LoyaltyPoint' | 'ProductItem' | 'LoyaltyReward' | 'ShippingMethod' | 'ShippingRate' | 'Cart' | 'DeliveryRoute' | 'CartItem' | 'PaymentProduct' | 'FailedJob' | 'PaymentMethod' | 'Page' | 'Author' | 'Post' | 'PaymentTransaction' | 'Websocket' | 'Request' | 'Job' | 'Log' | 'Subscription' | 'Error'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export type TableNames = 'taggables' | 'categorizables' | 'commentables' | 'commentable_upvotes' | 'passkeys' | 'password_resets' | 'query_logs' | 'migrations' | 'court_houses' | 'judges' | 'oauth_access_tokens' | 'oauth_clients' | 'email_subscriptions' | 'users' | 'personal_access_tokens' | 'print_devices' | 'categories' | 'payments' | 'drivers' | 'waitlist_products' | 'digital_deliveries' | 'manufacturers' | 'order_items' | 'shipping_zones' | 'customers' | 'products' | 'receipts' | 'product_variants' | 'license_keys' | 'waitlist_restaurants' | 'reviews' | 'product_units' | 'gift_cards' | 'orders' | 'coupons' | 'tax_rates' | 'transactions' | 'loyalty_points' | 'product_items' | 'loyalty_rewards' | 'shipping_methods' | 'shipping_rates' | 'carts' | 'delivery_routes' | 'cart_items' | 'payment_products' | 'failed_jobs' | 'payment_methods' | 'pages' | 'authors' | 'posts' | 'payment_transactions' | 'websockets' | 'requests' | 'jobs' | 'logs' | 'subscriptions' | 'errors'
1+
export type TableNames = 'taggables' | 'categorizables' | 'commentables' | 'commentable_upvotes' | 'passkeys' | 'password_resets' | 'query_logs' | 'migrations' | 'court_houses' | 'judges' | 'judge_reviews' | 'oauth_access_tokens' | 'oauth_clients' | 'email_subscriptions' | 'users' | 'personal_access_tokens' | 'print_devices' | 'categories' | 'payments' | 'drivers' | 'waitlist_products' | 'digital_deliveries' | 'manufacturers' | 'order_items' | 'shipping_zones' | 'customers' | 'products' | 'receipts' | 'product_variants' | 'license_keys' | 'waitlist_restaurants' | 'reviews' | 'product_units' | 'gift_cards' | 'orders' | 'coupons' | 'tax_rates' | 'transactions' | 'loyalty_points' | 'product_items' | 'loyalty_rewards' | 'shipping_methods' | 'shipping_rates' | 'carts' | 'delivery_routes' | 'cart_items' | 'payment_products' | 'failed_jobs' | 'payment_methods' | 'pages' | 'authors' | 'posts' | 'payment_transactions' | 'websockets' | 'requests' | 'jobs' | 'logs' | 'subscriptions' | 'errors'

storage/framework/orm/routes.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ route.post('judges', 'JudgeStoreOrmAction')
1212

1313
route.get('judges/{id}', 'JudgeShowOrmAction')
1414

15+
route.get('judge-reviews', 'JudgeReviewIndexOrmAction')
16+
17+
route.post('judge-reviews', 'JudgeReviewStoreOrmAction')
18+
19+
route.get('judge-reviews/{id}', 'JudgeReviewShowOrmAction')
20+
1521
route.get('users', 'UserIndexOrmAction')
1622

1723
route.post('users', 'UserStoreOrmAction')

storage/framework/orm/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export { default as Job, type JobJsonResponse, type JobUpdate, type NewJob } fro
3030

3131
export { default as Judge, type JudgeJsonResponse, type JudgeUpdate, type NewJudge } from './models/Judge'
3232

33+
export { default as JudgeReview, type JudgeReviewJsonResponse, type JudgeReviewUpdate, type NewJudgeReview } from './models/JudgeReview'
34+
3335
export { default as LicenseKey, type LicenseKeyJsonResponse, type LicenseKeyUpdate, type NewLicenseKey } from './models/LicenseKey'
3436

3537
export { default as Log, type LogJsonResponse, type LogUpdate, type NewLog } from './models/Log'

0 commit comments

Comments
 (0)