Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const path = require('node:path')
const { fileURLToPath } = require('node:url')
const { statSync } = require('node:fs')
const { glob } = require('glob')
const { glob } = require('node:fs/promises')
const fp = require('fastify-plugin')
const send = require('@fastify/send')
const encodingNegotiator = require('@fastify/accept-negotiator')
Expand Down Expand Up @@ -139,27 +139,30 @@
for (let rootPath of roots) {
rootPath = rootPath.split(path.win32.sep).join(path.posix.sep)
!rootPath.endsWith('/') && (rootPath += '/')
const files = await glob('**/**', {
cwd: rootPath, absolute: false, follow: true, nodir: true, dot: opts.serveDotFiles, ignore: opts.globIgnore
})

for (let file of files) {
file = file.split(path.win32.sep).join(path.posix.sep)
const route = prefix + file

if (routes.has(route)) {
continue
}
const files = await Array.fromAsync(glob('**/**', {
cwd: rootPath, absolute: false, follow: true, nodir: true, dot: opts.serveDotFiles,ignore: opts.globIgnore

Check failure on line 144 in index.js

View workflow job for this annotation

GitHub Actions / test / quality-check / Lint Code

A space is required after ','
}))

Check failure on line 145 in index.js

View workflow job for this annotation

GitHub Actions / test / quality-check / Lint Code

Trailing spaces not allowed

Check failure on line 146 in index.js

View workflow job for this annotation

GitHub Actions / test / quality-check / Lint Code

Trailing spaces not allowed
for (let file of files)
{

Check failure on line 148 in index.js

View workflow job for this annotation

GitHub Actions / test / quality-check / Lint Code

Block must not be padded by blank lines

Check failure on line 148 in index.js

View workflow job for this annotation

GitHub Actions / test / quality-check / Lint Code

Opening curly brace does not appear on the same line as controlling statement

Check failure on line 149 in index.js

View workflow job for this annotation

GitHub Actions / test / quality-check / Lint Code

Trailing spaces not allowed
file = file.split(path.win32.sep).join(path.posix.sep)

Check failure on line 150 in index.js

View workflow job for this annotation

GitHub Actions / test / quality-check / Lint Code

Expected indentation of 10 spaces but found 12
const route = prefix + file

Check failure on line 151 in index.js

View workflow job for this annotation

GitHub Actions / test / quality-check / Lint Code

Expected indentation of 10 spaces but found 12

if (routes.has(route)) {

Check failure on line 153 in index.js

View workflow job for this annotation

GitHub Actions / test / quality-check / Lint Code

Expected indentation of 10 spaces but found 12
continue

Check failure on line 154 in index.js

View workflow job for this annotation

GitHub Actions / test / quality-check / Lint Code

Expected indentation of 12 spaces but found 14
}

routes.add(route)
routes.add(route)

setUpHeadAndGet(routeOpts, route, `/${file}`, rootPath)
setUpHeadAndGet(routeOpts, route, `/${file}`, rootPath)

const key = path.posix.basename(route)
if (indexes.has(key) && !indexDirs.has(key)) {
indexDirs.set(path.posix.dirname(route), rootPath)
const key = path.posix.basename(route)
if (indexes.has(key) && !indexDirs.has(key)) {
indexDirs.set(path.posix.dirname(route), rootPath)
}
}
}
}

for (const [dirname, rootPath] of indexDirs.entries()) {
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@
"@fastify/send": "^4.0.0",
"content-disposition": "^0.5.4",
"fastify-plugin": "^5.0.0",
"fastq": "^1.17.1",
"glob": "^11.0.0"
"fastq": "^1.17.1"
},
"devDependencies": {
"@fastify/compress": "^8.0.0",
Expand Down
Loading