mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
resolvers
This commit is contained in:
parent
1bb3e4e9e6
commit
39cd82dc2a
@ -10,7 +10,7 @@ export const undefinedToNullResolver = (list) => {
|
||||
return resolvers
|
||||
}
|
||||
|
||||
export default function Resolver(type, options = {}) {
|
||||
export default function Resolver(type, options: any = {}) {
|
||||
const {
|
||||
idAttribute = 'id',
|
||||
undefinedToNull = [],
|
||||
@ -44,7 +44,7 @@ export default function Resolver(type, options = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
const booleanResolver = (obj) => {
|
||||
const booleanResolver = (obj: any[]) => {
|
||||
const resolvers = {}
|
||||
for (const [key, condition] of Object.entries(obj)) {
|
||||
resolvers[key] = async (parent, params, { cypherParams, driver }, resolveInfo) => {
|
||||
|
||||
@ -4,7 +4,7 @@ export default function generateInviteCode() {
|
||||
// 6 random numbers in [ 0, 35 ] are 36 possible numbers (10 [0-9] + 26 [A-Z])
|
||||
return Array.from(
|
||||
{ length: CONSTANTS_REGISTRATION.INVITE_CODE_LENGTH },
|
||||
(n = Math.floor(Math.random() * 36)) => {
|
||||
(n: number = Math.floor(Math.random() * 36)) => {
|
||||
// n > 9: it is a letter (ASCII 65 is A) -> 10 + 55 = 65
|
||||
// else: it is a number (ASCII 48 is 0) -> 0 + 48 = 48
|
||||
return String.fromCharCode(n > 9 ? n + 55 : n + 48)
|
||||
|
||||
@ -4,7 +4,7 @@ import CONSTANTS_REGISTRATION from './../../../constants/registration'
|
||||
export default function generateNonce() {
|
||||
return Array.from(
|
||||
{ length: CONSTANTS_REGISTRATION.NONCE_LENGTH },
|
||||
(n = Math.floor(Math.random() * 10)) => {
|
||||
(n: number = Math.floor(Math.random() * 10)) => {
|
||||
return String.fromCharCode(n + 48)
|
||||
},
|
||||
).join('')
|
||||
|
||||
@ -10,7 +10,7 @@ import CONFIG from '../../../config'
|
||||
// const widths = [34, 160, 320, 640, 1024]
|
||||
const { AWS_ENDPOINT: endpoint, AWS_REGION: region, AWS_BUCKET: Bucket, S3_CONFIGURED } = CONFIG
|
||||
|
||||
export async function deleteImage(resource, relationshipType, opts = {}) {
|
||||
export async function deleteImage(resource, relationshipType, opts: any = {}) {
|
||||
sanitizeRelationshipType(relationshipType)
|
||||
const { transaction, deleteCallback } = opts
|
||||
if (!transaction) return wrapTransaction(deleteImage, [resource, relationshipType], opts)
|
||||
@ -32,7 +32,7 @@ export async function deleteImage(resource, relationshipType, opts = {}) {
|
||||
return image
|
||||
}
|
||||
|
||||
export async function mergeImage(resource, relationshipType, imageInput, opts = {}) {
|
||||
export async function mergeImage(resource, relationshipType, imageInput, opts: any = {}) {
|
||||
if (typeof imageInput === 'undefined') return
|
||||
if (imageInput === null) return deleteImage(resource, relationshipType, opts)
|
||||
sanitizeRelationshipType(relationshipType)
|
||||
|
||||
@ -244,7 +244,7 @@ export default {
|
||||
]
|
||||
|
||||
params.limit = 15
|
||||
const type = multiSearchMap.find((obj) => obj.symbol === searchType)
|
||||
const type: any = multiSearchMap.find((obj) => obj.symbol === searchType)
|
||||
return getSearchResults(context, type.setup, params)
|
||||
},
|
||||
},
|
||||
|
||||
@ -4,7 +4,7 @@ export default {
|
||||
Query: {
|
||||
statistics: async (_parent, _args, { driver }) => {
|
||||
const session = driver.session()
|
||||
const counts = {}
|
||||
const counts: any = {}
|
||||
try {
|
||||
const mapping = {
|
||||
countUsers: 'User',
|
||||
|
||||
@ -72,7 +72,7 @@ export const createOrUpdateLocations = async (nodeLabel, nodeId, locationName, s
|
||||
let locationId
|
||||
|
||||
if (locationName !== null) {
|
||||
const res = await fetch(
|
||||
const res: any = await fetch(
|
||||
`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(
|
||||
locationName,
|
||||
)}.json?access_token=${
|
||||
@ -155,7 +155,7 @@ export const createOrUpdateLocations = async (nodeLabel, nodeId, locationName, s
|
||||
}
|
||||
|
||||
export const queryLocations = async ({ place, lang }) => {
|
||||
const res = await fetch(
|
||||
const res: any = await fetch(
|
||||
`https://api.mapbox.com/geocoding/v5/mapbox.places/${place}.json?access_token=${CONFIG.MAPBOX_TOKEN}&types=region,place,country&language=${lang}`,
|
||||
)
|
||||
// Return empty array if no location found or error occurred
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user