Skip to content

Commit

Permalink
feat: test redirects: 100000 itens
Browse files Browse the repository at this point in the history
  • Loading branch information
pedromtec committed Sep 12, 2024
1 parent 1687e05 commit 6232ff6
Show file tree
Hide file tree
Showing 3 changed files with 500,037 additions and 0 deletions.
4 changes: 4 additions & 0 deletions faststore.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ module.exports = {
nodeVersion: 18,
cypressVersion: 12,
},
redirects: () => {
const redirects = require("./src/redirects.json");
return redirects
},
account: "storeframework",
vtexHeadlessCms: {
webhookUrls: [
Expand Down
31 changes: 31 additions & 0 deletions generateRedirects.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const fs = require('fs')

const possibleDestinations = ['/4k-philips-monitor-99988213/p', '/aedle-vk1-headphone-99988211/p', '/echo-dot-smart-speaker-99988214/p']

function generateRandomString(prefix, length) {
const characters = 'abcdefghijklmnopqrstuvwxyz';
const randomString = Array(length)
.fill()
.map(() => characters.charAt(Math.floor(Math.random() * characters.length)))
.join('')
return prefix + randomString
}


function generateRedirects(amount) {
const redirects = []
for (let i = 0; i < amount; i++) {
const source = generateRandomString('/produto/', 15)
const destination = possibleDestinations[i % possibleDestinations.length]
redirects.push({ source, destination, permanent: true })
}

return redirects
}

(function main() {
const redirects = generateRedirects(10000)
console.log(redirects)
fs.writeFileSync('./src/redirects.json', JSON.stringify(redirects, null, 2))
})()

Loading

0 comments on commit 6232ff6

Please sign in to comment.