All files / json-crdt-server/src/routes/presence/methods remove.ts

100% Statements 9/9
100% Branches 0/0
100% Functions 3/3
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30    4x 4x 93x 93x                     93x   93x           93x 2x 2x      
import type {RouteDeps, Router, RouterBase} from '../../types';
 
export const remove =
  ({t, services}: RouteDeps) =>
  <R extends RouterBase>(r: Router<R>) => {
    const Request = t.Object(
      t.Key('room', t.str).options({
        title: 'Room ID',
        description: 'The ID of the room from which to remove the entry.',
      }),
      t.Key('id', t.str).options({
        title: 'ID of the entry',
        description: 'The ID of the entry to remove.',
      }),
    );
 
    const Response = t.obj;
 
    const Func = t.Function(Request, Response).options({
      title: 'Remove a presence entry.',
      intro: 'Removes a presence entry from a room and notifies all listeners.',
      description: 'This method removes a presence entry from a room and notifies all listeners. ',
    });
 
    return r.add('presence.remove', Func, async ({room, id}) => {
      await services.presence.remove(room, id);
      return {};
    });
  };