Service Self-Dependency Issue in TypeScript Repository Implementation

Can a service depend on itself? I think i'm doing something wrong.
I've written a "repository" that has two methods. One method calls the other.
this
wasn't working, so I ended up yielding the service. This feels a bit wrong.

const customHtmlTemplate = CustomHtmlTemplateRepository.of({
  handleUsernamePassword: ({ username, password }) =>
    Effect.gen(function* () {
      if (username !== 'demouser' && password !== 'password') {
        return Effect.fail(InvalidUsernamePassword);
      }
      return Effect.succeed({} as Success);
    }),
  handleActionKey: ({ actionKey, formData }) =>
    Effect.gen(function* () {
      if (actionKey === 'submit') {
        const { handleUsernamePassword } = yield* CustomHtmlTemplateRepository;
        const result = yield* handleUsernamePassword(formData);
      }
      return Effect.succeed({});
    }),
});
Was this page helpful?