Skip to content

Commit

Permalink
chore: change name of Images.createBad to Images.createSourceless
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanHjelsethStorstad committed Jan 23, 2025
1 parent 2bf4831 commit 3abccf0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
12 changes: 8 additions & 4 deletions src/services/images/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,20 @@ export const createMany = ServiceMethodHandler({

/**
* WARNING: This function should only be used in extreme cases
* Creats bad image this should really only happen in worst case scenario
* Ads it to the standard collection
* Creates bad image this should really only happen in worst case scenario
* where the server has lost a image and needs to be replaced with a bad image.
* A bad image is an image that has no correct fsLocation attributes.
* @param name - the name of the image
* @param config - the config for the image (special)
*/
export const createBad = ServiceMethodHandler({
export const createSourceless = ServiceMethodHandler({
withData: false,
handler: async (prisma, { name, special }: { name: string, special: SpecialImage }) => {
const standardCollection = await readSpecialImageCollection('STANDARDIMAGES')
logger.warn('creating a bad image, this should only happen in extreme cases.')
logger.warn(`
creating a bad image, Something has caused the server to lose a neccesary image.
It was replaced with a image model with no correct fsLocation atrributes.
`)
return await prisma.image.create({
data: {
name,
Expand Down
6 changes: 3 additions & 3 deletions src/services/images/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'server-only'
import { create, createBad, createMany } from './create'
import { create, createSourceless, createMany } from './create'
import { readPage, read, readSpecial } from './read'
import { ServiceMethod } from '@/services/ServiceMethod'

Expand All @@ -14,9 +14,9 @@ export const Images = {
serviceMethodHandler: createMany,
hasAuther: false // TODO: add auth - visibilty
}),
createBad: ServiceMethod({
createSourceless: ServiceMethod({
withData: false,
serviceMethodHandler: createBad,
serviceMethodHandler: createSourceless,
hasAuther: false // TODO: add auth - visibilty
}),
readPage: ServiceMethod({
Expand Down
6 changes: 4 additions & 2 deletions src/services/images/read.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'server-only'
import { createBad } from './create'
import { createSourceless } from './create'
import { ServiceMethodHandler } from '@/services/ServiceMethodHandler'
import { cursorPageingSelection } from '@/lib/paging/cursorPageingSelection'
import { ServerError } from '@/services/error'
Expand Down Expand Up @@ -60,7 +60,9 @@ export const readSpecial = ServiceMethodHandler({
})

if (!image) {
return await createBad.client(prisma).execute({ params: { name: special, special }, session })
return await createSourceless.client(prisma).execute(
{ params: { name: special, special }, session }
)
}
return image
}
Expand Down

0 comments on commit 3abccf0

Please sign in to comment.