Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const getScheme = (schema, action) => {
if (!schema || !schema.access || is.emptyObject(schema.access)) {
return null
}
// Get access object - directly from schema or from the relevant action
const access = getAccessObject(schema.access, action)
// Return if string
if (typeof access === 'string') {
return access
}
// Return access prop if set
if (access.allow !== undefined) {
return access.allow
}
test('headers', wrapper, async (t, server) => {
const request = makeRequest(server.url);
request.end();
const response = await pEvent(request, 'response');
await getStream(response);
t.false(is.emptyObject(response.headers));
t.false(is.emptyArray(response.rawHeaders));
});
const prepareTypeQualifier = ({ attributes = {}, relationships = {}, type }) => (is.emptyObject(attributes) && is.emptyObject(relationships))
? [filter(compare({ path: 'type', match: type }))]
: []
async createUser(
_,
{ email, username, password }: IMutationUserVars,
{ dataSources: { users } }
) {
const verifiedUser = await verifyUniqueUser({ email, username }, (id1, id2) =>
users.findByCondition({
$or: [{ email: id1 }, { username: id2 }]
})
);
if (!is.emptyObject(verifiedUser)) {
const salt = await bcrypt.genSalt(10);
const hash = await bcrypt.hash(password, salt);
const id = uuid();
let user: IUser = await users.create(
Object.assign(
{},
{
email,
username,
id,
password: hash,
admin: false
}
)
);