mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
This commit takes all backend changes for signup and invite feature. I was working on these features and removed the generated mutations for type user along the way.
19 lines
483 B
JavaScript
19 lines
483 B
JavaScript
import { UserInputError } from 'apollo-server'
|
|
|
|
const validateUrl = async (resolve, root, args, context, info) => {
|
|
const { url } = args
|
|
const isValid = url.match(/^(?:https?:\/\/)(?:[^@\n])?(?:www\.)?([^:/\n?]+)/g)
|
|
if (isValid) {
|
|
/* eslint-disable-next-line no-return-await */
|
|
return await resolve(root, args, context, info)
|
|
} else {
|
|
throw new UserInputError('Input is not a URL')
|
|
}
|
|
}
|
|
|
|
export default {
|
|
Mutation: {
|
|
CreateSocialMedia: validateUrl,
|
|
},
|
|
}
|