Files
parcer/server/src/workflow-management/storage.ts

26 lines
645 B
TypeScript
Raw Normal View History

2024-06-08 20:55:58 +05:30
/**
* A group of functions for storing recordings on the file system.
* Functions are asynchronous to unload the server from heavy file system operations.
*/
import fs from 'fs';
import * as path from "path";
2024-06-08 20:56:15 +05:30
/**
* Reads a file from path and returns its content as a string.
* @param path The path to the file.
* @returns {Promise<string>}
* @category WorkflowManagement-Storage
*/
2024-06-08 20:55:58 +05:30
export const readFile = (path: string): Promise<string> => {
return new Promise((resolve, reject) => {
fs.readFile(path, 'utf8', (err, data) => {
if (err) {
reject(err);
} else {
resolve(data);
}
});
});
};