diff --git a/src/index.tsx b/src/index.tsx index 91ab192..811f79a 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -68,16 +68,10 @@ app.get('/program', (_req, res) => { if (bFile.startsWith('.')) { continue }else if (json[file] === sha256sum){ - console.log('This picture has already been turned to sepia') continue } - - // Modification des données json[file] = sha256sum - - // Ré-écriture dans le fichier output await fs.writeFile('output.json', JSON.stringify(json)) - try{ const image = await Jimp.read(readI) image.sepia() @@ -97,74 +91,52 @@ app.get('/program', (_req, res) => { })('./assets') }) -async function filter() { - const listStart = readdirSync('./assets') // si moins de 6 element dans la liste .... +async function listToSend() { + const listFiles = readdirSync('./assets') const listFinal: Array> = [] - for(const files of listStart) - { + for(const files of listFiles){ const listPerso = await filesList('./assets/' + files) listFinal.push(listPerso) } - const filteredList = listFinal.map((innerList) => innerList.filter((element) => path.basename(element).startsWith('.'))) - // (a,b) => (a > b ? -1 : 1) - console.log(filteredList) - const listBS = filteredList.map((innerList) => innerList.reverse()) - // console.log(listBS) - return listBS + const listToSend = filteredList.map((innerList) => innerList.reverse()) + return listToSend } -// function randomSort() { -// return Math.random() - 0.5 -// } -// async function randomI(): Promise<[] | [string, string, string, string, string, string]> { -// const filteredList = await filter() -// const sorted = filteredList.sort(randomSort).slice(0, 6) -// while (sorted.length < 6 && sorted.length > 0 ) { -// const listLength = sorted.length -// sorted.push(...filteredList.sort(randomSort).slice(0, 6 - listLength)) -// } -// return sorted as [] -// } - -app.get('/code', async (_, res) => { // envoie a /code list de list des anims par perso (en théorie ) - const data = await filter() - // const baseI = await base() +app.get('/code', async (_, res) => { + const data = await listToSend() const lenght = data.length - // return json data if (lenght !== 0){ res.json(data) } }) -// function randomIntFromInterval(min: number, max: number) { -// return Math.floor(Math.random() * (max - min + 1) + min) -// } + async function base() { - const listA = readdirSync('./assets') // si moins de 6 element dans la liste .... - const listB: Array> = [] - const listC: Array = [] - for(const perso of listA){ + const listFiles = readdirSync('./assets') + const outerListFinal: Array> = [] + const innerListFinal: Array = [] + for(const perso of listFiles){ const listPerso = await filesList('./assets/' + perso) for(const image of listPerso){ const bName = path.basename(image) if(bName.startsWith('.base')){ - listC.push(image) + innerListFinal.push(image) } } } - listB.push(listC) + outerListFinal.push(innerListFinal) // console.log(listB) - return listB + return outerListFinal } app.get('/', async (_, res) => { - const list = await base() + const listBase = await base() - if(list.length === 0 ){ + if(listBase.length === 0 ){ const board = <> @@ -180,22 +152,22 @@ app.get('/', async (_, res) => {
- +
- +
- +
- +
- +
- +
{