Skip to content

Commit

Permalink
This adds created and modified timestamps to directory listings when
Browse files Browse the repository at this point in the history
consuming the JSON API - I want to experiement with using some of the
somisansa time series data, and need these fields (otherwise i'd have to
rely on filenames which is not reliable)
  • Loading branch information
ZachSARAO committed Mar 12, 2024
1 parent 3d459b2 commit 7297514
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/server/routes/get/dir/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export default async function ({
return {
v,
directory: path,
modified: stats.mtime,
created: stats.ctime,
entry,
isFile: stats.isFile(),
isDirectory: stats.isDirectory(),
Expand Down Expand Up @@ -87,7 +89,7 @@ export default async function ({
res.setHeader('content-type', 'application/json')
res.write(
JSON.stringify(
listings.map(({ isFile, isDirectory, size, entry, v }, i, arr) => {
listings.map(({ isFile, isDirectory, created, modified, size, entry, v }, i, arr) => {
const path = normalize(join(pathname, entry))
const unique =
arr.filter(({ pathname, entry }) => normalize(join(pathname, entry)) === path)
Expand All @@ -100,6 +102,8 @@ export default async function ({
}`,
v,
entry,
modified,
created,
isFile,
isDirectory,
size,
Expand Down

0 comments on commit 7297514

Please sign in to comment.