Month-end close
reports/
- 2026-09.json 48 KB
- 2026-10.json 51 KB
- 2026-11.json 53 KB
// end of the November close
await ctx.fs().writeFile(
'reports/2026-11.json', report)
November close
read back after the deploy
Some of what an app produces is simply a file. A finance app builds a month-end report. An ops tool exports a CSV for an auditor. A library wants a path on disk, not a value in a database. Until now that meant pushing the file somewhere else and keeping track of where it went.
Now a Helix project has its own folder. Call ctx.fs(), write the file, and every function in the project can read it back, on the next run and after the next deploy.
What that gives the team building it:
- The methods you already know.
readFile,writeFile,readdir,mkdir, streams. The samefs/promisescalls, with Node’s own errors, soENOENTmeans what it always meant. - Files that stay put. The directory persists across executions and deployments. Every function in the project sees the same one.
- A path for libraries that need one.
fs.resolve()returns a real path inside the project’s folder. - A safe local copy.
helix devkeeps files in.helix/project-files/inside the project, already excluded from git, so building never touches deployed files.
What it gives IT:
- Each project keeps to its own folder. A path that tries to leave it, through
.., an absolute path or a symlink, is rejected before anything runs. - Off unless it’s used. Helix turns the file system on only for a project whose own code calls
ctx.fs(). - Gone with the project. Deleting a project deletes its files.
An example
A finance team runs a month-end app on Helix. Each close, it pulls the numbers and builds a report the controller signs off.
1. The app writes the report
At the end of the close, a function writes the month’s report to reports/2026-11.json in the project’s folder.
# inside a Helix function
$ await ctx.fs().writeFile('reports/2026-11.json', report)
2. The controller opens it the next morning
The page that shows the report reads the same file. It’s there because the folder persists, even though the run that wrote it has finished.
3. A new version ships
The team deploys a change to how the report is laid out. Last month’s report is still in the folder, so the new page can show both side by side.
4. Someone asks for a month that isn’t there
The read fails with Node’s usual ENOENT, and the app answers “No report for that month” instead of an error page.
What else you could build
- An export folder that keeps each month’s CSV for an auditor to download.
- A template library of document templates an app fills in.
- A cache for a library that needs a file on disk.
- Data files you can query in place. It works with AlaSQL, and with Parquet files through HyParquet.
- An upload inbox that keeps files people send in until a job processes them.
Before you build one
Call it in your own code. Helix finds ctx.fs() in your project’s source, not inside a dependency. If a library needs files, call ctx.fs() yourself and pass it the handle or a path.
Give concurrent runs their own file names. Every execution shares the one folder, and nothing coordinates two writers on the same file.
Use the database for records. Files suit reports, exports and templates. Data that relates to other data belongs in the project’s database.
How to read and write files, and handle errors, is in the docs linked above.