Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ import type { TransportConnection, Application } from '@feathersjs/feathers'
import authenticationClient from '@feathersjs/authentication-client'
import type { AuthenticationClientOptions } from '@feathersjs/authentication-client'

import { tfAgegroupClient } from './services/track-field/agegroup/agegroup.shared'
export type {
TfAgegroup,
TfAgegroupData,
TfAgegroupQuery,
TfAgegroupPatch
} from './services/track-field/agegroup/agegroup.shared'

import { tfItemClient } from './services/track-field/item/item.shared'
export type { TfItem, TfItemData, TfItemQuery, TfItemPatch } from './services/track-field/item/item.shared'

Expand Down Expand Up @@ -56,5 +64,6 @@ export const createClient = <Configuration = any>(
client.configure(tfSeasonClient)
client.configure(tfTeamClient)
client.configure(tfItemClient)
client.configure(tfAgegroupClient)
return client
}
2 changes: 2 additions & 0 deletions src/services/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { tfAgegroup } from './track-field/agegroup/agegroup'
import { tfItem } from './track-field/item/item'
import { tfPlayer } from './track-field/player/player'
import { tfTeam } from './track-field/team/team'
Expand All @@ -6,6 +7,7 @@ import { tfSeason } from './track-field/season/season'
import type { Application } from '../declarations'

export const services = (app: Application) => {
app.configure(tfAgegroup)
app.configure(tfItem)
app.configure(tfPlayer)
app.configure(tfTeam)
Expand Down
27 changes: 27 additions & 0 deletions src/services/track-field/agegroup/agegroup.class.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// For more information about this file see https://dove.feathersjs.com/guides/cli/service.class.html#database-services
import type { Params } from '@feathersjs/feathers'
import { KnexService } from '@feathersjs/knex'
import type { KnexAdapterParams, KnexAdapterOptions } from '@feathersjs/knex'

import type { Application } from '../../../declarations'
import type { TfAgegroup, TfAgegroupData, TfAgegroupPatch, TfAgegroupQuery } from './agegroup.schema'

export type { TfAgegroup, TfAgegroupData, TfAgegroupPatch, TfAgegroupQuery }

export interface TfAgegroupParams extends KnexAdapterParams<TfAgegroupQuery> {}

// By default calls the standard Knex adapter service methods but can be customized with your own functionality.
export class TfAgegroupService<ServiceParams extends Params = TfAgegroupParams> extends KnexService<
TfAgegroup,
TfAgegroupData,
TfAgegroupParams,
TfAgegroupPatch
> {}

export const getOptions = (app: Application): KnexAdapterOptions => {
return {
paginate: app.get('paginate'),
Model: app.get('mysqlClient'),
name: 'ctfc_agegroup'
}
}
58 changes: 58 additions & 0 deletions src/services/track-field/agegroup/agegroup.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// // For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html
import { resolve } from '@feathersjs/schema'
import { Type, getValidator, querySyntax } from '@feathersjs/typebox'
import type { Static } from '@feathersjs/typebox'

import type { HookContext } from '../../../declarations'
import { dataValidator, queryValidator } from '../../../validators'
import { toLowerCaseProperty } from '../../../utilities/property-name-converter'

// Main data model schema
export const tfAgegroupSchema = Type.Object(
{
id: Type.Number(),
name: Type.String(),
minage: Type.Number(),
maxage: Type.Number()
},
{ $id: 'TfAgegroup', additionalProperties: false }
)
export type TfAgegroup = Static<typeof tfAgegroupSchema>
export const tfAgegroupValidator = getValidator(tfAgegroupSchema, dataValidator)
export const tfAgegroupResolver = resolve<TfAgegroup, HookContext>({}, {
converter: async (rawData) => {
return toLowerCaseProperty(rawData, tfAgegroupSchema)
}
});

export const tfAgegroupExternalResolver = resolve<TfAgegroup, HookContext>({})

// Schema for creating new entries
export const tfAgegroupDataSchema = Type.Pick(tfAgegroupSchema, ['name'], {
$id: 'TfAgegroupData'
})
export type TfAgegroupData = Static<typeof tfAgegroupDataSchema>
export const tfAgegroupDataValidator = getValidator(tfAgegroupDataSchema, dataValidator)
export const tfAgegroupDataResolver = resolve<TfAgegroup, HookContext>({})

// Schema for updating existing entries
export const tfAgegroupPatchSchema = Type.Partial(tfAgegroupSchema, {
$id: 'TfAgegroupPatch'
})
export type TfAgegroupPatch = Static<typeof tfAgegroupPatchSchema>
export const tfAgegroupPatchValidator = getValidator(tfAgegroupPatchSchema, dataValidator)
export const tfAgegroupPatchResolver = resolve<TfAgegroup, HookContext>({})

// Schema for allowed query properties
export const tfAgegroupQueryProperties = Type.Pick(tfAgegroupSchema, ['id', 'name','minage','maxage'])
export const tfAgegroupQuerySchema = Type.Intersect(
[
querySyntax(tfAgegroupQueryProperties),
// Add additional query properties here
Type.Object({}, { additionalProperties: false })
],
{ additionalProperties: false }
)
export type TfAgegroupQuery = Static<typeof tfAgegroupQuerySchema>
export const tfAgegroupQueryValidator = getValidator(tfAgegroupQuerySchema, queryValidator)
export const tfAgegroupQueryResolver = resolve<TfAgegroupQuery, HookContext>({})
36 changes: 36 additions & 0 deletions src/services/track-field/agegroup/agegroup.shared.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// For more information about this file see https://dove.feathersjs.com/guides/cli/service.shared.html
import type { Params } from '@feathersjs/feathers'
import type { ClientApplication } from '../../../client'
import type {
TfAgegroup,
TfAgegroupData,
TfAgegroupPatch,
TfAgegroupQuery,
TfAgegroupService
} from './agegroup.class'

export type { TfAgegroup, TfAgegroupData, TfAgegroupPatch, TfAgegroupQuery }

export type TfAgegroupClientService = Pick<
TfAgegroupService<Params<TfAgegroupQuery>>,
(typeof tfAgegroupMethods)[number]
>

export const tfAgegroupPath = 'track-field/agegroup'

export const tfAgegroupMethods = ['find', 'get', 'create', 'patch', 'remove'] as const

export const tfAgegroupClient = (client: ClientApplication) => {
const connection = client.get('connection')

client.use(tfAgegroupPath, connection.service(tfAgegroupPath), {
methods: tfAgegroupMethods
})
}

// Add this service to the client service type index
declare module '../../../client' {
interface ServiceTypes {
[tfAgegroupPath]: TfAgegroupClientService
}
}
71 changes: 71 additions & 0 deletions src/services/track-field/agegroup/agegroup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// For more information about this file see https://dove.feathersjs.com/guides/cli/service.html

import { hooks as schemaHooks } from '@feathersjs/schema'

import {
tfAgegroupDataValidator,
tfAgegroupPatchValidator,
tfAgegroupQueryValidator,
tfAgegroupResolver,
tfAgegroupExternalResolver,
tfAgegroupDataResolver,
tfAgegroupPatchResolver,
tfAgegroupQueryResolver
} from './agegroup.schema'

import type { Application } from '../../../declarations'
import { TfAgegroupService, getOptions } from './agegroup.class'
import { tfAgegroupPath, tfAgegroupMethods } from './agegroup.shared'

export * from './agegroup.class'
export * from './agegroup.schema'

// A configure function that registers the service and its hooks via `app.configure`
export const tfAgegroup = (app: Application) => {
// Register our service on the Feathers application
app.use(tfAgegroupPath, new TfAgegroupService(getOptions(app)), {
// A list of all methods this service exposes externally
methods: tfAgegroupMethods,
// You can add additional custom events to be sent to clients here
events: []
})
// Initialize hooks
app.service(tfAgegroupPath).hooks({
around: {
all: [
schemaHooks.resolveExternal(tfAgegroupExternalResolver),
schemaHooks.resolveResult(tfAgegroupResolver)
]
},
before: {
all: [
schemaHooks.validateQuery(tfAgegroupQueryValidator),
schemaHooks.resolveQuery(tfAgegroupQueryResolver)
],
find: [],
get: [],
create: [
schemaHooks.validateData(tfAgegroupDataValidator),
schemaHooks.resolveData(tfAgegroupDataResolver)
],
patch: [
schemaHooks.validateData(tfAgegroupPatchValidator),
schemaHooks.resolveData(tfAgegroupPatchResolver)
],
remove: []
},
after: {
all: []
},
error: {
all: []
}
})
}

// Add this service to the service type index
declare module '../../../declarations' {
interface ServiceTypes {
[tfAgegroupPath]: TfAgegroupService
}
}
11 changes: 11 additions & 0 deletions test/services/track-field/agegroup/agegroup.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// For more information about this file see https://dove.feathersjs.com/guides/cli/service.test.html
import assert from 'assert'
import { app } from '../../../../src/app'

describe('track-field/agegroup service', () => {
it('registered the service', () => {
const service = app.service('track-field/agegroup')

assert.ok(service, 'Registered the service')
})
})