diff --git a/backend/src/activitypub/ActivityPub.js b/backend/src/activitypub/ActivityPub.js index 12671f330..cd16f620e 100644 --- a/backend/src/activitypub/ActivityPub.js +++ b/backend/src/activitypub/ActivityPub.js @@ -35,8 +35,8 @@ export default class ActivityPub { handleFollowActivity(activity) { debug(`inside FOLLOW ${activity.actor}`) - let toActorName = extractNameFromId(activity.object) - let fromDomain = extractDomainFromUrl(activity.actor) + const toActorName = extractNameFromId(activity.object) + const fromDomain = extractDomainFromUrl(activity.actor) const dataSource = this.dataSource return new Promise((resolve, reject) => { @@ -53,7 +53,7 @@ export default class ActivityPub { toActorObject = JSON.parse(toActorObject) await this.dataSource.addSharedInboxEndpoint(toActorObject.endpoints.sharedInbox) - let followersCollectionPage = await this.dataSource.getFollowersCollectionPage( + const followersCollectionPage = await this.dataSource.getFollowersCollectionPage( activity.object, ) @@ -222,6 +222,7 @@ export default class ActivityPub { }) } } + async trySend(activity, fromName, host, url, tries = 5) { try { return await signAndSend(activity, fromName, host, url) diff --git a/backend/src/activitypub/Collections.js b/backend/src/activitypub/Collections.js index 641db596a..4040468cf 100644 --- a/backend/src/activitypub/Collections.js +++ b/backend/src/activitypub/Collections.js @@ -2,6 +2,7 @@ export default class Collections { constructor(dataSource) { this.dataSource = dataSource } + getFollowersCollection(actorId) { return this.dataSource.getFollowersCollection(actorId) } diff --git a/backend/src/activitypub/NitroDataSource.js b/backend/src/activitypub/NitroDataSource.js index 0900bed6c..dfdbf6c14 100644 --- a/backend/src/activitypub/NitroDataSource.js +++ b/backend/src/activitypub/NitroDataSource.js @@ -303,6 +303,7 @@ export default class NitroDataSource { }), ) } + async saveFollowingCollectionPage(followingCollection, onlyNewestItem = true) { debug('inside saveFollowers') let orderedItems = followingCollection.orderedItems @@ -470,6 +471,7 @@ export default class NitroDataSource { throwErrorIfApolloErrorOccurred(result) return result.data.SharedInboxEnpoint } + async addSharedInboxEndpoint(uri) { try { const result = await this.client.mutate({ diff --git a/backend/src/activitypub/security/index.js b/backend/src/activitypub/security/index.js index 9b48b7ed9..05642ed26 100644 --- a/backend/src/activitypub/security/index.js +++ b/backend/src/activitypub/security/index.js @@ -97,7 +97,7 @@ export function verifySignature(url, headers) { // private: signing function constructSigningString(url, headers) { const urlObj = new URL(url) - let signingString = `(request-target): post ${urlObj.pathname}${ + const signingString = `(request-target): post ${urlObj.pathname}${ urlObj.search !== '' ? urlObj.search : '' }` return Object.keys(headers).reduce((result, key) => { diff --git a/backend/src/activitypub/utils/index.js b/backend/src/activitypub/utils/index.js index 3927f4056..5f26c635f 100644 --- a/backend/src/activitypub/utils/index.js +++ b/backend/src/activitypub/utils/index.js @@ -40,70 +40,72 @@ export function signAndSend(activity, fromName, targetDomain, url) { // fix for development: replace with http url = url.indexOf('localhost') > -1 ? url.replace('https', 'http') : url debug(`passhprase = ${CONFIG.PRIVATE_KEY_PASSPHRASE}`) - return new Promise(async (resolve, reject) => { + return new Promise((resolve, reject) => { debug('inside signAndSend') // get the private key - const result = await activityPub.dataSource.client.query({ - query: gql` + activityPub.dataSource.client + .query({ + query: gql` query { User(slug: "${fromName}") { privateKey } } `, - }) + }) + .then(result => { + if (result.error) { + reject(result.error) + } else { + // add security context + const parsedActivity = JSON.parse(activity) + if (Array.isArray(parsedActivity['@context'])) { + parsedActivity['@context'].push('https://w3id.org/security/v1') + } else { + const context = [parsedActivity['@context']] + context.push('https://w3id.org/security/v1') + parsedActivity['@context'] = context + } - if (result.error) { - reject(result.error) - } else { - // add security context - const parsedActivity = JSON.parse(activity) - if (Array.isArray(parsedActivity['@context'])) { - parsedActivity['@context'].push('https://w3id.org/security/v1') - } else { - const context = [parsedActivity['@context']] - context.push('https://w3id.org/security/v1') - parsedActivity['@context'] = context - } + // deduplicate context strings + parsedActivity['@context'] = [...new Set(parsedActivity['@context'])] + const privateKey = result.data.User[0].privateKey + const date = new Date().toUTCString() - // deduplicate context strings - parsedActivity['@context'] = [...new Set(parsedActivity['@context'])] - const privateKey = result.data.User[0].privateKey - const date = new Date().toUTCString() - - debug(`url = ${url}`) - request( - { - url: url, - headers: { - Host: targetDomain, - Date: date, - Signature: createSignature({ - privateKey, - keyId: `${activityPub.endpoint}/activitypub/users/${fromName}#main-key`, - url, + debug(`url = ${url}`) + request( + { + url: url, headers: { Host: targetDomain, Date: date, + Signature: createSignature({ + privateKey, + keyId: `${activityPub.endpoint}/activitypub/users/${fromName}#main-key`, + url, + headers: { + Host: targetDomain, + Date: date, + 'Content-Type': 'application/activity+json', + }, + }), 'Content-Type': 'application/activity+json', }, - }), - 'Content-Type': 'application/activity+json', - }, - method: 'POST', - body: JSON.stringify(parsedActivity), - }, - (error, response) => { - if (error) { - debug(`Error = ${JSON.stringify(error, null, 2)}`) - reject(error) - } else { - debug('Response Headers:', JSON.stringify(response.headers, null, 2)) - debug('Response Body:', JSON.stringify(response.body, null, 2)) - resolve() - } - }, - ) - } + method: 'POST', + body: JSON.stringify(parsedActivity), + }, + (error, response) => { + if (error) { + debug(`Error = ${JSON.stringify(error, null, 2)}`) + reject(error) + } else { + debug('Response Headers:', JSON.stringify(response.headers, null, 2)) + debug('Response Body:', JSON.stringify(response.body, null, 2)) + resolve() + } + }, + ) + } + }) }) } diff --git a/backend/src/middleware/permissionsMiddleware.js b/backend/src/middleware/permissionsMiddleware.js index afc38a65c..d972603a6 100644 --- a/backend/src/middleware/permissionsMiddleware.js +++ b/backend/src/middleware/permissionsMiddleware.js @@ -97,8 +97,6 @@ const invitationLimitReached = rule({ return record.get('limitReached') }) return limitReached - } catch (e) { - throw e } finally { session.close() } diff --git a/backend/src/middleware/slugify/uniqueSlug.js b/backend/src/middleware/slugify/uniqueSlug.js index 69aef2d1b..ca37cd562 100644 --- a/backend/src/middleware/slugify/uniqueSlug.js +++ b/backend/src/middleware/slugify/uniqueSlug.js @@ -1,6 +1,6 @@ import slugify from 'slug' export default async function uniqueSlug(string, isUnique) { - let slug = slugify(string || 'anonymous', { + const slug = slugify(string || 'anonymous', { lower: true, }) if (await isUnique(slug)) return slug diff --git a/backend/src/middleware/xssMiddleware.js b/backend/src/middleware/xssMiddleware.js index 06aa5b306..6894e8601 100644 --- a/backend/src/middleware/xssMiddleware.js +++ b/backend/src/middleware/xssMiddleware.js @@ -8,8 +8,8 @@ import linkifyHtml from 'linkifyjs/html' const embedToAnchor = content => { const $ = cheerio.load(content) $('div[data-url-embed]').each((i, el) => { - let url = el.attribs['data-url-embed'] - let aTag = $(`${url}`) + const url = el.attribs['data-url-embed'] + const aTag = $(`${url}`) $(el).replaceWith(aTag) }) return $('body').html() @@ -87,7 +87,7 @@ function clean(dirty) { b: 'strong', s: 'strike', img: function(tagName, attribs) { - let src = attribs.src + const src = attribs.src if (!src) { // remove broken images diff --git a/backend/src/schema/resolvers/comments.js b/backend/src/schema/resolvers/comments.js index 31219d6d9..89a2040f4 100644 --- a/backend/src/schema/resolvers/comments.js +++ b/backend/src/schema/resolvers/comments.js @@ -18,7 +18,7 @@ export default { false, ) - let transactionRes = await session.run( + const transactionRes = await session.run( ` MATCH (post:Post {id: $postId}), (comment:Comment {id: $commentId}), (author:User {id: $userId}) MERGE (post)<-[:COMMENTS]-(comment)<-[:WROTE]-(author) diff --git a/backend/src/schema/resolvers/comments.spec.js b/backend/src/schema/resolvers/comments.spec.js index 890ba5feb..e8280bd4b 100644 --- a/backend/src/schema/resolvers/comments.spec.js +++ b/backend/src/schema/resolvers/comments.spec.js @@ -5,7 +5,6 @@ import { host, login, gql } from '../../jest/helpers' const factory = Factory() let client let createCommentVariables -let createPostVariables let createCommentVariablesSansPostId let createCommentVariablesWithNonExistentPost let userParams @@ -26,7 +25,7 @@ const createCommentMutation = gql` } } ` -createPostVariables = { +const createPostVariables = { id: 'p1', title: 'post to comment on', content: 'please comment on me', @@ -325,7 +324,7 @@ describe('ManageComments', () => { } ` - let deleteCommentVariables = { + const deleteCommentVariables = { id: 'c456', } diff --git a/backend/src/schema/resolvers/follow.js b/backend/src/schema/resolvers/follow.js index 4e9a3b27d..730a66cfd 100644 --- a/backend/src/schema/resolvers/follow.js +++ b/backend/src/schema/resolvers/follow.js @@ -4,7 +4,7 @@ export default { const { id, type } = params const session = context.driver.session() - let transactionRes = await session.run( + const transactionRes = await session.run( `MATCH (node {id: $id}), (user:User {id: $userId}) WHERE $type IN labels(node) AND NOT $id = $userId MERGE (user)-[relation:FOLLOWS]->(node) @@ -29,7 +29,7 @@ export default { const { id, type } = params const session = context.driver.session() - let transactionRes = await session.run( + const transactionRes = await session.run( `MATCH (user:User {id: $userId})-[relation:FOLLOWS]->(node {id: $id}) WHERE $type IN labels(node) DELETE relation diff --git a/backend/src/schema/resolvers/follow.spec.js b/backend/src/schema/resolvers/follow.spec.js index d29e17938..66be20841 100644 --- a/backend/src/schema/resolvers/follow.spec.js +++ b/backend/src/schema/resolvers/follow.spec.js @@ -41,8 +41,7 @@ describe('follow', () => { describe('follow user', () => { describe('unauthenticated follow', () => { it('throws authorization error', async () => { - let client - client = new GraphQLClient(host) + const client = new GraphQLClient(host) await expect(client.request(mutationFollowUser('u2'))).rejects.toThrow('Not Authorised') }) }) @@ -93,8 +92,7 @@ describe('follow', () => { // follow await clientUser1.request(mutationFollowUser('u2')) // unfollow - let client - client = new GraphQLClient(host) + const client = new GraphQLClient(host) await expect(client.request(mutationUnfollowUser('u2'))).rejects.toThrow('Not Authorised') }) }) diff --git a/backend/src/schema/resolvers/notifications.spec.js b/backend/src/schema/resolvers/notifications.spec.js index 3876a4be3..8d51ebfbb 100644 --- a/backend/src/schema/resolvers/notifications.spec.js +++ b/backend/src/schema/resolvers/notifications.spec.js @@ -4,7 +4,7 @@ import { host, login } from '../../jest/helpers' const factory = Factory() let client -let userParams = { +const userParams = { id: 'you', email: 'test@example.org', password: '1234', @@ -34,7 +34,7 @@ describe('Notification', () => { }) describe('currentUser { notifications }', () => { - let variables = {} + const variables = {} describe('authenticated', () => { let headers @@ -79,7 +79,7 @@ describe('currentUser { notifications }', () => { } } }` - let variables = { read: false } + const variables = { read: false } it('returns only unread notifications of current user', async () => { const expected = { currentUser: { diff --git a/backend/src/schema/resolvers/passwordReset.js b/backend/src/schema/resolvers/passwordReset.js index 88d82846a..d2012c0fd 100644 --- a/backend/src/schema/resolvers/passwordReset.js +++ b/backend/src/schema/resolvers/passwordReset.js @@ -41,7 +41,7 @@ export default { SET u.encryptedPassword = $encryptedNewPassword RETURN pr ` - let transactionRes = await session.run(cypher, { + const transactionRes = await session.run(cypher, { stillValid, email, code, diff --git a/backend/src/schema/resolvers/passwordReset.spec.js b/backend/src/schema/resolvers/passwordReset.spec.js index 545945f51..b54b25a80 100644 --- a/backend/src/schema/resolvers/passwordReset.spec.js +++ b/backend/src/schema/resolvers/passwordReset.spec.js @@ -10,7 +10,7 @@ const driver = getDriver() const getAllPasswordResets = async () => { const session = driver.session() - let transactionRes = await session.run('MATCH (r:PasswordReset) RETURN r') + const transactionRes = await session.run('MATCH (r:PasswordReset) RETURN r') const resets = transactionRes.records.map(record => record.get('r')) session.close() return resets @@ -84,9 +84,9 @@ describe('passwordReset', () => { } const mutation = `mutation($code: String!, $email: String!, $newPassword: String!) { resetPassword(code: $code, email: $email, newPassword: $newPassword) }` - let email = 'user@example.org' - let code = 'abcdef' - let newPassword = 'supersecret' + const email = 'user@example.org' + const code = 'abcdef' + const newPassword = 'supersecret' let variables describe('invalid email', () => { diff --git a/backend/src/schema/resolvers/posts.spec.js b/backend/src/schema/resolvers/posts.spec.js index 233be450a..6714c93ad 100644 --- a/backend/src/schema/resolvers/posts.spec.js +++ b/backend/src/schema/resolvers/posts.spec.js @@ -337,7 +337,7 @@ describe('DeletePost', () => { } ` - let variables = { + const variables = { id: 'p1', } diff --git a/backend/src/schema/resolvers/registration.spec.js b/backend/src/schema/resolvers/registration.spec.js index dc2e96348..9f9a171f7 100644 --- a/backend/src/schema/resolvers/registration.spec.js +++ b/backend/src/schema/resolvers/registration.spec.js @@ -300,7 +300,7 @@ describe('SignupVerification', () => { } ` describe('given valid password and email', () => { - let variables = { + const variables = { nonce: '123456', name: 'John Doe', password: '123', diff --git a/backend/src/schema/resolvers/reports.js b/backend/src/schema/resolvers/reports.js index 67c896939..79cae032b 100644 --- a/backend/src/schema/resolvers/reports.js +++ b/backend/src/schema/resolvers/reports.js @@ -60,7 +60,7 @@ export default { if (!dbResponse) return null const { report, submitter, resource, type } = dbResponse - let response = { + const response = { ...report.properties, post: null, comment: null, diff --git a/backend/src/schema/resolvers/rewards.js b/backend/src/schema/resolvers/rewards.js index f7a759aa4..74c7860e4 100644 --- a/backend/src/schema/resolvers/rewards.js +++ b/backend/src/schema/resolvers/rewards.js @@ -4,7 +4,7 @@ import { UserInputError } from 'apollo-server' const instance = neode() const getUserAndBadge = async ({ badgeKey, userId }) => { - let user = await instance.first('User', 'id', userId) + const user = await instance.first('User', 'id', userId) const badge = await instance.first('Badge', 'id', badgeKey) if (!user) throw new UserInputError("Couldn't find a user with that id") if (!badge) throw new UserInputError("Couldn't find a badge with that id") @@ -36,8 +36,6 @@ export default { userId, }, ) - } catch (err) { - throw err } finally { session.close() } diff --git a/backend/src/schema/resolvers/shout.js b/backend/src/schema/resolvers/shout.js index d2d7f652e..398e43d77 100644 --- a/backend/src/schema/resolvers/shout.js +++ b/backend/src/schema/resolvers/shout.js @@ -4,7 +4,7 @@ export default { const { id, type } = params const session = context.driver.session() - let transactionRes = await session.run( + const transactionRes = await session.run( `MATCH (node {id: $id})<-[:WROTE]-(userWritten:User), (user:User {id: $userId}) WHERE $type IN labels(node) AND NOT userWritten.id = $userId MERGE (user)-[relation:SHOUTED]->(node) @@ -29,7 +29,7 @@ export default { const { id, type } = params const session = context.driver.session() - let transactionRes = await session.run( + const transactionRes = await session.run( `MATCH (user:User {id: $userId})-[relation:SHOUTED]->(node {id: $id}) WHERE $type IN labels(node) DELETE relation diff --git a/backend/src/schema/resolvers/shout.spec.js b/backend/src/schema/resolvers/shout.spec.js index a94f7ca0b..029e6998c 100644 --- a/backend/src/schema/resolvers/shout.spec.js +++ b/backend/src/schema/resolvers/shout.spec.js @@ -60,8 +60,7 @@ describe('shout', () => { describe('shout foreign post', () => { describe('unauthenticated shout', () => { it('throws authorization error', async () => { - let client - client = new GraphQLClient(host) + const client = new GraphQLClient(host) await expect(client.request(mutationShoutPost('p1'))).rejects.toThrow('Not Authorised') }) }) @@ -109,8 +108,7 @@ describe('shout', () => { // shout await clientUser1.request(mutationShoutPost('p2')) // unshout - let client - client = new GraphQLClient(host) + const client = new GraphQLClient(host) await expect(client.request(mutationUnshoutPost('p2'))).rejects.toThrow('Not Authorised') }) }) diff --git a/backend/src/schema/resolvers/statistics.js b/backend/src/schema/resolvers/statistics.js index f09b7219d..982c2acfa 100644 --- a/backend/src/schema/resolvers/statistics.js +++ b/backend/src/schema/resolvers/statistics.js @@ -1,9 +1,9 @@ export const query = (cypher, session) => { return new Promise((resolve, reject) => { - let data = [] + const data = [] session.run(cypher).subscribe({ onNext: function(record) { - let item = {} + const item = {} record.keys.forEach(key => { item[key] = record.get(key) }) @@ -34,7 +34,7 @@ const queryOne = (cypher, session) => { export default { Query: { statistics: async (parent, args, { driver, user }) => { - return new Promise(async resolve => { + return new Promise(resolve => { const session = driver.session() const queries = { countUsers: @@ -54,18 +54,24 @@ export default { countFollows: 'MATCH (:User)-[r:FOLLOWS]->(:User) RETURN COUNT(r) AS countFollows', countShouts: 'MATCH (:User)-[r:SHOUTED]->(:Post) RETURN COUNT(r) AS countShouts', } - let data = { - countUsers: (await queryOne(queries.countUsers, session)).countUsers.low, - countPosts: (await queryOne(queries.countPosts, session)).countPosts.low, - countComments: (await queryOne(queries.countComments, session)).countComments.low, - countNotifications: (await queryOne(queries.countNotifications, session)) - .countNotifications.low, - countOrganizations: (await queryOne(queries.countOrganizations, session)) - .countOrganizations.low, - countProjects: (await queryOne(queries.countProjects, session)).countProjects.low, - countInvites: (await queryOne(queries.countInvites, session)).countInvites.low, - countFollows: (await queryOne(queries.countFollows, session)).countFollows.low, - countShouts: (await queryOne(queries.countShouts, session)).countShouts.low, + const data = { + countUsers: queryOne(queries.countUsers, session).then(res => res.countUsers.low), + countPosts: queryOne(queries.countPosts, session).then(res => res.countPosts.low), + countComments: queryOne(queries.countComments, session).then( + res => res.countComments.low, + ), + countNotifications: queryOne(queries.countNotifications, session).then( + res => res.countNotifications.low, + ), + countOrganizations: queryOne(queries.countOrganizations, session).then( + res => res.countOrganizations.low, + ), + countProjects: queryOne(queries.countProjects, session).then( + res => res.countProjects.low, + ), + countInvites: queryOne(queries.countInvites, session).then(res => res.countInvites.low), + countFollows: queryOne(queries.countFollows, session).then(res => res.countFollows.low), + countShouts: queryOne(queries.countShouts, session).then(res => res.countShouts.low), } resolve(data) }) diff --git a/backend/src/schema/resolvers/user_management.js b/backend/src/schema/resolvers/user_management.js index 7ed84586b..be790ca3a 100644 --- a/backend/src/schema/resolvers/user_management.js +++ b/backend/src/schema/resolvers/user_management.js @@ -49,7 +49,7 @@ export default { } }, changePassword: async (_, { oldPassword, newPassword }, { driver, user }) => { - let currentUser = await instance.find('User', user.id) + const currentUser = await instance.find('User', user.id) const encryptedPassword = currentUser.get('encryptedPassword') if (!(await bcrypt.compareSync(oldPassword, encryptedPassword))) { diff --git a/backend/src/schema/resolvers/user_management.spec.js b/backend/src/schema/resolvers/user_management.spec.js index 50b5896b3..ff0c0db4e 100644 --- a/backend/src/schema/resolvers/user_management.spec.js +++ b/backend/src/schema/resolvers/user_management.spec.js @@ -296,7 +296,7 @@ describe('change password', () => { describe('correct password', () => { it('changes the password if given correct credentials "', async () => { - let response = await client.request( + const response = await client.request( mutation({ oldPassword: '1234', newPassword: '12345', diff --git a/backend/src/schema/resolvers/users.js b/backend/src/schema/resolvers/users.js index c0826c6c8..77e4ae2aa 100644 --- a/backend/src/schema/resolvers/users.js +++ b/backend/src/schema/resolvers/users.js @@ -23,7 +23,7 @@ export default { UpdateUser: async (object, args, context, resolveInfo) => { args = await fileUpload(args, { file: 'avatarUpload', url: 'avatar' }) try { - let user = await instance.find('User', args.id) + const user = await instance.find('User', args.id) if (!user) return null await user.update(args) return user.toJson() @@ -60,7 +60,7 @@ export default { const { id } = parent const statement = `MATCH(u:User {id: {id}})-[:PRIMARY_EMAIL]->(e:EmailAddress) RETURN e` const result = await instance.cypher(statement, { id }) - let [{ email }] = result.records.map(r => r.get('e').properties) + const [{ email }] = result.records.map(r => r.get('e').properties) return email }, ...Resolver('User', { diff --git a/backend/src/schema/types/index.js b/backend/src/schema/types/index.js index bcdceed44..068af64da 100644 --- a/backend/src/schema/types/index.js +++ b/backend/src/schema/types/index.js @@ -21,7 +21,7 @@ const findGqlFiles = dir => { return results } -let typeDefs = [] +const typeDefs = [] findGqlFiles(__dirname).forEach(file => { typeDefs.push(fs.readFileSync(file).toString('utf-8')) diff --git a/backend/src/seed/factories/index.js b/backend/src/seed/factories/index.js index e841b0beb..0efb2a886 100644 --- a/backend/src/seed/factories/index.js +++ b/backend/src/seed/factories/index.js @@ -40,15 +40,13 @@ export const cleanDatabase = async (options = {}) => { const cypher = 'MATCH (n) DETACH DELETE n' try { return await session.run(cypher) - } catch (error) { - throw error } finally { session.close() } } export default function Factory(options = {}) { - let { + const { seedServerHost = 'http://127.0.0.1:4001', neo4jDriver = getDriver(), neodeInstance = neode(), diff --git a/backend/src/seed/seed-helpers.js b/backend/src/seed/seed-helpers.js index 399d06670..913ca1d54 100644 --- a/backend/src/seed/seed-helpers.js +++ b/backend/src/seed/seed-helpers.js @@ -37,17 +37,17 @@ const difficulties = ['easy', 'medium', 'hard'] export default { randomItem: (items, filter) => { - let ids = filter + const ids = filter ? Object.keys(items).filter(id => { return filter(items[id]) }) : _.keys(items) - let randomIds = _.shuffle(ids) + const randomIds = _.shuffle(ids) return items[randomIds.pop()] }, randomItems: (items, key = 'id', min = 1, max = 1) => { - let randomIds = _.shuffle(_.keys(items)) - let res = [] + const randomIds = _.shuffle(_.keys(items)) + const res = [] const count = _.random(min, max) @@ -86,8 +86,8 @@ export default { if (allowEmpty === false && count === 0) { count = 1 } - let categorieIds = _.shuffle(_.keys(seederstore.categories)) - let ids = [] + const categorieIds = _.shuffle(_.keys(seederstore.categories)) + const ids = [] for (let i = 0; i < count; i++) { ids.push(categorieIds.pop()) } @@ -95,7 +95,7 @@ export default { }, randomAddresses: () => { const count = Math.round(Math.random() * 3) - let addresses = [] + const addresses = [] for (let i = 0; i < count; i++) { addresses.push({ city: faker.address.city(), @@ -116,7 +116,7 @@ export default { * @param key the field key that is represented in the values (slug, name, etc.) */ mapIdsByKey: (items, values, key) => { - let res = [] + const res = [] values.forEach(value => { res.push(_.find(items, [key, value]).id.toString()) })