const routeSize = 10000

if (!process.env.REACT_STATIC_SLAVE) {
  console.log()
  console.log(`Testing ${routeSize} routes`)
}

export default {
  getRoutes: async () => {
    const { data: posts } = await axios.get('https://jsonplaceholder.typicode.com/posts')

    const allPosts = []

    while (allPosts.length < routeSize) {
      allPosts.push(posts[Math.floor(Math.random() * posts.length)])
    }

    console.log(allPosts)

    const routes = [
      {
        path: '/',
        component: 'src/Home',
      },
    ]

    for (let index = 0; index < routeSize; index++) {
      routes.push({
        path: `/${index}`,
        component: index % 2 === 0 ? 'src/Home' : 'src/About',
        getProps: () => ({
          [`prop_${Math.floor(Math.random() * 100 * propCollision)}`]: fakeData,
        }),
      })
    }

    return routes
  },
}
