aboutsummaryrefslogtreecommitdiff
path: root/src/files.ts
diff options
context:
space:
mode:
authorTom Harley2018-03-03 00:28:52 +0000
committerTom Harley2018-03-03 00:28:52 +0000
commit113b5dcbb948f96416f0b76ed8a8debff704c575 (patch)
treed920f1e9c73e703505128a0c2e3099bb94c81033 /src/files.ts
parentPlug in authentication support - WIP (diff)
parentAdd miniature response-wrapper middleware (diff)
downloadmedicine-113b5dcbb948f96416f0b76ed8a8debff704c575.tar.gz
medicine-113b5dcbb948f96416f0b76ed8a8debff704c575.zip

Merge branch ‘trh/gets’ into trh/payload-checker

Diffstat (limited to 'src/files.ts')
-rw-r--r--src/files.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/files.ts b/src/files.ts
new file mode 100644
index 0000000..daab817
--- /dev/null
+++ b/src/files.ts
@@ -0,0 +1,22 @@
+import * as fs from 'fs';
+
+const CONTENT_BASE_DIRECTORY: string = './files';
+
+const path: (filename: string, projectName: string) => string
+ = (filename: string, projectName: string): string => {
+ return `${CONTENT_BASE_DIRECTORY}/${projectName}/${filename}`;
+};
+
+const writableStream:
+ (filename: string, projectName: string) => fs.WriteStream =
+ (filename: string, projectName: string): fs.WriteStream => {
+ return fs.createWriteStream(path(filename, projectName));
+};
+
+export const files: {
+ path: (f: string, p: string) => string;
+ writableStream: (f: string, p: string) => fs.WriteStream;
+} = {
+ path,
+ writableStream
+};