users.shared.ts 928 B

123456789101112131415161718192021222324252627
  1. // For more information about this file see https://dove.feathersjs.com/guides/cli/service.shared.html
  2. import type { Params } from '@feathersjs/feathers'
  3. import type { ClientApplication } from '../../client'
  4. import type { User, UserData, UserPatch, UserQuery, UserService } from './users.class'
  5. export type { User, UserData, UserPatch, UserQuery }
  6. export type UserClientService = Pick<UserService<Params<UserQuery>>, (typeof userMethods)[number]>
  7. export const userPath = 'users'
  8. export const userMethods: Array<keyof UserService> = ['find', 'get', 'create', 'patch', 'remove']
  9. export const userClient = (client: ClientApplication) => {
  10. const connection = client.get('connection')
  11. client.use(userPath, connection.service(userPath), {
  12. methods: userMethods
  13. })
  14. }
  15. // Add this service to the client service type index
  16. declare module '../../client' {
  17. interface ServiceTypes {
  18. [userPath]: UserClientService
  19. }
  20. }