This commit is contained in:
ryanwong
2022-02-06 22:15:10 -05:00
parent 46625dd6cd
commit a07577bffa
145 changed files with 12008 additions and 0 deletions
View File
+36
View File
@@ -0,0 +1,36 @@
"use strict";
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
/**
* activity_log Resolve Add
* @copyright 2021 Manaknightdigital Inc.
* @link https://manaknightdigital.com
* @license Proprietary Software licensing
* @author Ryan Wong
*
*/
const { ApolloError ,UserInputError} = require('apollo-server-express');
const { Validator } = require('node-input-validator');
module.exports = async (parent, args, {db}, info) => {
try {
const { name } = args;
const v = new Validator({ }, { });
v.check().then(function (matched) {
if (!matched) {
Object.keys(v.errors).forEach((error) => {
return new UserInputError(v.errors[error].message);
});
}
});
return await db.activity_log.insert({ name },{returnAllFields: true});
} catch (error) {
console.log('create_activity_log -> error', error);
return new ApolloError('InternalServerError');
}
};
+36
View File
@@ -0,0 +1,36 @@
"use strict";
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
/**
* calendar Resolve Add
* @copyright 2021 Manaknightdigital Inc.
* @link https://manaknightdigital.com
* @license Proprietary Software licensing
* @author Ryan Wong
*
*/
const { ApolloError ,UserInputError} = require('apollo-server-express');
const { Validator } = require('node-input-validator');
module.exports = async (parent, args, {db}, info) => {
try {
const { } = args;
const v = new Validator({ }, { });
v.check().then(function (matched) {
if (!matched) {
Object.keys(v.errors).forEach((error) => {
return new UserInputError(v.errors[error].message);
});
}
});
return await db.calendar.insert({ },{returnAllFields: true});
} catch (error) {
console.log('create_calendar -> error', error);
return new ApolloError('InternalServerError');
}
};
+36
View File
@@ -0,0 +1,36 @@
"use strict";
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
/**
* code Resolve Add
* @copyright 2021 Manaknightdigital Inc.
* @link https://manaknightdigital.com
* @license Proprietary Software licensing
* @author Ryan Wong
*
*/
const { ApolloError ,UserInputError} = require('apollo-server-express');
const { Validator } = require('node-input-validator');
module.exports = async (parent, args, {db}, info) => {
try {
const { code } = args;
const v = new Validator({ code: args.code}, { code: "required" });
v.check().then(function (matched) {
if (!matched) {
Object.keys(v.errors).forEach((error) => {
return new UserInputError(v.errors[error].message);
});
}
});
return await db.code.insert({ code },{returnAllFields: true});
} catch (error) {
console.log('create_code -> error', error);
return new ApolloError('InternalServerError');
}
};
+40
View File
@@ -0,0 +1,40 @@
"use strict";
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
/**
* credential Resolve Add
* @copyright 2021 Manaknightdigital Inc.
* @link https://manaknightdigital.com
* @license Proprietary Software licensing
* @author Ryan Wong
*
*/
const { ApolloError ,UserInputError} = require('apollo-server-express');
const { Validator } = require('node-input-validator');
module.exports = async (parent, args, {db}, info) => {
try {
const { email,
password } = args;
const v = new Validator({ email: args.email,
password: args.password}, { email: "required|valid_email",
password: "required" });
v.check().then(function (matched) {
if (!matched) {
Object.keys(v.errors).forEach((error) => {
return new UserInputError(v.errors[error].message);
});
}
});
return await db.credential.insert({ email,
password },{returnAllFields: true});
} catch (error) {
console.log('create_credential -> error', error);
return new ApolloError('InternalServerError');
}
};
+38
View File
@@ -0,0 +1,38 @@
"use strict";
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
/**
* image Resolve Add
* @copyright 2021 Manaknightdigital Inc.
* @link https://manaknightdigital.com
* @license Proprietary Software licensing
* @author Ryan Wong
*
*/
const { ApolloError ,UserInputError} = require('apollo-server-express');
const { Validator } = require('node-input-validator');
module.exports = async (parent, args, {db}, info) => {
try {
const { url,
caption } = args;
const v = new Validator({ url: args.url}, { url: "required" });
v.check().then(function (matched) {
if (!matched) {
Object.keys(v.errors).forEach((error) => {
return new UserInputError(v.errors[error].message);
});
}
});
return await db.image.insert({ url,
caption },{returnAllFields: true});
} catch (error) {
console.log('create_image -> error', error);
return new ApolloError('InternalServerError');
}
};
+73
View File
@@ -0,0 +1,73 @@
'use strict';
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
/**
* links Resolve Add
* @copyright 2021 Manaknightdigital Inc.
* @link https://manaknightdigital.com
* @license Proprietary Software licensing
* @author Ryan Wong
*
*/
const request = require('request-promise');
const { validateInputForGraphql } = require('../../services/ValidationService');
const { formatError } = require('../../utils/formatError');
const { errorCodes } = require('../../core/strings');
const inputValidations = {
Mutation: {
createLink: (resolver = () => null) => {
return validateInputForGraphql(
resolver,
{
link: 'required|string',
},
{
'link.required': 'Link field is required.',
'link.string': 'Link field should be a string.',
},
);
},
},
};
module.exports = inputValidations.Mutation.createLink(async (_, { link }, { db, user }) => {
try {
const previousLinks = await db.link.getAll({ user_id: user.id, status: 1 });
try {
const urlResponse = await request({ uri: link, resolveWithFullResponse: true, method: 'GET' });
const headers = urlResponse?.headers;
const xFrameHeader = headers['x-frame-options'];
if (xFrameHeader && (xFrameHeader === 'SAMEORIGIN' || xFrameHeader === 'DENY')) {
return {
success: false,
message: 'Iframe blocked to given link.',
code: errorCodes.extra.IFRAME_BLOCKED,
};
}
} catch (error) {
return {
success: false,
message: 'Link invalid or not available at the moment.',
code: errorCodes.extra.INVALID_URL,
};
}
if (previousLinks?.length) {
await db.link.update(
{ status: 0 },
{
where: { id: previousLinks?.map((link) => link.id) },
},
);
}
await db.link.insert({ link, user_id: user.id });
return {
success: true,
message: 'Link inserted successfully.',
};
} catch (error) {
return formatError(error);
}
});
+36
View File
@@ -0,0 +1,36 @@
"use strict";
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
/**
* note Resolve Add
* @copyright 2021 Manaknightdigital Inc.
* @link https://manaknightdigital.com
* @license Proprietary Software licensing
* @author Ryan Wong
*
*/
const { ApolloError ,UserInputError} = require('apollo-server-express');
const { Validator } = require('node-input-validator');
module.exports = async (parent, args, {db}, info) => {
try {
const { } = args;
const v = new Validator({ }, { });
v.check().then(function (matched) {
if (!matched) {
Object.keys(v.errors).forEach((error) => {
return new UserInputError(v.errors[error].message);
});
}
});
return await db.note.insert({ },{returnAllFields: true});
} catch (error) {
console.log('create_note -> error', error);
return new ApolloError('InternalServerError');
}
};
+40
View File
@@ -0,0 +1,40 @@
"use strict";
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
/**
* profile Resolve Add
* @copyright 2021 Manaknightdigital Inc.
* @link https://manaknightdigital.com
* @license Proprietary Software licensing
* @author Ryan Wong
*
*/
const { ApolloError ,UserInputError} = require('apollo-server-express');
const { Validator } = require('node-input-validator');
module.exports = async (parent, args, {db}, info) => {
try {
const { timezone,
dashboard_code } = args;
const v = new Validator({ timezone: args.timezone,
dashboard_code: args.dashboard_code}, { timezone: "required",
dashboard_code: "required" });
v.check().then(function (matched) {
if (!matched) {
Object.keys(v.errors).forEach((error) => {
return new UserInputError(v.errors[error].message);
});
}
});
return await db.profile.insert({ timezone,
dashboard_code },{returnAllFields: true});
} catch (error) {
console.log('create_profile -> error', error);
return new ApolloError('InternalServerError');
}
};
+40
View File
@@ -0,0 +1,40 @@
"use strict";
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
/**
* refer_log Resolve Add
* @copyright 2021 Manaknightdigital Inc.
* @link https://manaknightdigital.com
* @license Proprietary Software licensing
* @author Ryan Wong
*
*/
const { ApolloError ,UserInputError} = require('apollo-server-express');
const { Validator } = require('node-input-validator');
module.exports = async (parent, args, {db}, info) => {
try {
const { type,
status } = args;
const v = new Validator({ type: args.type,
status: args.status}, { type: "required|integer",
status: "required|integer" });
v.check().then(function (matched) {
if (!matched) {
Object.keys(v.errors).forEach((error) => {
return new UserInputError(v.errors[error].message);
});
}
});
return await db.refer_log.insert({ type,
status },{returnAllFields: true});
} catch (error) {
console.log('create_refer_log -> error', error);
return new ApolloError('InternalServerError');
}
};
+39
View File
@@ -0,0 +1,39 @@
'use strict';
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
/**
* user Resolve Add
* @copyright 2021 Manaknightdigital Inc.
* @link https://manaknightdigital.com
* @license Proprietary Software licensing
* @author Ryan Wong
*
*/
const { ApolloError, UserInputError } = require('apollo-server-express');
const { Validator } = require('node-input-validator');
module.exports = async (parent, args, { db }, info) => {
try {
const { first_name, last_name, phone } = args;
const v = new Validator(
{
first_name: args.first_name,
last_name: args.last_name,
},
{ first_name: 'required', last_name: 'required' },
);
v.check().then(function (matched) {
if (!matched) {
Object.keys(v.errors).forEach((error) => {
return new UserInputError(v.errors[error].message);
});
}
});
return await db.user.insert({ first_name, last_name, phone }, { returnAllFields: true });
} catch (error) {
console.log('create_user -> error', error);
return new ApolloError('InternalServerError');
}
};