Makes invites, and checks and claims them at sign-up. An invite works once,
for UNUSED_INVITES_RETENTION_DAYS days. routes/invites.ts makes and
checks them, and POST /api/users claims one.
Marks invite token used and returns the inviter's id. Call it before the
async account creation, and releaseInvite if that fails: checking
first and marking after would let parallel sign-ups share one invite.
Makes an invite from inviterId and returns its token, which the client
puts in the invite link.
Makes a claimed invite usable again, when the sign-up that claimed it failed.
Returns the id of the inviter when invite token is unused and still in its
window, which is the one after which db/startup.ts purges it. It doesn't
claim the invite: sign-up goes through claimInvite.
Usage
import * as mod from "api/services/invite-service.ts";