Adding a ton of stuff

This commit is contained in:
2026-07-17 04:39:18 -07:00
parent 8d9fe8e75d
commit de28a67417
63 changed files with 2027 additions and 613 deletions
+57
View File
@@ -0,0 +1,57 @@
import { Attributes, FindOptions } from "@sequelize/core"
import { BlogPost, User } from "@/models"
import { ALL_RECORDS_SCOPE, PolicyFactory } from "@/policies/base-policy"
import { Path } from "@/utils/deep-pick"
export class BlogPostsPolicy extends PolicyFactory(BlogPost) {
show(): boolean {
if (this.user.isSystemAdmin) {
return true
}
return false
}
create(): boolean {
if (this.user.isSystemAdmin) {
return true
}
return false
}
update(): boolean {
if (this.user.isSystemAdmin) {
return true
}
return false
}
destroy(): boolean {
if (this.user.isSystemAdmin) {
return true
}
return false
}
permittedAttributes(): Path[] {
return ["title", "slug", "content", "tags", "publishedAt"] as (keyof Attributes<BlogPost>)[]
}
permittedAttributesForCreate(): Path[] {
return [...this.permittedAttributes()]
}
permittedAttributesForUpdate(): Path[] {
return [...this.permittedAttributes()]
}
static policyScope(_user: User): FindOptions<Attributes<BlogPost>> {
return ALL_RECORDS_SCOPE
}
}
export default BlogPostsPolicy