@joktec/file
v0.2.12
Published
JokTec - Local File Service
Readme
@joktec/file
File utility package for JokTec applications.
@joktec/file provides local file helper operations and Magika-backed file classification setup behind the JokTec client lifecycle.
What It Provides
FileModuleglobal Nest module.FileServicebuilt onAbstractClientService.- Magika-backed file classification config.
- File client interface and metrics.
- Directory size, cleanup, modified-file lookup, read, append, and delete helpers.
Install
yarn add @joktec/fileUsage
import { FileModule, FileService } from '@joktec/file';
@Module({
imports: [FileModule],
})
export class AppModule {}Inject FileService into app services:
await fileService.appendFile('events.log', JSON.stringify(event), '\n');
const content = await fileService.readFile('events.log');
const size = await fileService.getSize();Config
Configure the file section in the application config. Multiple connections are selected with conId.
file:
conId: default
directory: ./storage/tmp
magika:
modelPath: ./models/magika/model.onnx
modelConfigPath: ./models/magika/config.jsonThe service creates the configured directory during startup when it does not exist.
Guidelines
- Treat this package as a local utility, not durable object storage.
- Keep path selection and retention rules in the consuming app.
- Use
deleteFiles(start, end)carefully; it deletes files by modified time. - Use
@joktec/storagefor S3-compatible object storage.
Development
yarn lint --scope @joktec/file
yarn build --scope @joktec/file
yarn test --scope @joktec/file