From 8bd1d19dbd899047bc8503dbe682358ddfc564cc Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Thu, 1 Mar 2018 19:48:47 +0000 Subject: Implement GET and POST request handlers --- src/files.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/files.ts (limited to 'src/files.ts') 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 +}; -- cgit v1.2.1