feat: initial commit - Band Management application

This commit is contained in:
2026-01-06 03:11:46 +01:00
commit 34e12e00b3
24543 changed files with 3991790 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
import { getServerSession } from '#auth'
export async function setAuthOnlyRoute(event, statusMessage = 'You must be signed in to access this API.') {
const session = await getServerSession(event)
if (!session) {
throw createError({
statusCode: 403,
statusMessage,
})
}
return session
}

View File

@@ -0,0 +1,8 @@
export const genId = array => {
const { length } = array
let lastIndex = 0
if (length)
lastIndex = Number(array[length - 1]?.id) + 1
return lastIndex || (length + 1)
}

View File

@@ -0,0 +1,11 @@
export const getIntId = (event, msg404 = 'Id is required to get item details') => {
const id = Number(event.context.params?.id)
if (!id || !Number.isInteger(id)) {
throw createError({
statusCode: 404,
statusMessage: msg404,
})
}
return id
}

View File

@@ -0,0 +1,8 @@
import { ensurePrefix } from '@antfu/utils'
export const getPublicUrl = path => {
const baseUrl = process.env.NUXT_APP_BASE_URL ?? ''
const pathWithBaseUrl = `${baseUrl}${path}`
return `${ensurePrefix('/', pathWithBaseUrl)}`.replaceAll('//', '/')
}

View File

@@ -0,0 +1 @@
export const paginateArray = (array, perPage, page) => array.slice((page - 1) * perPage, page * perPage)

View File

@@ -0,0 +1,6 @@
export const paginationMeta = (options, total) => {
const start = (options.page - 1) * options.itemsPerPage + 1
const end = Math.min(options.page * options.itemsPerPage, total)
return `Showing ${total === 0 ? 0 : start} to ${end} of ${total} entries`
}