resolvers

This commit is contained in:
Ulf Gebhardt 2023-06-12 14:07:20 +02:00
parent 1bb3e4e9e6
commit 39cd82dc2a
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
7 changed files with 10 additions and 10 deletions

View File

@ -10,7 +10,7 @@ export const undefinedToNullResolver = (list) => {
return resolvers return resolvers
} }
export default function Resolver(type, options = {}) { export default function Resolver(type, options: any = {}) {
const { const {
idAttribute = 'id', idAttribute = 'id',
undefinedToNull = [], undefinedToNull = [],
@ -44,7 +44,7 @@ export default function Resolver(type, options = {}) {
} }
} }
const booleanResolver = (obj) => { const booleanResolver = (obj: any[]) => {
const resolvers = {} const resolvers = {}
for (const [key, condition] of Object.entries(obj)) { for (const [key, condition] of Object.entries(obj)) {
resolvers[key] = async (parent, params, { cypherParams, driver }, resolveInfo) => { resolvers[key] = async (parent, params, { cypherParams, driver }, resolveInfo) => {

View File

@ -4,7 +4,7 @@ export default function generateInviteCode() {
// 6 random numbers in [ 0, 35 ] are 36 possible numbers (10 [0-9] + 26 [A-Z]) // 6 random numbers in [ 0, 35 ] are 36 possible numbers (10 [0-9] + 26 [A-Z])
return Array.from( return Array.from(
{ length: CONSTANTS_REGISTRATION.INVITE_CODE_LENGTH }, { 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 // 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 // else: it is a number (ASCII 48 is 0) -> 0 + 48 = 48
return String.fromCharCode(n > 9 ? n + 55 : n + 48) return String.fromCharCode(n > 9 ? n + 55 : n + 48)

View File

@ -4,7 +4,7 @@ import CONSTANTS_REGISTRATION from './../../../constants/registration'
export default function generateNonce() { export default function generateNonce() {
return Array.from( return Array.from(
{ length: CONSTANTS_REGISTRATION.NONCE_LENGTH }, { length: CONSTANTS_REGISTRATION.NONCE_LENGTH },
(n = Math.floor(Math.random() * 10)) => { (n: number = Math.floor(Math.random() * 10)) => {
return String.fromCharCode(n + 48) return String.fromCharCode(n + 48)
}, },
).join('') ).join('')

View File

@ -10,7 +10,7 @@ import CONFIG from '../../../config'
// const widths = [34, 160, 320, 640, 1024] // const widths = [34, 160, 320, 640, 1024]
const { AWS_ENDPOINT: endpoint, AWS_REGION: region, AWS_BUCKET: Bucket, S3_CONFIGURED } = CONFIG 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) sanitizeRelationshipType(relationshipType)
const { transaction, deleteCallback } = opts const { transaction, deleteCallback } = opts
if (!transaction) return wrapTransaction(deleteImage, [resource, relationshipType], opts) if (!transaction) return wrapTransaction(deleteImage, [resource, relationshipType], opts)
@ -32,7 +32,7 @@ export async function deleteImage(resource, relationshipType, opts = {}) {
return image 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 (typeof imageInput === 'undefined') return
if (imageInput === null) return deleteImage(resource, relationshipType, opts) if (imageInput === null) return deleteImage(resource, relationshipType, opts)
sanitizeRelationshipType(relationshipType) sanitizeRelationshipType(relationshipType)

View File

@ -244,7 +244,7 @@ export default {
] ]
params.limit = 15 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) return getSearchResults(context, type.setup, params)
}, },
}, },

View File

@ -4,7 +4,7 @@ export default {
Query: { Query: {
statistics: async (_parent, _args, { driver }) => { statistics: async (_parent, _args, { driver }) => {
const session = driver.session() const session = driver.session()
const counts = {} const counts: any = {}
try { try {
const mapping = { const mapping = {
countUsers: 'User', countUsers: 'User',

View File

@ -72,7 +72,7 @@ export const createOrUpdateLocations = async (nodeLabel, nodeId, locationName, s
let locationId let locationId
if (locationName !== null) { if (locationName !== null) {
const res = await fetch( const res: any = await fetch(
`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent( `https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(
locationName, locationName,
)}.json?access_token=${ )}.json?access_token=${
@ -155,7 +155,7 @@ export const createOrUpdateLocations = async (nodeLabel, nodeId, locationName, s
} }
export const queryLocations = async ({ place, lang }) => { 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}`, `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 // Return empty array if no location found or error occurred