zapier webhooks

This commit is contained in:
Catalin Pit
2024-02-23 15:02:53 +02:00
parent 91375a17c2
commit 99a26065a8
13 changed files with 232 additions and 3 deletions

View File

@ -0,0 +1,16 @@
import { getUserByApiToken } from '../../public-api/get-user-by-token';
type ValidateApiTokenOptions = {
authorization: string | undefined;
};
export const validateApiToken = async ({ authorization }: ValidateApiTokenOptions) => {
try {
// Support for both "Authorization: Bearer api_xxx" and "Authorization: api_xxx"
const [token] = (authorization || '').split('Bearer ').filter((s) => s.length > 0);
return await getUserByApiToken({ token });
} catch (err) {
throw new Error(`Failed to validate API token`);
}
};