From f2f471e9c081d94622de02a22ca2faeaf8f6647b Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Fri, 13 Apr 2018 16:45:31 +0100 Subject: Fix some tests by including users in projects --- src/FileRouter.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/FileRouter.ts b/src/FileRouter.ts index b750094..48ec9c7 100644 --- a/src/FileRouter.ts +++ b/src/FileRouter.ts @@ -639,6 +639,9 @@ export class FileRouter { projectName: string ): Promise => { res.locals.project = await Project.findOne({ + include: [ + User + ], where: { name: projectName } -- cgit v1.2.1 From de1be5ca1789dbd8e8a88ebe042cb767793ef333 Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Fri, 13 Apr 2018 16:54:22 +0100 Subject: Fix some tests by adding properties in projects --- src/db/model/Project.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/db/model/Project.ts b/src/db/model/Project.ts index d57eaaa..6cda34e 100644 --- a/src/db/model/Project.ts +++ b/src/db/model/Project.ts @@ -36,6 +36,10 @@ export default class Project extends Model { return this.rootFolderInternal; } + public get properties(): object { + return this; + } + public get metadata(): { public_metadata?: Metadata; private_metadata?: Metadata; -- cgit v1.2.1 From d628ed540c883764eff623c7a059bcb588c017bc Mon Sep 17 00:00:00 2001 From: jw255 Date: Mon, 16 Apr 2018 16:08:08 +0100 Subject: nothing major --- files/abc/28b2710e-38bb-4bad-bf40-dde2480e4646 | 11 +++++++++++ files/abc/52f7bb86-f385-4bc1-aea5-38e32363e4df.jpg | Bin 0 -> 4279 bytes files/abc/d124ef49-e9e3-4794-bf50-76f40797b5d5 | Bin 0 -> 6785 bytes src/FileRouter.ts | 3 ++- src/db/model/User.ts | 2 -- src/matcher/options.ts | 11 +++++++++++ test/unit/options.unit.test.ts | 6 +++--- 7 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 files/abc/28b2710e-38bb-4bad-bf40-dde2480e4646 create mode 100644 files/abc/52f7bb86-f385-4bc1-aea5-38e32363e4df.jpg create mode 100644 files/abc/d124ef49-e9e3-4794-bf50-76f40797b5d5 diff --git a/files/abc/28b2710e-38bb-4bad-bf40-dde2480e4646 b/files/abc/28b2710e-38bb-4bad-bf40-dde2480e4646 new file mode 100644 index 0000000..b00f005 --- /dev/null +++ b/files/abc/28b2710e-38bb-4bad-bf40-dde2480e4646 @@ -0,0 +1,11 @@ +------WebKitFormBoundary4I0l9vAyn9AB6jO8 +Content-Disposition: form-data; name="pres"; filename="config" +Content-Type: application/octet-stream + +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + +------WebKitFormBoundary4I0l9vAyn9AB6jO8-- diff --git a/files/abc/52f7bb86-f385-4bc1-aea5-38e32363e4df.jpg b/files/abc/52f7bb86-f385-4bc1-aea5-38e32363e4df.jpg new file mode 100644 index 0000000..dd86d56 Binary files /dev/null and b/files/abc/52f7bb86-f385-4bc1-aea5-38e32363e4df.jpg differ diff --git a/files/abc/d124ef49-e9e3-4794-bf50-76f40797b5d5 b/files/abc/d124ef49-e9e3-4794-bf50-76f40797b5d5 new file mode 100644 index 0000000..d7a00af Binary files /dev/null and b/files/abc/d124ef49-e9e3-4794-bf50-76f40797b5d5 differ diff --git a/src/FileRouter.ts b/src/FileRouter.ts index 9a7dcac..f7a1809 100644 --- a/src/FileRouter.ts +++ b/src/FileRouter.ts @@ -689,6 +689,7 @@ export class FileRouter { // TODO Rewrite using sub-queries instead of repeated queries. while (fileNames.length > 2) { const fileOrNull: File | null = await File.findOne({ + include: [{all: true}], where: { name: fileNames[0], parentFolder: file @@ -703,7 +704,7 @@ export class FileRouter { } const parentFolder: File | null = await File.findOne({ include: [ - { model: File, as: 'containedFilesInternal'}, + { model: File, as: 'containedFilesInternal'} ], where: { //parentFolder: file, diff --git a/src/db/model/User.ts b/src/db/model/User.ts index 3a0ef26..73d2356 100644 --- a/src/db/model/User.ts +++ b/src/db/model/User.ts @@ -126,14 +126,12 @@ export default class User extends Model { } public get fullInfo(): UserFullInfo { - console.log("fullinfo called") // FIXME: Fetch these things if they aren't already present if (this.userGroups === undefined) { this.userGroups = []; } else if (this.projects === undefined) { this.projects = []; } - console.log("2") return { username : this.username, privileges: this.userGroups! diff --git a/src/matcher/options.ts b/src/matcher/options.ts index 0513eb3..967a6f9 100644 --- a/src/matcher/options.ts +++ b/src/matcher/options.ts @@ -15,13 +15,20 @@ export type Value = const matchNoCurry: (template: TemplateValue, value: Value | undefined) => boolean = (template: TemplateValue, value: Value | undefined): boolean => { + console.log("matchNoCurry()") + console.log(template) + console.log(value) if (types.atom(template)) { + console.log("atom") return template === value; } else if (types.function(template)) { + console.log("function") return template(value); } else if (types.atom(value) || value === undefined) { + console.log("atom2") return false; } else if (types.object(template)) { + console.log("object") return Object.keys(template) .every((key: string): boolean => { const v: Value | undefined = value[key]; @@ -34,7 +41,11 @@ const matchNoCurry: // tslint:disable-next-line:typedef export const match = (template: TemplateValue, value?: Value) => { + console.log("match()") + console.log(template) + console.log(value) if (value === undefined) { + console.log("is undefined") return matchNoCurry.bind(null, template); } return matchNoCurry(template, value); diff --git a/test/unit/options.unit.test.ts b/test/unit/options.unit.test.ts index 4a85c2f..fd88ca6 100644 --- a/test/unit/options.unit.test.ts +++ b/test/unit/options.unit.test.ts @@ -209,10 +209,10 @@ describe('Matching:', () => { options.match(template)(matchee).should.be.true; }); - it('$$ Buy now: unit tests cheap and chearful. only £9.99', () => { + it.only('Matching Arrays', () => { /* tslint:disable:align */ - const matchee: any = [ 'test' ]; - const template = types.array(types.anything); + const matchee: any = ['ss']; + const template: any = types.array; /* tslint:enable:align */ options.match(template)(matchee).should.be.true; -- cgit v1.2.1 From 4ec93e886fc10de2c65e9599dbfca2a70db578e3 Mon Sep 17 00:00:00 2001 From: jw255 Date: Mon, 16 Apr 2018 19:34:57 +0100 Subject: World War Files, part 1\nRoot folder is automatically created at the start of the server. also project folder should now appear in the filesystem --- .gitignore | 3 + files/abc/28b2710e-38bb-4bad-bf40-dde2480e4646 | 11 - files/abc/52f7bb86-f385-4bc1-aea5-38e32363e4df.jpg | Bin 4279 -> 0 bytes files/abc/d124ef49-e9e3-4794-bf50-76f40797b5d5 | Bin 6785 -> 0 bytes files/mocky/bbb850e4-7c0e-41b9-ae63-a025b81d09de | 0 src/FileRouter.ts | 20 +- src/db/model/File.ts | 18 ++ src/files.ts | 62 +++--- src/index.ts | 11 + test/JH_environment.json | 52 +++++ test/postman.json.json | 245 +++++++++++++++++++++ 11 files changed, 380 insertions(+), 42 deletions(-) delete mode 100644 files/abc/28b2710e-38bb-4bad-bf40-dde2480e4646 delete mode 100644 files/abc/52f7bb86-f385-4bc1-aea5-38e32363e4df.jpg delete mode 100644 files/abc/d124ef49-e9e3-4794-bf50-76f40797b5d5 delete mode 100644 files/mocky/bbb850e4-7c0e-41b9-ae63-a025b81d09de create mode 100644 test/JH_environment.json create mode 100644 test/postman.json.json diff --git a/.gitignore b/.gitignore index d5c5f43..1be1136 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,6 @@ logs/ # Typedoc-generated documentation docs/ + +# project files +files/* diff --git a/files/abc/28b2710e-38bb-4bad-bf40-dde2480e4646 b/files/abc/28b2710e-38bb-4bad-bf40-dde2480e4646 deleted file mode 100644 index b00f005..0000000 --- a/files/abc/28b2710e-38bb-4bad-bf40-dde2480e4646 +++ /dev/null @@ -1,11 +0,0 @@ -------WebKitFormBoundary4I0l9vAyn9AB6jO8 -Content-Disposition: form-data; name="pres"; filename="config" -Content-Type: application/octet-stream - -[core] - repositoryformatversion = 0 - filemode = true - bare = false - logallrefupdates = true - -------WebKitFormBoundary4I0l9vAyn9AB6jO8-- diff --git a/files/abc/52f7bb86-f385-4bc1-aea5-38e32363e4df.jpg b/files/abc/52f7bb86-f385-4bc1-aea5-38e32363e4df.jpg deleted file mode 100644 index dd86d56..0000000 Binary files a/files/abc/52f7bb86-f385-4bc1-aea5-38e32363e4df.jpg and /dev/null differ diff --git a/files/abc/d124ef49-e9e3-4794-bf50-76f40797b5d5 b/files/abc/d124ef49-e9e3-4794-bf50-76f40797b5d5 deleted file mode 100644 index d7a00af..0000000 Binary files a/files/abc/d124ef49-e9e3-4794-bf50-76f40797b5d5 and /dev/null differ diff --git a/files/mocky/bbb850e4-7c0e-41b9-ae63-a025b81d09de b/files/mocky/bbb850e4-7c0e-41b9-ae63-a025b81d09de deleted file mode 100644 index e69de29..0000000 diff --git a/src/FileRouter.ts b/src/FileRouter.ts index 70243c3..ca2ed50 100644 --- a/src/FileRouter.ts +++ b/src/FileRouter.ts @@ -8,7 +8,7 @@ import { default as UserGroup } from './db/model/UserGroup'; import { NextFunction, Request, Response, Router } from 'express'; import { RequestError } from './errors/errorware'; -import { View, files, views } from './files'; +import { View, files, views, rootPathId, createProjectFolder } from './files'; import { logger } from './logger'; import { Property, default as serverConfig } from './serverConfig'; import { uuid } from './uuid'; @@ -497,9 +497,12 @@ const postProjectName: Middleware = async( logger.debug('Adding new project'); const file: File = new File({ uuid: uuid.generate(), - mimetype: 'inode/directory' + mimetype: 'inode/directory', + name: req.params.project_name, + parentFolderId: rootPathId }); promise = file.save(); + createProjectFolder(req.params.project_name); project = new Project({ name: req.params.project_name, rootFolder: file @@ -575,7 +578,6 @@ const postFilePath: Middleware = ( name: res.locals.filename, parentFolder: res.locals.parentFolder }); - //console.log(res.locals); req.pipe(files.writableStream(file.uuid, res.locals.project.name)); next(); }; @@ -677,11 +679,12 @@ export class FileRouter { req: Request, res: Response, next: NextFunction, filename: string ): Promise => { - console.log(`parsing path ${filename}`) + filename = filename.replace(/\+/g, "/"); // Replace + with / logger.debug(`Searching for file ${filename}`); const fileNames: string[] = req.params.path.split('/'); const project: Project | null = res.locals.project; if (project == null) { + // Project should have been found by previous precondition logger.debug('Project was not found: skipping finding file'); return next(new RequestError(404, 'project_not_found')); } @@ -696,15 +699,21 @@ export class FileRouter { } }); if (fileOrNull == null) { + console.log("fileOrNull was null") return next(); } else { + console.log("^^") + console.log(file) file = fileOrNull; } fileNames.splice(0, 1); } + if (file == null) { + console.log("file was null") return next(); } + console.log(file) const parentFolder: File | null = await File.findOne({ include: [ { model: File, as: 'containedFilesInternal'} @@ -714,7 +723,8 @@ export class FileRouter { name: fileNames[0] } }); - //console.log(parentFolder); + console.log("parent folder: ") + console.log(parentFolder); if (parentFolder == null) { return next(); } diff --git a/src/db/model/File.ts b/src/db/model/File.ts index 4026b85..193a785 100644 --- a/src/db/model/File.ts +++ b/src/db/model/File.ts @@ -5,6 +5,24 @@ import { default as User } from './User'; import { FileTypeName, mimes } from '../../files'; +/* + * attributes: + * - nameInternal + * - fullPathInternal + * - uuid + * - type + * - size + * - parentFolderId + * - containedFilesInternal + * - creatorName + * - creator + * - rootFolderOf + * - uploadDate + * - modifyDate + * - status + * - metadataInternal +*/ + @Table export default class File extends Model { @AllowNull diff --git a/src/files.ts b/src/files.ts index 8ad7236..42e490a 100644 --- a/src/files.ts +++ b/src/files.ts @@ -6,17 +6,12 @@ import { default as Project } from './db/model/Project'; const CONTENT_BASE_DIRECTORY: string = './files'; const LOG_BASE_DIRECTORY: string = './logs'; - -const path: (filename: string, projectName: string) => string - = (filename: string, projectName: string): string => { +/* tslint:disable */ +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 => { +const writableStream: (filename: string, projectName: string) => fs.WriteStream = (filename: string, projectName: string): fs.WriteStream => { return fs.createWriteStream(path(filename, projectName)); }; @@ -25,29 +20,29 @@ interface RawSize { length: number; } -const readableStream: ( - filename: string, projectName: string, - { offset, length }?: Partial -) => fs.ReadStream = ( - filename: string, projectName: string, - { offset, length }: Partial = - { offset: undefined, length: undefined } -): fs.ReadStream => { +const readableStream: (filename: string, projectName: string, { offset, length }?: Partial) => fs.ReadStream + = (filename: string, projectName: string, { offset, length }: Partial = { offset: undefined, length: undefined }): fs.ReadStream => { const options: object = { - start: offset - ? offset - : 0, - end: offset && length - ? offset + length - : undefined + start: offset? offset: 0, + end: offset && length? offset + length: undefined }; return fs.createReadStream(path(filename, projectName), options); }; +/* +// prj name, file uuid => if exists and return path string/ parent folder +const findParent: (projectName: string, fileUUID: string) => File | null = (projectName: string, fileUUID: string) => { + if(!projectName || !fileUUID){ + return null; + } + function findFile(dir: string, fileList: string[]) : string { + + } -const logPath: -(type: string, projectName?: string) => string = ( - type: string, projectName?: string -): string => { +} +*/ + +const logPath: (type: string, projectName?: string) => string = ( + type: string, projectName?: string): string => { return projectName ? `${LOG_BASE_DIRECTORY}/projects/${projectName}/${type}` : `${LOG_BASE_DIRECTORY}/general/${type}`; @@ -198,3 +193,18 @@ class MimeTypeMap extends Map { export const mimes: MimeTypeMap = new MimeTypeMap([ [ 'inode/directory', 'directory' ] ]); + +export const rootPathId: string = '0'; +export const rootPathFile: File | null = null; + +export const createRootFolder: () => void = (): any => { + if (!fs.existsSync(CONTENT_BASE_DIRECTORY)){ + fs.mkdirSync(CONTENT_BASE_DIRECTORY); + } +} + +export const createProjectFolder: (name: string) => void = (projName: string): any => { + if (!fs.existsSync(CONTENT_BASE_DIRECTORY + '/' + projName)){ + fs.mkdirSync(CONTENT_BASE_DIRECTORY + '/' + projName); + } +} diff --git a/src/index.ts b/src/index.ts index 7e21c35..5960374 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,7 +8,9 @@ import { default as app } from './app'; logger.info('Importing database ORM'); import { default as seq } from './db/orm'; +import { View, files, views, rootPathId, createRootFolder } from './files'; +import { default as File } from './db/model/File'; import { default as User } from './db/model/User'; import { default as UserGroup } from './db/model/UserGroup'; @@ -40,6 +42,14 @@ logger.info(`Port ${port} chosen`); process.exit(1); } + logger.info('Setting up directory structure'); + const rootDir: File = new File({ + uuid: rootPathId, + mimetype: 'inode/directory', + name: '/' + }); + await rootDir.save(); + logger.info('Adding admin privileges'); const admin: UserGroup = new UserGroup({ name: 'admin', @@ -70,6 +80,7 @@ logger.info(`Port ${port} chosen`); }); await root.save(); + createRootFolder(); await root.$set('userGroups', [admin, logging]); diff --git a/test/JH_environment.json b/test/JH_environment.json new file mode 100644 index 0000000..bf72d78 --- /dev/null +++ b/test/JH_environment.json @@ -0,0 +1,52 @@ +{ + "id": "ddad923b-9750-c337-ff49-6ee328a72e20", + "name": "JH", + "values": [ + { + "enabled": true, + "key": "host", + "value": "http://localhost:3000", + "type": "text" + }, + { + "enabled": true, + "key": "endpoint", + "value": "cs3099group-be-4", + "type": "text" + }, + { + "enabled": true, + "key": "dummy_admin_username", + "value": "hafeez", + "type": "text" + }, + { + "enabled": true, + "key": "dummy_admin_pass", + "value": "pass", + "type": "text" + }, + { + "enabled": true, + "key": "dummy_project", + "value": "abc", + "type": "text" + }, + { + "enabled": true, + "key": "access_token", + "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvYmplY3QiOnsidXNlcm5hbWUiOiJoYWZlZXoiLCJwYXNzd29yZEludGVybmFsIjpudWxsLCJjcmVhdGlvbkRhdGUiOiIyMDE4LTA0LTE2VDE2OjExOjU5LjU0M1oiLCJ1cGRhdGVkQXQiOiIyMDE4LTA0LTE2VDE2OjExOjU5LjU0M1oiLCJ1c2VyR3JvdXBzIjpbeyJpZCI6MSwibmFtZSI6ImxvZ2dpbmciLCJjYW5DcmVhdGVVc2VycyI6bnVsbCwiY2FuRGVsZXRlVXNlcnMiOm51bGwsImNhbkVkaXRVc2VycyI6bnVsbCwiY2FuQ3JlYXRlUHJvamVjdHMiOm51bGwsImNhbkRlbGV0ZVByb2plY3RzIjpudWxsLCJjYW5FZGl0UHJvamVjdHMiOm51bGwsImNhbkFjY2Vzc0xvZ3MiOnRydWUsImlzSW50ZXJuYWwiOmZhbHNlLCJkZXNjcmlwdGlvbiI6IkFsbG93cyBQb3N0IHRvIExvZyIsIlVzZXJIYXNQcml2aWxlZ2UiOnsidXNlcm5hbWUiOiJoYWZlZXoiLCJwcml2aWxlZ2VJZCI6MX19LHsiaWQiOjIsIm5hbWUiOiJhZG1pbiIsImNhbkNyZWF0ZVVzZXJzIjp0cnVlLCJjYW5EZWxldGVVc2VycyI6dHJ1ZSwiY2FuRWRpdFVzZXJzIjp0cnVlLCJjYW5DcmVhdGVQcm9qZWN0cyI6dHJ1ZSwiY2FuRGVsZXRlUHJvamVjdHMiOnRydWUsImNhbkVkaXRQcm9qZWN0cyI6dHJ1ZSwiY2FuQWNjZXNzTG9ncyI6bnVsbCwiaXNJbnRlcm5hbCI6ZmFsc2UsImRlc2NyaXB0aW9uIjoiU3lzdGVtcyBhZG1pbiIsIlVzZXJIYXNQcml2aWxlZ2UiOnsidXNlcm5hbWUiOiJoYWZlZXoiLCJwcml2aWxlZ2VJZCI6Mn19XSwicHJvamVjdHMiOltdfSwiaWF0IjoxNTIzODk1MzgzLCJleHAiOjE1MjM5MTY5ODN9.3kpxdZFReNz24MfK6AN4rc3T1vOaG9AM40RQ4-FL7xI", + "type": "text" + }, + { + "enabled": true, + "key": "refresh_token", + "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvYmplY3QiOnsidXNlcm5hbWUiOiJoYWZlZXoiLCJwYXNzd29yZEludGVybmFsIjpudWxsLCJjcmVhdGlvbkRhdGUiOiIyMDE4LTA0LTE2VDE2OjExOjU5LjU0M1oiLCJ1cGRhdGVkQXQiOiIyMDE4LTA0LTE2VDE2OjExOjU5LjU0M1oiLCJ1c2VyR3JvdXBzIjpbeyJpZCI6MSwibmFtZSI6ImxvZ2dpbmciLCJjYW5DcmVhdGVVc2VycyI6bnVsbCwiY2FuRGVsZXRlVXNlcnMiOm51bGwsImNhbkVkaXRVc2VycyI6bnVsbCwiY2FuQ3JlYXRlUHJvamVjdHMiOm51bGwsImNhbkRlbGV0ZVByb2plY3RzIjpudWxsLCJjYW5FZGl0UHJvamVjdHMiOm51bGwsImNhbkFjY2Vzc0xvZ3MiOnRydWUsImlzSW50ZXJuYWwiOmZhbHNlLCJkZXNjcmlwdGlvbiI6IkFsbG93cyBQb3N0IHRvIExvZyIsIlVzZXJIYXNQcml2aWxlZ2UiOnsidXNlcm5hbWUiOiJoYWZlZXoiLCJwcml2aWxlZ2VJZCI6MX19LHsiaWQiOjIsIm5hbWUiOiJhZG1pbiIsImNhbkNyZWF0ZVVzZXJzIjp0cnVlLCJjYW5EZWxldGVVc2VycyI6dHJ1ZSwiY2FuRWRpdFVzZXJzIjp0cnVlLCJjYW5DcmVhdGVQcm9qZWN0cyI6dHJ1ZSwiY2FuRGVsZXRlUHJvamVjdHMiOnRydWUsImNhbkVkaXRQcm9qZWN0cyI6dHJ1ZSwiY2FuQWNjZXNzTG9ncyI6bnVsbCwiaXNJbnRlcm5hbCI6ZmFsc2UsImRlc2NyaXB0aW9uIjoiU3lzdGVtcyBhZG1pbiIsIlVzZXJIYXNQcml2aWxlZ2UiOnsidXNlcm5hbWUiOiJoYWZlZXoiLCJwcml2aWxlZ2VJZCI6Mn19XSwicHJvamVjdHMiOltdfSwiaWF0IjoxNTIzODk1MzgzLCJleHAiOjE1MjM5MTY5ODN9.3kpxdZFReNz24MfK6AN4rc3T1vOaG9AM40RQ4-FL7xI", + "type": "text" + } + ], + "timestamp": 1523895383946, + "_postman_variable_scope": "environment", + "_postman_exported_at": "2018-04-16T16:30:59.939Z", + "_postman_exported_using": "Postman/5.5.2" +} \ No newline at end of file diff --git a/test/postman.json.json b/test/postman.json.json new file mode 100644 index 0000000..14771e0 --- /dev/null +++ b/test/postman.json.json @@ -0,0 +1,245 @@ +{ + "variables": [], + "info": { + "name": "JH", + "_postman_id": "d9fad1ce-92af-fc2c-ff74-074fc681c7ee", + "description": "", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "name": "authorised", + "description": "", + "item": [ + { + "name": "/projects", + "request": { + "url": "{{host}}/{{endpoint}}/projects", + "method": "GET", + "header": [ + { + "key": "", + "value": "", + "disabled": true + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "description": "" + }, + "response": [] + }, + { + "name": "/log", + "request": { + "url": "{{host}}/{{endpoint}}/log", + "method": "GET", + "header": [ + { + "key": "", + "value": "", + "disabled": true + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "description": "" + }, + "response": [] + }, + { + "name": "/_supported_protocols", + "request": { + "url": "{{host}}/{{endpoint}}/_supported_protocols_", + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer {{access_token}}", + "description": "", + "disabled": true + } + ], + "body": {}, + "description": "" + }, + "response": [] + }, + { + "name": "/project_roles", + "request": { + "url": "{{host}}/{{endpoint}}/project_roles", + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer {{access_token}}", + "description": "", + "disabled": true + } + ], + "body": {}, + "description": "" + }, + "response": [] + }, + { + "name": "/projects/", + "request": { + "url": "{{host}}/{{endpoint}}/projects/{{dummy_project}}", + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "description": "" + }, + { + "key": "Authorization", + "value": "Bearer {{access_token}}", + "description": "" + } + ], + "body": { + "mode": "raw", + "raw": "{}" + }, + "description": "" + }, + "response": [] + }, + { + "name": "/projects/abc/files_by_id", + "request": { + "url": "{{host}}/{{endpoint}}/projects/{{dummy_project}}/files_by_id/d124ef49-e9e3-4794-bf50-76f40797b5d5", + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer {{access_token}}", + "description": "" + }, + { + "key": "Content-Type", + "value": "image/png", + "description": "", + "disabled": true + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "pres", + "description": "", + "type": "file", + "src": "triangle_down_black.png" + } + ] + }, + "description": "" + }, + "response": [] + }, + { + "name": "/projects/abc/files", + "request": { + "url": "{{host}}/{{endpoint}}/projects/{{dummy_project}}/files/path/to/image.png", + "method": "POST", + "header": [ + { + "key": "Authorization", + "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvYmplY3QiOnsidXNlcm5hbWUiOiJoYWZlZXoiLCJwYXNzd29yZEludGVybmFsIjpudWxsLCJjcmVhdGlvbkRhdGUiOiIyMDE4LTA0LTE2VDEyOjA1OjUyLjQ2N1oiLCJ1cGRhdGVkQXQiOiIyMDE4LTA0LTE2VDEyOjA1OjUyLjQ2N1oiLCJ1c2VyR3JvdXBzIjpbeyJpZCI6MSwibmFtZSI6ImxvZ2dpbmciLCJjYW5DcmVhdGVVc2VycyI6bnVsbCwiY2FuRGVsZXRlVXNlcnMiOm51bGwsImNhbkVkaXRVc2VycyI6bnVsbCwiY2FuQ3JlYXRlUHJvamVjdHMiOm51bGwsImNhbkRlbGV0ZVByb2plY3RzIjpudWxsLCJjYW5FZGl0UHJvamVjdHMiOm51bGwsImNhbkFjY2Vzc0xvZ3MiOnRydWUsImlzSW50ZXJuYWwiOmZhbHNlLCJkZXNjcmlwdGlvbiI6IkFsbG93cyBQb3N0IHRvIExvZyIsIlVzZXJIYXNQcml2aWxlZ2UiOnsidXNlcm5hbWUiOiJoYWZlZXoiLCJwcml2aWxlZ2VJZCI6MX19LHsiaWQiOjIsIm5hbWUiOiJhZG1pbiIsImNhbkNyZWF0ZVVzZXJzIjp0cnVlLCJjYW5EZWxldGVVc2VycyI6dHJ1ZSwiY2FuRWRpdFVzZXJzIjp0cnVlLCJjYW5DcmVhdGVQcm9qZWN0cyI6dHJ1ZSwiY2FuRGVsZXRlUHJvamVjdHMiOnRydWUsImNhbkVkaXRQcm9qZWN0cyI6dHJ1ZSwiY2FuQWNjZXNzTG9ncyI6bnVsbCwiaXNJbnRlcm5hbCI6ZmFsc2UsImRlc2NyaXB0aW9uIjoiU3lzdGVtcyBhZG1pbiIsIlVzZXJIYXNQcml2aWxlZ2UiOnsidXNlcm5hbWUiOiJoYWZlZXoiLCJwcml2aWxlZ2VJZCI6Mn19XSwicHJvamVjdHMiOltdfSwiaWF0IjoxNTIzODgwMzU2LCJleHAiOjE1MjM5MDE5NTZ9.LrRWCzjBQmPtEkthmPJvVdl6XsYqA4Myqw-VFHMbQ8o", + "description": "" + }, + { + "key": "Content-Type", + "value": "image/png", + "description": "" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "triangle", + "description": "", + "type": "file", + "src": "triangle_down_black.png" + } + ] + }, + "description": "" + }, + "response": [] + }, + { + "name": "/", + "request": { + "url": "{{host}}/", + "method": "GET", + "header": [], + "body": {}, + "description": "" + }, + "response": [] + } + ] + }, + { + "name": "/oauth/token", + "event": [ + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "let res = JSON.parse(responseBody);", + "postman.setEnvironmentVariable(\"access_token\", res.access_token);", + "postman.setEnvironmentVariable(\"refresh_token\", res.refresh_token);" + ] + } + } + ], + "request": { + "url": "{{host}}/{{endpoint}}/oauth/token", + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/x-www-form-urlencoded" + } + ], + "body": { + "mode": "urlencoded", + "urlencoded": [ + { + "key": "grant_type", + "value": "password", + "description": "", + "type": "text" + }, + { + "key": "username", + "value": "{{dummy_admin_username}}", + "description": "", + "type": "text" + }, + { + "key": "password", + "value": "{{dummy_admin_pass}}", + "description": "", + "type": "text" + } + ] + }, + "description": "wefrwrbjk;" + }, + "response": [] + } + ] +} \ No newline at end of file -- cgit v1.2.1 From c7874c8d2407fc7d046b6ba6856ebfdb46a30f37 Mon Sep 17 00:00:00 2001 From: jw255 Date: Mon, 16 Apr 2018 20:34:29 +0100 Subject: World War Files - ideas all there, but SQLize part still missing. --- src/FileRouter.ts | 52 ++++++++++++++++++++++++++++++++++++++++++++++------ src/files.ts | 7 +++++++ 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/FileRouter.ts b/src/FileRouter.ts index ca2ed50..df7ca94 100644 --- a/src/FileRouter.ts +++ b/src/FileRouter.ts @@ -8,7 +8,7 @@ import { default as UserGroup } from './db/model/UserGroup'; import { NextFunction, Request, Response, Router } from 'express'; import { RequestError } from './errors/errorware'; -import { View, files, views, rootPathId, createProjectFolder } from './files'; +import { addSubFileToFolder, View, files, views, rootPathId, createProjectFolder } from './files'; import { logger } from './logger'; import { Property, default as serverConfig } from './serverConfig'; import { uuid } from './uuid'; @@ -565,22 +565,56 @@ const getFileId: Middleware = getFile; /** * Post a File. / delete / move / etc */ -const postFilePath: Middleware = ( +/* tslint:disable */ +const postFilePath: Middleware = async( req: Request, res: Response, next: NextFunction -): void => { +): Promise => { logger.debug(`Receiving file to ${res.locals.parentFolder}`); - res.locals.modified = true; + if (res.locals.file != null) { next(new RequestError(400, 'file_exists')); } + + // lets have a res.locals.deepestFolderName (and Id) which is a string of the deepest parent folder found + let remainingPath: string = res.locals.path.split(res.locals.deepestFolderName)[1]; + console.log(`remainingPath: ${remainingPath}`) + + while((remainingPath.match(/\//g) || []).length > 1){ + // If there are more subfolders that dont exist, then create them + const subFolder: string = remainingPath.split("/")[1] + logger.debug(`Adding subfolder \'${subFolder}`); + const dir: File = new File({ + uuid: uuid.generate(), + mimetype: 'inode/directory', + name: subFolder, + parentFolderId: res.locals.deepestFolderId + }); + await dir.save(); + + // update parent directory of new directory + addSubFileToFolder(res.locals.deepestFolderId, dir.id); + + // update vars + remainingPath = remainingPath.split(subFolder)[1] + res.locals.deepestFolderName = subFolder; + res.locals.deepestFolderId = dir.id; + console.log(`\tremainingPath: ${remainingPath}`) + console.log(`\tdeepestFolderName: ${res.locals.deepestFolderName}`) + console.log(`\tdeepestFolderId: ${res.locals.deepestFolderId}`) + } + const file: File = new File({ uuid: uuid.generate(), name: res.locals.filename, - parentFolder: res.locals.parentFolder + parentFolder: res.locals.deepestFolderId }); + // update parent directory of new directory + addSubFileToFolder(res.locals.deepestFolderId, file.id); + // pipe the data req.pipe(files.writableStream(file.uuid, res.locals.project.name)); next(); }; +/* tslint:enable */ export class FileRouter { public router: Router; @@ -679,8 +713,14 @@ export class FileRouter { req: Request, res: Response, next: NextFunction, filename: string ): Promise => { - filename = filename.replace(/\+/g, "/"); // Replace + with / + // TODO \/ + // We need to find the res.locals.deepestFolderName (and Id) for the currently requested path + + // Replace + with / + filename = filename.replace(/\+/g, '/'); logger.debug(`Searching for file ${filename}`); + res.locals.path = filename; + const fileNames: string[] = req.params.path.split('/'); const project: Project | null = res.locals.project; if (project == null) { diff --git a/src/files.ts b/src/files.ts index 42e490a..6572c53 100644 --- a/src/files.ts +++ b/src/files.ts @@ -208,3 +208,10 @@ export const createProjectFolder: (name: string) => void = (projName: string): a fs.mkdirSync(CONTENT_BASE_DIRECTORY + '/' + projName); } } + +export const addSubFileToFolder: (parentId: string, subFileId: string) => void = (parentId: string, subFileId: string): any => { + // TODO: + // fetch parent file object from database + // update parent file object + // save +} -- cgit v1.2.1 From 7905240ed1655f9db3f571976034e287d88e1315 Mon Sep 17 00:00:00 2001 From: jw255 Date: Tue, 17 Apr 2018 10:38:32 +0100 Subject: World War Files - changed precondition + filled addSubFileToFolder() function. Need to test tho --- src/FileRouter.ts | 79 +++++++++++++++++++++++++------------------------------ src/files.ts | 40 +++++++++++++++++----------- 2 files changed, 60 insertions(+), 59 deletions(-) diff --git a/src/FileRouter.ts b/src/FileRouter.ts index df7ca94..4b56b19 100644 --- a/src/FileRouter.ts +++ b/src/FileRouter.ts @@ -13,9 +13,6 @@ import { logger } from './logger'; import { Property, default as serverConfig } from './serverConfig'; import { uuid } from './uuid'; -// TODO: figure this out -const BASE_FILE_STORAGE: string = 'TODO: figure this out'; - /** * The type of an Express middleware callback. */ @@ -540,7 +537,6 @@ const getFile: Middleware = async( req: Request, res: Response, next: NextFunction ): Promise => { logger.debug(`Getting file in ${req.query.view} view`); - res.locals.modified = true; const file: File | null = res.locals.file; if (file == null) { return next(new RequestError(404, 'file_not_found')); @@ -566,9 +562,7 @@ const getFileId: Middleware = getFile; * Post a File. / delete / move / etc */ /* tslint:disable */ -const postFilePath: Middleware = async( - req: Request, res: Response, next: NextFunction -): Promise => { +const postFilePath: Middleware = async(req: Request, res: Response, next: NextFunction): Promise => { logger.debug(`Receiving file to ${res.locals.parentFolder}`); if (res.locals.file != null) { @@ -579,6 +573,7 @@ const postFilePath: Middleware = async( let remainingPath: string = res.locals.path.split(res.locals.deepestFolderName)[1]; console.log(`remainingPath: ${remainingPath}`) + // Loop the part of the path that doesn't exist yet and create all the folders while((remainingPath.match(/\//g) || []).length > 1){ // If there are more subfolders that dont exist, then create them const subFolder: string = remainingPath.split("/")[1] @@ -610,6 +605,8 @@ const postFilePath: Middleware = async( }); // update parent directory of new directory addSubFileToFolder(res.locals.deepestFolderId, file.id); + + // TODO respond to correct query params (like update metadata, move, etc) // pipe the data req.pipe(files.writableStream(file.uuid, res.locals.project.name)); next(); @@ -721,59 +718,49 @@ export class FileRouter { logger.debug(`Searching for file ${filename}`); res.locals.path = filename; + // split path into parts const fileNames: string[] = req.params.path.split('/'); + res.locals.filename = fileNames[-1]; const project: Project | null = res.locals.project; if (project == null) { // Project should have been found by previous precondition logger.debug('Project was not found: skipping finding file'); return next(new RequestError(404, 'project_not_found')); } - let file: File = project.rootFolder; - // TODO Rewrite using sub-queries instead of repeated queries. - while (fileNames.length > 2) { + console.debug(fileNames); + + let curDir: File | null = project.rootFolder; + res.locals.deepestFolderId = curDir.id; + res.locals.deepestFolderName = curDir.name; + let i: number = 0; + + // Loop through the path and find the deepest folder that exists. Also find the file if possible. + while (curDir && i < fileNames.length) { const fileOrNull: File | null = await File.findOne({ include: [{all: true}], where: { - name: fileNames[0], - parentFolder: file + name: fileNames[i], + parentFolder: curDir } }); if (fileOrNull == null) { - console.log("fileOrNull was null") + console.log("next subdir not found in DB"); return next(); - } else { - console.log("^^") - console.log(file) - file = fileOrNull; + } + + if(i < fileNames.length-1){ + // Found next subdirectory + console.log(`found subdir ${fileOrNull.name}`); + res.locals.deepestFolderId = fileOrNull.id; + res.locals.deepestFolderName = fileOrNull.name; + }else{ + // Found actual file + console.log(`found file ${fileOrNull.name}`); + res.locals.file = fileOrNull; } - fileNames.splice(0, 1); + curDir = fileOrNull; } - if (file == null) { - console.log("file was null") - return next(); - } - console.log(file) - const parentFolder: File | null = await File.findOne({ - include: [ - { model: File, as: 'containedFilesInternal'} - ], - where: { - parentFolderId: file.id, - name: fileNames[0] - } - }); - console.log("parent folder: ") - console.log(parentFolder); - if (parentFolder == null) { - return next(); - } - res.locals.parentFolder = parentFolder; - const tFile: File | undefined = parentFolder.containedFiles.find( - (f: File): boolean => f.name === fileNames[1] - ); - res.locals.file = tFile; - res.locals.filename = fileNames[1]; next(); } ); @@ -793,6 +780,12 @@ export class FileRouter { } }); res.locals.file = file; + if(file) { + res.locals.filename = file.name; + res.locals.deepestFolderId = file.parentFolderId; + if(file.parentFolder) res.locals.deepestFolderName = file.parentFolder.name; + else console.log("parentfolder not set!") + } next(); } ); diff --git a/src/files.ts b/src/files.ts index 6572c53..a5fd08d 100644 --- a/src/files.ts +++ b/src/files.ts @@ -28,18 +28,6 @@ const readableStream: (filename: string, projectName: string, { offset, length } }; return fs.createReadStream(path(filename, projectName), options); }; -/* -// prj name, file uuid => if exists and return path string/ parent folder -const findParent: (projectName: string, fileUUID: string) => File | null = (projectName: string, fileUUID: string) => { - if(!projectName || !fileUUID){ - return null; - } - function findFile(dir: string, fileList: string[]) : string { - - } - -} -*/ const logPath: (type: string, projectName?: string) => string = ( type: string, projectName?: string): string => { @@ -209,9 +197,29 @@ export const createProjectFolder: (name: string) => void = (projName: string): a } } -export const addSubFileToFolder: (parentId: string, subFileId: string) => void = (parentId: string, subFileId: string): any => { - // TODO: - // fetch parent file object from database - // update parent file object +export const addSubFileToFolder: (parentId: string, subFileId: string) => Promise = async(parentId: string, subFileId: string): Promise => { + // Fetch parent and subFile object from database + const parent: File | null = await File.findOne({ + include: [{all: true}], + where: { + uuid: parentId + } + }); + const file: File | null = await File.findOne({ + include: [{all: true}], + where: { + uuid: subFileId + } + }); + if(!parent || !file){ + return false; + } + // update both objects + parent.containedFiles.push(file); + file.parentFolderId = parent.id; // save + await parent.save(); + await file.save(); + + return true; } -- cgit v1.2.1 From fb54545484732f149223a63d06eff4c7d98b8410 Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Tue, 17 Apr 2018 17:39:56 +0100 Subject: Fix tests for matcher, and minor import edits --- src/matcher/index.ts | 1 + test/unit/options.unit.test.ts | 162 ++++++++++++++++++++++------------------- 2 files changed, 88 insertions(+), 75 deletions(-) diff --git a/src/matcher/index.ts b/src/matcher/index.ts index 99cc18c..0806907 100644 --- a/src/matcher/index.ts +++ b/src/matcher/index.ts @@ -10,6 +10,7 @@ export { export { Atom, + isPresent as anything, isNumber as number, isString as string, isBoolean as boolean, diff --git a/test/unit/options.unit.test.ts b/test/unit/options.unit.test.ts index fd88ca6..a442c38 100644 --- a/test/unit/options.unit.test.ts +++ b/test/unit/options.unit.test.ts @@ -10,8 +10,9 @@ import * as chai from 'chai'; chai.should(); -import * as options from '../../src/matcher/options'; -import { default as types } from '../../src/matcher/types'; +import { anything, boolean, not_present, number, string +} from '../../src/matcher'; +import { array, match, optional } from '../../src/matcher/options'; // tslint:disable-next-line:no-require-imports @@ -20,115 +21,115 @@ describe('Matching:', () => { context('for literals', () => { context('accepts matching', () => { it('strings', () => { - options.match('a', 'a').should.be.true; + match('a', 'a').should.be.true; }); it('numbers', () => { - options.match(3, 3).should.be.true; + match(3, 3).should.be.true; }); it('boolean values', () => { - options.match(true, true).should.be.true; + match(true, true).should.be.true; }); it('null to null', () => { - options.match(null, null).should.be.true; + match(null, null).should.be.true; }); }); context('rejects', () => { it('different strings', () => { - options.match('x', 'y').should.be.false; + match('x', 'y').should.be.false; }); it('different numbers', () => { - options.match(20, 42).should.be.false; + match(20, 42).should.be.false; }); it('different boolean values', () => { - options.match(true, false).should.be.false; + match(true, false).should.be.false; }); it('different types', () => { - options.match('55', 55).should.be.false; + match('55', 55).should.be.false; }); it('null matched with non-null values', () => { - options.match(null, false).should.be.false; + match(null, false).should.be.false; }); it('non-null values matched with null', () => { - options.match(0, null).should.be.false; + match(0, null).should.be.false; }); }); }); context('for checker functions', () => { context('accepts', () => { it('values that succeed the checker function', () => { - options.match(types.number, 9).should.be.true; + match(number, 9).should.be.true; }); }); context('rejects', () => { it('values that do not succeed the checker function', () => { - options.match(types.boolean, 'true').should.be.false; + match(boolean, 'true').should.be.false; }); }); }); it('accepts basic things', () => { const template = { - a: types.string + a: string }; const matchee = { a: 'yes' }; - options.match(template, matchee).should.be.true; + match(template, matchee).should.be.true; }); it('accepts objects with superfluous properties', () => { const template = { - a: types.number + a: number }; const matchee = { a: 40, b: 20 }; - options.match(template, matchee).should.be.true; + match(template, matchee).should.be.true; }); it('rejects objects missing some properties', () => { const template = { - a: types.boolean, - b: types.number, - c: types.number + a: boolean, + b: number, + c: number }; const matchee = { b: 5 }; - options.match(template, matchee).should.be.false; + match(template, matchee).should.be.false; }); it('accepts objects that omit not_present properties', () => { const template = { - a: types.number, - b: types.not_present, - c: types.not_present + a: number, + b: not_present, + c: not_present }; const matchee = { a: 4 }; - options.match(template, matchee).should.be.true; + match(template, matchee).should.be.true; }); it('rejects empty objects for non-empty templates', () => { const template = { - a: types.boolean + a: boolean }; const matchee = { }; - options.match(template, matchee).should.be.false; + match(template, matchee).should.be.false; }); it('accepts empty objects for empty templates', () => { const template = { }; const matchee = { }; - options.match(template, matchee).should.be.true; + match(template, matchee).should.be.true; }); it('accepts nested objects that match', () => { const template = { - a: types.number, + a: number, b: { - ba: types.string, - bb: types.string + ba: string, + bb: string }, - c: types.boolean + c: boolean }; const matchee = { a: 432, @@ -139,7 +140,7 @@ describe('Matching:', () => { c: true, x: false }; - options.match(template, matchee).should.be.true; + match(template, matchee).should.be.true; }); it('accepts literal matches', () => { const template = { @@ -148,7 +149,7 @@ describe('Matching:', () => { const matchee = { a: 'literal' }; - options.match(template, matchee).should.be.true; + match(template, matchee).should.be.true; }); it('rejects incorrect literal matches', () => { const template = { @@ -157,65 +158,76 @@ describe('Matching:', () => { const matchee = { g: 80 }; - options.match(template, matchee).should.be.false; + match(template, matchee).should.be.false; }); it('accepts optional matches', () => { const template = { - a: options.optional(types.array), - b: options.optional(types.anything) + a: optional(number), + b: optional(anything) }; const matchee = { b: [] }; - options.match(template)(matchee).should.be.true; + match(template)(matchee).should.be.true; }); it('big bad unit test', () => { - /* tslint:disable:align */ - const matchee = { status: 'success', - data: [ { privilege: 'admin', description: 'null', internal: false }, - { privilege: 'logging', - description: 'Allows Post to Log', - internal: false } ] }; + const matchee = { + status: 'success', + data: [ + { + privilege: 'admin', + description: 'null', + internal: false + }, + { + privilege: 'logging', + description: 'Allows Post to Log', + internal: false + } + ] + }; const template = { - status: types.string, - data: options.optional(types.anything), - error: options.optional(types.string), - error_description: options.optional(types.string), - user_message: options.optional(types.string), - error_data: options.optional(types.anything) - }; - /* tslint:enable:align */ + status: string, + data: optional(anything), + error: optional(string), + error_description: optional(string), + user_message: optional(string), + error_data: optional(anything) + }; - options.match(template)(matchee).should.be.true; + match(template)(matchee).should.be.true; }); it('bigger badder unit test', () => { - /* tslint:disable:align */ - const matchee = [ { project_name: 'mocky', - users: [{ username: 'uname', access_level: 'admin'}], - public_metadata: { creation_date: '2018-04-14T17:13:44.291Z' }, + const matchee = [{ + project_name: 'mocky', + users: [{ + username: 'uname', + access_level: 'admin' + }], + public_metadata: { + creation_date: '2018-04-14T17:13:44.291Z' + }, private_metadata: {}, - admin_metadata: {} } ]; - const template = types.array({ - project_name: types.string, - users: types.array({ - username: types.string, - access_level: types.string + admin_metadata: {} + }]; + const template = array({ + project_name: string, + users: array({ + username: string, + access_level: string }), - public_metadata: types.anything, - private_metadata: options.optional(types.anything), - admin_metadata: options.optional(types.anything) + public_metadata: anything, + private_metadata: optional(anything), + admin_metadata: optional(anything) }); - /* tslint:enable:align */ - options.match(template)(matchee).should.be.true; + match(template)(matchee).should.be.true; }); - it.only('Matching Arrays', () => { - /* tslint:disable:align */ - const matchee: any = ['ss']; - const template: any = types.array; - /* tslint:enable:align */ + it('Matching Arrays', () => { + const matchee: string[] = ['ss']; + const template = array(string); - options.match(template)(matchee).should.be.true; + match(template)(matchee).should.be.true; }); }); }); -- cgit v1.2.1 From 8f1837af9400ef0ef5c1cab1e853b46e11b1b76b Mon Sep 17 00:00:00 2001 From: jw255 Date: Tue, 17 Apr 2018 18:43:06 +0100 Subject: Files - now actually works --- src/FileRouter.ts | 108 ++++++++++++++++++++++++++++++--------------------- src/db/model/File.ts | 14 ++++--- src/files.ts | 7 +++- 3 files changed, 78 insertions(+), 51 deletions(-) diff --git a/src/FileRouter.ts b/src/FileRouter.ts index 4b56b19..ed6567c 100644 --- a/src/FileRouter.ts +++ b/src/FileRouter.ts @@ -495,18 +495,21 @@ const postProjectName: Middleware = async( const file: File = new File({ uuid: uuid.generate(), mimetype: 'inode/directory', - name: req.params.project_name, parentFolderId: rootPathId }); + file.name = ''; // Leave blank as discussed promise = file.save(); createProjectFolder(req.params.project_name); + project = new Project({ name: req.params.project_name, rootFolder: file }); + project.rootFolderId = file.uuid; } else { logger.debug('Updating project properties'); } + project.metadata = req.body; // tslint:disable-next-line:await-promise await promise; @@ -563,48 +566,57 @@ const getFileId: Middleware = getFile; */ /* tslint:disable */ const postFilePath: Middleware = async(req: Request, res: Response, next: NextFunction): Promise => { - logger.debug(`Receiving file to ${res.locals.parentFolder}`); + logger.debug(`Receiving file ${res.locals.path}`); if (res.locals.file != null) { + // TODO update metadata or append to file next(new RequestError(400, 'file_exists')); } // lets have a res.locals.deepestFolderName (and Id) which is a string of the deepest parent folder found - let remainingPath: string = res.locals.path.split(res.locals.deepestFolderName)[1]; - console.log(`remainingPath: ${remainingPath}`) + let remainingPath: string = (res.locals.deepestFolderName == '') ? '/' + res.locals.path + : res.locals.path.split(res.locals.deepestFolderName)[1]; // Loop the part of the path that doesn't exist yet and create all the folders while((remainingPath.match(/\//g) || []).length > 1){ // If there are more subfolders that dont exist, then create them const subFolder: string = remainingPath.split("/")[1] - logger.debug(`Adding subfolder \'${subFolder}`); + logger.debug(`Adding subfolder \'${subFolder}\'`); const dir: File = new File({ uuid: uuid.generate(), mimetype: 'inode/directory', - name: subFolder, - parentFolderId: res.locals.deepestFolderId + nameInternal: subFolder//, + //parentFolderId: res.locals.deepestFolderId }); await dir.save(); // update parent directory of new directory - addSubFileToFolder(res.locals.deepestFolderId, dir.id); - + if(!await addSubFileToFolder(res.locals.deepestFolderId, dir.uuid)){ + logger.debug("adding file to folder failed!") + next(new RequestError(500, 'Adding file to folder failed')) + } // update vars remainingPath = remainingPath.split(subFolder)[1] res.locals.deepestFolderName = subFolder; - res.locals.deepestFolderId = dir.id; - console.log(`\tremainingPath: ${remainingPath}`) - console.log(`\tdeepestFolderName: ${res.locals.deepestFolderName}`) - console.log(`\tdeepestFolderId: ${res.locals.deepestFolderId}`) + res.locals.deepestFolderId = dir.uuid; } + logger.debug(`now adding the actual file \'${res.locals.filename}\' to folder \'${res.locals.deepestFolderName}\'`) + const file: File = new File({ uuid: uuid.generate(), - name: res.locals.filename, - parentFolder: res.locals.deepestFolderId + nameInternal: res.locals.filename//, + //parentFolder: res.locals.deepestFolderId }); + file.mimetype = req.headers['content-type']!; + + await file.save(); + // update parent directory of new directory - addSubFileToFolder(res.locals.deepestFolderId, file.id); + if(!await addSubFileToFolder(res.locals.deepestFolderId, file.uuid)){ + logger.debug("adding file to folder failed!") + next(new RequestError(500, 'Adding file to folder failed')) + } // TODO respond to correct query params (like update metadata, move, etc) // pipe the data @@ -710,55 +722,60 @@ export class FileRouter { req: Request, res: Response, next: NextFunction, filename: string ): Promise => { - // TODO \/ - // We need to find the res.locals.deepestFolderName (and Id) for the currently requested path + // Vars we assign here: + // - res.locals.deepestFolderName (...Id): deepest existing folder in path + // - res.locals.path: requested path (using "/") + // - res.locals.filename: requested file name (may be '') + // - res.locals.file: actual file object if it exists + // Vars arleady assigned: + // - res.locals.project: requested project object // Replace + with / - filename = filename.replace(/\+/g, '/'); - logger.debug(`Searching for file ${filename}`); - res.locals.path = filename; - - // split path into parts - const fileNames: string[] = req.params.path.split('/'); - res.locals.filename = fileNames[-1]; + res.locals.path = filename.replace(/\+/g, '/'); + logger.debug(`Searching for path \'${res.locals.path}\'`); + // Split path into parts + const fileNames: string[] = res.locals.path.split('/'); + res.locals.filename = (fileNames.length > 0) ? + fileNames[fileNames.length - 1] : ''; + logger.debug(`Searching for file \'${res.locals.filename}\'`); const project: Project | null = res.locals.project; if (project == null) { // Project should have been found by previous precondition logger.debug('Project was not found: skipping finding file'); return next(new RequestError(404, 'project_not_found')); } - console.debug(fileNames); - let curDir: File | null = project.rootFolder; - res.locals.deepestFolderId = curDir.id; + res.locals.deepestFolderId = curDir.uuid; res.locals.deepestFolderName = curDir.name; let i: number = 0; - - // Loop through the path and find the deepest folder that exists. Also find the file if possible. + // Loop through the path and find the deepest folder that exists. + // Also find the file if possible. while (curDir && i < fileNames.length) { + logger.debug(`Searching for \'${fileNames[i]}\'`); const fileOrNull: File | null = await File.findOne({ include: [{all: true}], where: { - name: fileNames[i], - parentFolder: curDir + nameInternal: fileNames[i], + parentFolderId: curDir.uuid } }); if (fileOrNull == null) { - console.log("next subdir not found in DB"); + logger.debug(`Sub-file \'${fileNames[i]}\' not found in DB`); return next(); - } - - if(i < fileNames.length-1){ + } + + if (i < fileNames.length - 1) { // Found next subdirectory - console.log(`found subdir ${fileOrNull.name}`); - res.locals.deepestFolderId = fileOrNull.id; - res.locals.deepestFolderName = fileOrNull.name; - }else{ + logger.debug(`Found Sub-folder \'${fileOrNull.name}\'`); + res.locals.deepestFolderId = fileOrNull.uuid; + res.locals.deepestFolderName = fileOrNull.name; + } else { // Found actual file - console.log(`found file ${fileOrNull.name}`); + logger.debug(`Found file \'${fileOrNull.name}\'`); res.locals.file = fileOrNull; } curDir = fileOrNull; + i++; } next(); @@ -772,7 +789,7 @@ export class FileRouter { req: Request, res: Response, next: NextFunction, fileId: string ): Promise => { - console.log(`parsing id ${fileId}`); + logger.info(`parsing id ${fileId}`); const file: File | null = await File.findOne({ include: [{all: true}], where: { @@ -783,8 +800,11 @@ export class FileRouter { if(file) { res.locals.filename = file.name; res.locals.deepestFolderId = file.parentFolderId; - if(file.parentFolder) res.locals.deepestFolderName = file.parentFolder.name; - else console.log("parentfolder not set!") + if (file.parentFolder) { + res.locals.deepestFolderName = file.parentFolder.name; + } else { + logger.debug('parentfolder not set!') + } } next(); } diff --git a/src/db/model/File.ts b/src/db/model/File.ts index 193a785..8a12431 100644 --- a/src/db/model/File.ts +++ b/src/db/model/File.ts @@ -27,7 +27,7 @@ import { FileTypeName, mimes } from '../../files'; export default class File extends Model { @AllowNull @Column - private nameInternal!: string; + public nameInternal!: string; @AllowNull @Column @@ -85,10 +85,14 @@ export default class File extends Model { public set name(name: string) { this.nameInternal = name; - this.fullPathInternal = this.fullPathInternal.substring( - 0, - this.fullPathInternal.lastIndexOf('/') + 1 - ) + this.name; + if (this.fullPathInternal) { + this.fullPathInternal = this.fullPathInternal.substring( + 0, + this.fullPathInternal.lastIndexOf('/') + 1 + ) + this.name; + } else { + this.fullPathInternal = this.name; + } } public get fullPath(): string { diff --git a/src/files.ts b/src/files.ts index a5fd08d..9be0381 100644 --- a/src/files.ts +++ b/src/files.ts @@ -1,11 +1,13 @@ import { Request, Response } from 'express'; import * as fs from 'fs'; +import { logger } from './logger'; import { default as File } from './db/model/File'; import { default as Project } from './db/model/Project'; const CONTENT_BASE_DIRECTORY: string = './files'; const LOG_BASE_DIRECTORY: string = './logs'; + /* tslint:disable */ const path: (filename: string, projectName: string) => string = (filename: string, projectName: string): string => { return `${CONTENT_BASE_DIRECTORY}/${projectName}/${filename}`; @@ -198,6 +200,7 @@ export const createProjectFolder: (name: string) => void = (projName: string): a } export const addSubFileToFolder: (parentId: string, subFileId: string) => Promise = async(parentId: string, subFileId: string): Promise => { + logger.debug(`adding file ${subFileId}) to directory ${parentId}`) // Fetch parent and subFile object from database const parent: File | null = await File.findOne({ include: [{all: true}], @@ -216,10 +219,10 @@ export const addSubFileToFolder: (parentId: string, subFileId: string) => Promis } // update both objects parent.containedFiles.push(file); - file.parentFolderId = parent.id; + file.parentFolderId = parent.uuid; // save - await parent.save(); await file.save(); + await parent.save(); return true; } -- cgit v1.2.1 From 505ae2d6af5ce31360f0f0b018a75cfee59cf3ac Mon Sep 17 00:00:00 2001 From: jw255 Date: Tue, 17 Apr 2018 22:58:03 +0100 Subject: using multer for files now --- package.json | 46 +++- src/FileRouter.ts | 28 ++- src/files.ts | 20 +- yarn.lock | 673 +++++++++++++++++++----------------------------------- 4 files changed, 315 insertions(+), 452 deletions(-) diff --git a/package.json b/package.json index c187871..f26bbe9 100644 --- a/package.json +++ b/package.json @@ -48,8 +48,10 @@ "@types/colors": "^1.1.3", "@types/express": "^4.0.33", "@types/express-jwt": "^0.0.38", + "@types/fs-extra": "^5.0.2", "@types/jsonwebtoken": "^7.2.5", "@types/morgan": "^1.7.32", + "@types/multer": "^1.3.6", "@types/node": "^6.0.46", "@types/passport": "^0.4.2", "@types/passport-local": "^1.0.32", @@ -65,14 +67,16 @@ "express": "^4.16.2", "express-jwt": "^5.3.0", "file-system": "^2.2.2", + "fs-extra": "^5.0.0", "jsonwebtoken": "^8.1.1", "mocha-each": "^1.1.0", "morgan": "^1.9.0", + "multer": "^1.3.0", "passport": "^0.4.0", "passport-local": "^1.0.0", - "pg": "^7.4.1", - "pg-hstore": "^2.3.2", - "pg-native": "^2.2.0", + "pg": "^7.3.0", + "pg-hstore": "^2.3.1", + "pg-native": "^2.1.9", "pmx": "^1.6.4", "reflect-metadata": "^0.1.12", "sequelize": "^4.32.7", @@ -86,5 +90,41 @@ "winston": "^2.4.0", "xlsx": "^0.11.19", "xml-parser": "^1.2.1" + }, + "resolutions": { + "@types/node": "9.6.5", + "@types/lodash": "4.14.107", + "@types/bluebird": "3.5.20", + "debug": "2.6.9", + "depd": "1.1.2", + "http-errors": "1.6.3", + "iconv-lite": "0.4.19", + "ms": "2.0.0", + "setprototypeof": "1.1.0", + "statuses": "1.5.0", + "mime": "1.4.1", + "async": "1.5.2", + "sprintf-js": "1.1.1", + "pg-types": "1.12.0", + "semver": "4.3.2", + "readable-stream": "1.0.31", + "nan": "2.10.0", + "isarray": "0.0.1", + "string_decoder": "0.10.31", + "glob": "7.1.2", + "minimist": "1.2.0", + "pump": "2.0.1", + "superagent": "3.8.2", + "cookiejar": "2.1.1", + "form-data": "2.3.2", + "chalk": "2.4.0", + "diff": "3.5.0", + "ansi-styles": "3.2.1", + "supports-color": "5.4.0", + "has-flag": "3.0.0", + "source-map": "0.5.7", + "commander": "2.13.0", + "type-detect": "1.0.0", + "wordwrap": "0.0.3" } } diff --git a/src/FileRouter.ts b/src/FileRouter.ts index ed6567c..8dc8468 100644 --- a/src/FileRouter.ts +++ b/src/FileRouter.ts @@ -6,13 +6,13 @@ import { UserFullInfo, default as User } from './db/model/User'; import { default as UserGroup } from './db/model/UserGroup'; import { NextFunction, Request, Response, Router } from 'express'; - import { RequestError } from './errors/errorware'; -import { addSubFileToFolder, View, files, views, rootPathId, createProjectFolder } from './files'; +import { addSubFileToFolder, View, files, views, rootPathId, createProjectFolder, upload, moveFile } from './files'; import { logger } from './logger'; import { Property, default as serverConfig } from './serverConfig'; import { uuid } from './uuid'; + /** * The type of an Express middleware callback. */ @@ -567,6 +567,8 @@ const getFileId: Middleware = getFile; /* tslint:disable */ const postFilePath: Middleware = async(req: Request, res: Response, next: NextFunction): Promise => { logger.debug(`Receiving file ${res.locals.path}`); + console.log(req.file); + // req.query.action if (res.locals.file != null) { // TODO update metadata or append to file @@ -605,10 +607,9 @@ const postFilePath: Middleware = async(req: Request, res: Response, next: NextFu const file: File = new File({ uuid: uuid.generate(), - nameInternal: res.locals.filename//, - //parentFolder: res.locals.deepestFolderId + nameInternal: res.locals.filename }); - file.mimetype = req.headers['content-type']!; + file.mimetype = req.file.mimetype; await file.save(); @@ -618,9 +619,8 @@ const postFilePath: Middleware = async(req: Request, res: Response, next: NextFu next(new RequestError(500, 'Adding file to folder failed')) } - // TODO respond to correct query params (like update metadata, move, etc) - // pipe the data - req.pipe(files.writableStream(file.uuid, res.locals.project.name)); + // Move temp file to proper location + moveFile(req.file.originalname, res.locals.project.name, file.uuid); next(); }; /* tslint:enable */ @@ -665,7 +665,8 @@ export class FileRouter { this.router.get ('/projects/:project_name/properties', getProjectProperties); // File access this.router.get ('/projects/:project_name/files/:path', getFilePath); - this.router.post('/projects/:project_name/files/:path', postFilePath); + this.router.post('/projects/:project_name/files/:path', + upload.single('userfile'), postFilePath); this.router.get ('/projects/:project_name/files_by_id/:id', getFileId); } @@ -730,6 +731,9 @@ export class FileRouter { // Vars arleady assigned: // - res.locals.project: requested project object + //console.log(`req.file.filename: ${req.file}`) + console.log(req.file) + // Replace + with / res.locals.path = filename.replace(/\+/g, '/'); logger.debug(`Searching for path \'${res.locals.path}\'`); @@ -748,7 +752,7 @@ export class FileRouter { res.locals.deepestFolderId = curDir.uuid; res.locals.deepestFolderName = curDir.name; let i: number = 0; - // Loop through the path and find the deepest folder that exists. + // Loop through the path and find the deepest folder that exists. // Also find the file if possible. while (curDir && i < fileNames.length) { logger.debug(`Searching for \'${fileNames[i]}\'`); @@ -797,13 +801,13 @@ export class FileRouter { } }); res.locals.file = file; - if(file) { + if (file) { res.locals.filename = file.name; res.locals.deepestFolderId = file.parentFolderId; if (file.parentFolder) { res.locals.deepestFolderName = file.parentFolder.name; } else { - logger.debug('parentfolder not set!') + logger.debug('parentfolder not set!'); } } next(); diff --git a/src/files.ts b/src/files.ts index 9be0381..b0e63aa 100644 --- a/src/files.ts +++ b/src/files.ts @@ -1,6 +1,7 @@ import { Request, Response } from 'express'; -import * as fs from 'fs'; +import * as fs from 'fs-extra'; import { logger } from './logger'; +import * as Multer from 'multer'; import { default as File } from './db/model/File'; import { default as Project } from './db/model/Project'; @@ -38,6 +39,23 @@ const logPath: (type: string, projectName?: string) => string = ( : `${LOG_BASE_DIRECTORY}/general/${type}`; }; +let storage = Multer.diskStorage({ + destination: function (req, file, cb) { + cb(null, CONTENT_BASE_DIRECTORY) + }, + filename: function (req, file, cb) { + cb(null, `temp-${file.originalname}`) + } +}); + +export const upload: Multer.Instance = Multer({ storage: storage }); + +export const moveFile: (filename: string, projectname: string, fileId: string) => void = + (filename: string, projectname: string, fileId: string): void => { + + fs.moveSync(`${CONTENT_BASE_DIRECTORY}/temp-${filename}`, `${CONTENT_BASE_DIRECTORY}/${projectname}/${fileId}`); +} + export const files: { path: (f: string, p: string) => string; writableStream: (f: string, p: string) => fs.WriteStream; diff --git a/yarn.lock b/yarn.lock index 7b18d1c..1a2cc9f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,14 +2,10 @@ # yarn lockfile v1 -"@types/bluebird@*": +"@types/bluebird@*", "@types/bluebird@3.5.18", "@types/bluebird@3.5.20": version "3.5.20" resolved "https://registry.yarnpkg.com/@types/bluebird/-/bluebird-3.5.20.tgz#f6363172add6f4eabb8cada53ca9af2781e8d6a1" -"@types/bluebird@3.5.18": - version "3.5.18" - resolved "https://registry.yarnpkg.com/@types/bluebird/-/bluebird-3.5.18.tgz#6a60435d4663e290f3709898a4f75014f279c4d6" - "@types/body-parser@*": version "1.16.8" resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.16.8.tgz#687ec34140624a3bec2b1a8ea9268478ae8f3be3" @@ -39,8 +35,10 @@ resolved "https://registry.yarnpkg.com/@types/chai/-/chai-3.5.2.tgz#c11cd2817d3a401b7ba0f5a420f35c56139b1c1e" "@types/colors@^1.1.3": - version "1.1.3" - resolved "https://registry.yarnpkg.com/@types/colors/-/colors-1.1.3.tgz#5413b0a7a1b16dd18be0e3fd57d2feecc81cc776" + version "1.2.1" + resolved "https://registry.yarnpkg.com/@types/colors/-/colors-1.2.1.tgz#57703f1a9f7f5fc40afb81eef13e96acdd1016a6" + dependencies: + colors "*" "@types/continuation-local-storage@*": version "3.2.1" @@ -90,6 +88,12 @@ dependencies: "@types/node" "*" +"@types/fs-extra@^5.0.2": + version "5.0.2" + resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-5.0.2.tgz#235a7e2b56452cc0a6a4809b53e1d1eaffff9c96" + dependencies: + "@types/node" "*" + "@types/geojson@^1.0.0": version "1.0.6" resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-1.0.6.tgz#3e02972728c69248c2af08d60a48cbb8680fffdf" @@ -111,18 +115,14 @@ resolved "https://registry.yarnpkg.com/@types/highlight.js/-/highlight.js-9.12.2.tgz#6ee7cd395effe5ec80b515d3ff1699068cd0cd1d" "@types/jsonwebtoken@^7.2.5": - version "7.2.5" - resolved "https://registry.yarnpkg.com/@types/jsonwebtoken/-/jsonwebtoken-7.2.5.tgz#413159d570ec45fc3e7da7ea3f7bca6fb9300e72" + version "7.2.6" + resolved "https://registry.yarnpkg.com/@types/jsonwebtoken/-/jsonwebtoken-7.2.6.tgz#8d018c21ca5910b5eb3ebcb385656606a215032f" dependencies: "@types/node" "*" -"@types/lodash@*": - version "4.14.104" - resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.104.tgz#53ee2357fa2e6e68379341d92eb2ecea4b11bb80" - -"@types/lodash@4.14.99": - version "4.14.99" - resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.99.tgz#e6e10c0a4cc16c7409b3181f1e66880d2fb7d4dc" +"@types/lodash@*", "@types/lodash@4.14.107", "@types/lodash@4.14.99": + version "4.14.107" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.107.tgz#b2d2ae3958bfb8ff828495cbe12214af9e4d035e" "@types/marked@0.3.0": version "0.3.0" @@ -142,7 +142,11 @@ dependencies: "@types/mocha" "*" -"@types/mocha@*", "@types/mocha@^2.2.32": +"@types/mocha@*": + version "5.0.0" + resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-5.0.0.tgz#a3014921991066193f6c8e47290d4d598dfd19e6" + +"@types/mocha@^2.2.32": version "2.2.48" resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-2.2.48.tgz#3523b126a0b049482e1c3c11877460f76622ffab" @@ -152,36 +156,38 @@ dependencies: "@types/express" "*" -"@types/node@*": - version "9.4.6" - resolved "https://registry.yarnpkg.com/@types/node/-/node-9.4.6.tgz#d8176d864ee48753d053783e4e463aec86b8d82e" +"@types/multer@^1.3.6": + version "1.3.6" + resolved "https://registry.yarnpkg.com/@types/multer/-/multer-1.3.6.tgz#e00454074bf9fd86d20ea652eba9850eb76604c4" + dependencies: + "@types/express" "*" -"@types/node@6.0.41": - version "6.0.41" - resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.41.tgz#578cf53aaec65887bcaf16792f8722932e8ff8ea" +"@types/node@*", "@types/node@6.0.41", "@types/node@9.6.5": + version "9.6.5" + resolved "https://registry.yarnpkg.com/@types/node/-/node-9.6.5.tgz#ee700810fdf49ac1c399fc5980b7559b3e5a381d" "@types/node@^6.0.46": - version "6.0.101" - resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.101.tgz#0c5911cfb434af4a51c0a499931fe6423207d921" + version "6.0.106" + resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.106.tgz#391bc3598ab5823563f7155847212152893edcd7" "@types/passport-local@^1.0.32": - version "1.0.32" - resolved "https://registry.yarnpkg.com/@types/passport-local/-/passport-local-1.0.32.tgz#0856e3772c46ab8ac89aacf5535fa001a2ce5a13" + version "1.0.33" + resolved "https://registry.yarnpkg.com/@types/passport-local/-/passport-local-1.0.33.tgz#d245b60c5b801cb3aeca1ffab557d5fe1534260d" dependencies: "@types/express" "*" "@types/passport" "*" "@types/passport-strategy" "*" "@types/passport-strategy@*": - version "0.2.32" - resolved "https://registry.yarnpkg.com/@types/passport-strategy/-/passport-strategy-0.2.32.tgz#0c1fb2e3b83621c8faf68c92f37898453ef60f71" + version "0.2.33" + resolved "https://registry.yarnpkg.com/@types/passport-strategy/-/passport-strategy-0.2.33.tgz#a523c6526262f96d9e4063d9285721551d87889b" dependencies: "@types/express" "*" "@types/passport" "*" "@types/passport@*", "@types/passport@^0.4.2": - version "0.4.3" - resolved "https://registry.yarnpkg.com/@types/passport/-/passport-0.4.3.tgz#ca4f9611fb67d0c5d581a9005e9b89a2f5e91a3a" + version "0.4.4" + resolved "https://registry.yarnpkg.com/@types/passport/-/passport-0.4.4.tgz#934acc2b8870fdde1800f48effd92cbf5c2646f5" dependencies: "@types/express" "*" @@ -199,8 +205,8 @@ "@types/validator" "*" "@types/sequelize@^4.27.5": - version "4.27.8" - resolved "https://registry.yarnpkg.com/@types/sequelize/-/sequelize-4.27.8.tgz#432eca1a5acd9ea40a49cc947676fe918aca17ec" + version "4.27.14" + resolved "https://registry.yarnpkg.com/@types/sequelize/-/sequelize-4.27.14.tgz#621dcc33db884e1fca368dc1b9fa7a60b38785d3" dependencies: "@types/bluebird" "*" "@types/continuation-local-storage" "*" @@ -215,8 +221,8 @@ "@types/mime" "*" "@types/sharp@^0.17.6": - version "0.17.6" - resolved "https://registry.yarnpkg.com/@types/sharp/-/sharp-0.17.6.tgz#3138602163b30b4969f75a2755a3f90caaaa9be3" + version "0.17.8" + resolved "https://registry.yarnpkg.com/@types/sharp/-/sharp-0.17.8.tgz#0d02f36030549ccd29f31c1badd06c15a4e998ef" dependencies: "@types/node" "*" @@ -228,14 +234,15 @@ "@types/node" "*" "@types/sqlite3@^3.1.1": - version "3.1.1" - resolved "https://registry.yarnpkg.com/@types/sqlite3/-/sqlite3-3.1.1.tgz#f9b707c574e8d2f73d6c41aaa86e28b6ef85a324" + version "3.1.3" + resolved "https://registry.yarnpkg.com/@types/sqlite3/-/sqlite3-3.1.3.tgz#580d547203b8ad6e11aa6a6769c8ca5d7e197d13" dependencies: + "@types/events" "*" "@types/node" "*" "@types/superagent@*": - version "3.5.7" - resolved "https://registry.yarnpkg.com/@types/superagent/-/superagent-3.5.7.tgz#c170633e7dff01425b4712bb3afac3a12be49b7b" + version "3.5.8" + resolved "https://registry.yarnpkg.com/@types/superagent/-/superagent-3.5.8.tgz#da2b5d6a5bc77b4bf1b6d082ec4c3328ba5c3b9f" dependencies: "@types/node" "*" @@ -256,8 +263,8 @@ resolved "https://registry.yarnpkg.com/@types/validator/-/validator-9.4.0.tgz#a4a80a31d3e4e094806ec446557808423379858d" "@types/winston@^2.3.8": - version "2.3.8" - resolved "https://registry.yarnpkg.com/@types/winston/-/winston-2.3.8.tgz#88964f45ecb5ed1feb4bfb38a24316bee8bf8768" + version "2.3.9" + resolved "https://registry.yarnpkg.com/@types/winston/-/winston-2.3.9.tgz#1ff9f1bb57952fe3d88c1b21c4899ede316a35bc" dependencies: "@types/node" "*" @@ -269,7 +276,7 @@ abbrev@1: version "1.1.1" resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" -accepts@~1.3.4: +accepts@~1.3.5: version "1.3.5" resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.5.tgz#eb777df6011723a3b14e8a72c0805c8e86746bd2" dependencies: @@ -291,24 +298,24 @@ align-text@^0.1.1, align-text@^0.1.3: longest "^1.0.1" repeat-string "^1.5.2" -amdefine@>=0.0.4: - version "1.0.1" - resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" - ansi-regex@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" -ansi-styles@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" - -ansi-styles@^3.2.1: +ansi-styles@3.2.1, ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" dependencies: color-convert "^1.9.0" +ap@~0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/ap/-/ap-0.2.0.tgz#ae0942600b29912f0d2b14ec60c45e8f330b6110" + +append-field@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/append-field/-/append-field-0.1.0.tgz#6ddc58fa083c7bc545d3c5995b2830cc2366d44a" + aproba@^1.0.3: version "1.2.0" resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" @@ -345,14 +352,10 @@ async-listener@^0.6.0: semver "^5.3.0" shimmer "^1.1.0" -async@^1.4.0, async@^1.5.0, async@^1.5.2: +async@1.5.2, async@^1.4.0, async@^1.5.0, async@~1.0.0: version "1.5.2" resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" -async@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/async/-/async-1.0.0.tgz#f8fc04ca3a13784ade9e1641af98578cfbd647a9" - asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" @@ -384,10 +387,11 @@ bindings@1.2.1: resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.2.1.tgz#14ad6113812d2d37d72e67b4cacb4bb726505f11" bl@^1.0.0: - version "1.2.1" - resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.1.tgz#cac328f7bee45730d404b692203fcb590e172d5e" + version "1.2.2" + resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.2.tgz#a160911717103c07410cef63ef51b397c025af9c" dependencies: - readable-stream "^2.0.5" + readable-stream "^2.3.5" + safe-buffer "^5.1.1" bluebird@^3.4.6, bluebird@^3.5.0: version "3.5.1" @@ -423,6 +427,10 @@ buffer-equal-constant-time@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz#f8e71132f7ffe6e01a5c9697a4c6f3e48d5cc819" +buffer-from@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.0.0.tgz#4cb8832d23612589b0406e9e2956c17f06fdf531" + buffer-writer@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/buffer-writer/-/buffer-writer-1.0.1.tgz#22a936901e3029afcd7547eb4487ceb697a3bf08" @@ -431,6 +439,13 @@ builtin-modules@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" +busboy@^0.2.11: + version "0.2.14" + resolved "https://registry.yarnpkg.com/busboy/-/busboy-0.2.14.tgz#6c2a622efcf47c57bbbe1e2a9c37ad36c7925453" + dependencies: + dicer "0.2.5" + readable-stream "1.1.x" + bytes@3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048" @@ -447,8 +462,8 @@ center-align@^0.1.1: lazy-cache "^1.0.3" cfb@~1.0.2: - version "1.0.5" - resolved "https://registry.yarnpkg.com/cfb/-/cfb-1.0.5.tgz#5f7cf2fcb385dd41db271cf1f28a83fcd705bf06" + version "1.0.6" + resolved "https://registry.yarnpkg.com/cfb/-/cfb-1.0.6.tgz#d0107fa579a8d79c53a31074a755abcb898017f0" dependencies: commander "^2.14.1" printj "~1.1.2" @@ -471,19 +486,9 @@ chai@^3.5.0: deep-eql "^0.1.3" type-detect "^1.0.0" -chalk@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" - dependencies: - ansi-styles "^2.2.1" - escape-string-regexp "^1.0.2" - has-ansi "^2.0.0" - strip-ansi "^3.0.0" - supports-color "^2.0.0" - -chalk@^2.0.0, chalk@^2.3.0: - version "2.3.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.2.tgz#250dc96b07491bfd601e648d66ddf5f60c7a5c65" +chalk@2.4.0, chalk@^1.1.3, chalk@^2.0.0, chalk@^2.3.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.0.tgz#a060a297a6b57e15b61ca63ce84995daa0fe6e52" dependencies: ansi-styles "^3.2.1" escape-string-regexp "^1.0.5" @@ -543,31 +548,21 @@ color@^3.0.0: color-convert "^1.9.1" color-string "^1.5.2" +colors@*, colors@^1.1.2: + version "1.2.1" + resolved "https://registry.yarnpkg.com/colors/-/colors-1.2.1.tgz#f4a3d302976aaf042356ba1ade3b1a2c62d9d794" + colors@1.0.x: version "1.0.3" resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b" -colors@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63" - -combined-stream@1.0.6, combined-stream@^1.0.5: +combined-stream@1.0.6: version "1.0.6" resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.6.tgz#723e7df6e801ac5613113a7e445a9b69cb632818" dependencies: delayed-stream "~1.0.0" -commander@2.9.0: - version "2.9.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" - dependencies: - graceful-readlink ">= 1.0.0" - -commander@^2.12.1, commander@^2.14.1, commander@~2.14.1: - version "2.14.1" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.14.1.tgz#2235123e37af8ca3c65df45b026dbd357b01b9aa" - -commander@~2.13.0: +commander@2.13.0, commander@2.9.0, commander@^2.12.1, commander@^2.14.1, commander@~2.13.0, commander@~2.14.1: version "2.13.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c" @@ -579,6 +574,15 @@ concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" +concat-stream@^1.5.0: + version "1.6.2" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" + dependencies: + buffer-from "^1.0.0" + inherits "^2.0.3" + readable-stream "^2.2.2" + typedarray "^0.0.6" + console-control-strings@^1.0.0, console-control-strings@~1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" @@ -606,11 +610,7 @@ cookie@0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" -cookiejar@2.0.x: - version "2.0.6" - resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.0.6.tgz#0abf356ad00d1c5a219d88d44518046dd026acfe" - -cookiejar@^2.0.6, cookiejar@^2.1.0: +cookiejar@2.0.x, cookiejar@2.1.1, cookiejar@^2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.1.tgz#41ad57b1b555951ec171412a81942b1e8200d34a" @@ -629,24 +629,12 @@ cycle@1.0.x: version "1.0.3" resolved "https://registry.yarnpkg.com/cycle/-/cycle-1.0.3.tgz#21e80b2be8580f98b468f379430662b046c34ad2" -debug@2.6.8: - version "2.6.8" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" - dependencies: - ms "2.0.0" - -debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.6.3, debug@^2.6.9: +debug@2.6.8, debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.6.3, debug@^2.6.9, debug@^3, debug@^3.1.0: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" dependencies: ms "2.0.0" -debug@^3, debug@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" - dependencies: - ms "2.0.0" - decamelize@^1.0.0: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -681,11 +669,7 @@ delegates@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" -depd@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.1.tgz#5783b4e1c459f06fa5ca27f991f3d06e7a310359" - -depd@^1.1.0, depd@~1.1.1: +depd@1.1.2, depd@^1.1.0, depd@~1.1.1, depd@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" @@ -697,11 +681,14 @@ detect-libc@^1.0.2, detect-libc@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" -diff@3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9" +dicer@0.2.5: + version "0.2.5" + resolved "https://registry.yarnpkg.com/dicer/-/dicer-0.2.5.tgz#5996c086bb33218c812c090bddc09cd12facb70f" + dependencies: + readable-stream "1.1.x" + streamsearch "0.1.2" -diff@^3.1.0, diff@^3.2.0: +diff@3.2.0, diff@3.5.0, diff@^3.1.0, diff@^3.2.0: version "3.5.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" @@ -726,7 +713,7 @@ emitter-listener@^1.1.1: dependencies: shimmer "^1.2.0" -encodeurl@~1.0.1: +encodeurl@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" @@ -744,7 +731,7 @@ escape-html@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" -escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: +escape-string-regexp@1.0.5, escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" @@ -769,12 +756,12 @@ expand-template@^1.0.2: resolved "https://registry.yarnpkg.com/expand-template/-/expand-template-1.1.0.tgz#e09efba977bf98f9ee0ed25abd0c692e02aec3fc" express-jwt@^5.3.0: - version "5.3.0" - resolved "https://registry.yarnpkg.com/express-jwt/-/express-jwt-5.3.0.tgz#3d90cd65802e6336252f19e6a3df3e149e0c5ea0" + version "5.3.1" + resolved "https://registry.yarnpkg.com/express-jwt/-/express-jwt-5.3.1.tgz#66f05c7dddb5409c037346a98b88965bb10ea4ae" dependencies: async "^1.5.0" express-unless "^0.3.0" - jsonwebtoken "^7.3.0" + jsonwebtoken "^8.1.0" lodash.set "^4.0.0" express-unless@^0.3.0: @@ -782,10 +769,10 @@ express-unless@^0.3.0: resolved "https://registry.yarnpkg.com/express-unless/-/express-unless-0.3.1.tgz#2557c146e75beb903e2d247f9b5ba01452696e20" express@^4.16.2: - version "4.16.2" - resolved "https://registry.yarnpkg.com/express/-/express-4.16.2.tgz#e35c6dfe2d64b7dca0a5cd4f21781be3299e076c" + version "4.16.3" + resolved "https://registry.yarnpkg.com/express/-/express-4.16.3.tgz#6af8a502350db3246ecc4becf6b5a34d22f7ed53" dependencies: - accepts "~1.3.4" + accepts "~1.3.5" array-flatten "1.1.1" body-parser "1.18.2" content-disposition "0.5.2" @@ -793,26 +780,26 @@ express@^4.16.2: cookie "0.3.1" cookie-signature "1.0.6" debug "2.6.9" - depd "~1.1.1" - encodeurl "~1.0.1" + depd "~1.1.2" + encodeurl "~1.0.2" escape-html "~1.0.3" etag "~1.8.1" - finalhandler "1.1.0" + finalhandler "1.1.1" fresh "0.5.2" merge-descriptors "1.0.1" methods "~1.1.2" on-finished "~2.3.0" parseurl "~1.3.2" path-to-regexp "0.1.7" - proxy-addr "~2.0.2" + proxy-addr "~2.0.3" qs "6.5.1" range-parser "~1.2.0" safe-buffer "5.1.1" - send "0.16.1" - serve-static "1.13.1" + send "0.16.2" + serve-static "1.13.2" setprototypeof "1.1.0" - statuses "~1.3.1" - type-is "~1.6.15" + statuses "~1.4.0" + type-is "~1.6.16" utils-merge "1.0.1" vary "~1.1.2" @@ -837,27 +824,19 @@ file-system@^2.2.2: file-match "^1.0.1" utils-extend "^1.0.4" -finalhandler@1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.0.tgz#ce0b6855b45853e791b2fcc680046d88253dd7f5" +finalhandler@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.1.tgz#eebf4ed840079c83f4249038c9d703008301b105" dependencies: debug "2.6.9" - encodeurl "~1.0.1" + encodeurl "~1.0.2" escape-html "~1.0.3" on-finished "~2.3.0" parseurl "~1.3.2" - statuses "~1.3.1" + statuses "~1.4.0" unpipe "~1.0.0" -form-data@1.0.0-rc4: - version "1.0.0-rc4" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-1.0.0-rc4.tgz#05ac6bc22227b43e4461f488161554699d4f8b5e" - dependencies: - async "^1.5.2" - combined-stream "^1.0.5" - mime-types "^2.1.10" - -form-data@^2.3.1: +form-data@2.3.2, form-data@^2.3.1: version "2.3.2" resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.2.tgz#4970498be604c20c005d4f5c23aecd21d6b49099" dependencies: @@ -865,9 +844,9 @@ form-data@^2.3.1: combined-stream "1.0.6" mime-types "^2.1.12" -formidable@^1.0.17, formidable@^1.1.1: - version "1.2.0" - resolved "https://registry.yarnpkg.com/formidable/-/formidable-1.2.0.tgz#ce291bfec67c176e282f891ece2c37de0c83ae84" +formidable@^1.1.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/formidable/-/formidable-1.2.1.tgz#70fb7ca0290ee6ff961090415f4b3df3d2082659" forwarded@~0.1.2: version "0.1.2" @@ -893,7 +872,7 @@ fs-extra@^5.0.0: jsonfile "^4.0.0" universalify "^0.1.0" -fs-minipass@^1.2.3, fs-minipass@^1.2.5: +fs-minipass@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.5.tgz#06c277218454ec288df77ada54a03b8702aacb9d" dependencies: @@ -924,18 +903,7 @@ github-from-package@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/github-from-package/-/github-from-package-0.0.0.tgz#97fb5d96bfde8973313f20e8288ef9a167fa64ce" -glob@7.1.1: - version "7.1.1" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.2" - once "^1.3.0" - path-is-absolute "^1.0.0" - -glob@7.1.2, glob@^7.0.0, glob@^7.0.5, glob@^7.1.1: +glob@7.1.1, glob@7.1.2, glob@^7.0.0, glob@^7.0.5, glob@^7.1.1: version "7.1.2" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" dependencies: @@ -950,10 +918,6 @@ graceful-fs@^4.1.2, graceful-fs@^4.1.6: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" -"graceful-readlink@>= 1.0.0": - version "1.0.1" - resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" - growl@1.9.2: version "1.9.2" resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f" @@ -968,17 +932,7 @@ handlebars@^4.0.6: optionalDependencies: uglify-js "^2.6" -has-ansi@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" - dependencies: - ansi-regex "^2.0.0" - -has-flag@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" - -has-flag@^3.0.0: +has-flag@3.0.0, has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" @@ -994,24 +948,20 @@ highlight.js@^9.0.0: version "9.12.0" resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.12.0.tgz#e6d9dbe57cbefe60751f02af336195870c90c01e" -hoek@2.x.x: - version "2.16.3" - resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" - homedir-polyfill@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz#4c2bbc8a758998feebf5ed68580f76d46768b4bc" dependencies: parse-passwd "^1.0.0" -http-errors@1.6.2, http-errors@~1.6.2: - version "1.6.2" - resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.2.tgz#0a002cc85707192a7e7946ceedc11155f60ec736" +http-errors@1.6.2, http-errors@1.6.3, http-errors@~1.6.2: + version "1.6.3" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.3.tgz#8b55680bb4be283a0b5bf4ea2e38580be1d9320d" dependencies: - depd "1.1.1" + depd "~1.1.2" inherits "2.0.3" - setprototypeof "1.0.3" - statuses ">= 1.3.1 < 2" + setprototypeof "1.1.0" + statuses ">= 1.4.0 < 2" iconv-lite@0.4.19, iconv-lite@^0.4.4: version "0.4.19" @@ -1034,7 +984,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@2.0.3, inherits@~2.0.1, inherits@~2.0.3: +inherits@2, inherits@2.0.3, inherits@^2.0.3, inherits@~2.0.1: version "2.0.3" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" @@ -1086,27 +1036,10 @@ isarray@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" -isarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" - -isemail@1.x.x: - version "1.2.0" - resolved "https://registry.yarnpkg.com/isemail/-/isemail-1.2.0.tgz#be03df8cc3e29de4d2c5df6501263f1fa4595e9a" - isstream@0.1.x: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" -joi@^6.10.1: - version "6.10.1" - resolved "https://registry.yarnpkg.com/joi/-/joi-6.10.1.tgz#4d50c318079122000fe5f16af1ff8e1917b77e06" - dependencies: - hoek "2.x.x" - isemail "1.x.x" - moment "2.x.x" - topo "1.x.x" - js-string-escape@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/js-string-escape/-/js-string-escape-1.0.1.tgz#e2625badbc0d67c7533e9edc1068c587ae4137ef" @@ -1136,19 +1069,9 @@ jsonfile@^4.0.0: optionalDependencies: graceful-fs "^4.1.6" -jsonwebtoken@^7.3.0: - version "7.4.3" - resolved "https://registry.yarnpkg.com/jsonwebtoken/-/jsonwebtoken-7.4.3.tgz#77f5021de058b605a1783fa1283e99812e645638" - dependencies: - joi "^6.10.1" - jws "^3.1.4" - lodash.once "^4.0.0" - ms "^2.0.0" - xtend "^4.0.1" - -jsonwebtoken@^8.1.1: - version "8.2.0" - resolved "https://registry.yarnpkg.com/jsonwebtoken/-/jsonwebtoken-8.2.0.tgz#690ec3a9e7e95e2884347ce3e9eb9d389aa598b3" +jsonwebtoken@^8.1.0, jsonwebtoken@^8.1.1: + version "8.2.1" + resolved "https://registry.yarnpkg.com/jsonwebtoken/-/jsonwebtoken-8.2.1.tgz#333ee39aa8f238f32fa41693e7a2fb7e42f82b31" dependencies: jws "^3.1.4" lodash.includes "^4.3.0" @@ -1299,8 +1222,8 @@ make-error@^1.1.1: resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.4.tgz#19978ed575f9e9545d2ff8c13e33b5d18a67d535" marked@^0.3.12: - version "0.3.17" - resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.17.tgz#607f06668b3c6b1246b28f13da76116ac1aa2d2b" + version "0.3.19" + resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.19.tgz#5d47f709c4c9fc3c216b6d46127280f40b39d790" media-typer@0.3.0: version "0.3.0" @@ -1318,42 +1241,30 @@ mime-db@~1.33.0: version "1.33.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.33.0.tgz#a3492050a5cb9b63450541e39d9788d2272783db" -mime-types@^2.1.10, mime-types@^2.1.12, mime-types@~2.1.18: +mime-types@^2.1.12, mime-types@~2.1.18: version "2.1.18" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.18.tgz#6f323f60a83d11146f831ff11fd66e2fe5503bb8" dependencies: mime-db "~1.33.0" -mime@1.4.1: +mime@1.4.1, mime@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/mime/-/mime-1.4.1.tgz#121f9ebc49e3766f311a76e1fa1c8003c4b03aa6" -mime@^1.3.4, mime@^1.4.1: - version "1.6.0" - resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" - mimic-response@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.0.tgz#df3d3652a73fded6b9b0b24146e6fd052353458e" -minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4: +minimatch@^3.0.0, minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" dependencies: brace-expansion "^1.1.7" -minimist@0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" - -minimist@^1.2.0: +minimist@0.0.8, minimist@1.2.0, minimist@^1.2.0, minimist@~0.0.1: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" -minimist@~0.0.1: - version "0.0.10" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" - minipass@^2.2.1, minipass@^2.2.4: version "2.2.4" resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.2.4.tgz#03c824d84551ec38a8d1bb5bc350a5a30a354a40" @@ -1397,14 +1308,14 @@ mocha@^3.1.2: supports-color "3.1.2" moment-timezone@^0.5.14: - version "0.5.14" - resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.14.tgz#4eb38ff9538b80108ba467a458f3ed4268ccfcb1" + version "0.5.15" + resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.15.tgz#0e2acec4a424850b4e0e3e08984532726563ad4c" dependencies: moment ">= 2.9.0" -moment@2.x.x, "moment@>= 2.9.0", moment@^2.20.0: - version "2.21.0" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.21.0.tgz#2a114b51d2a6ec9e6d83cf803f838a878d8a023a" +"moment@>= 2.9.0", moment@^2.20.0: + version "2.22.1" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.1.tgz#529a2e9bf973f259c9643d237fda84de3a26e8ad" morgan@^1.9.0: version "1.9.0" @@ -1416,21 +1327,26 @@ morgan@^1.9.0: on-finished "~2.3.0" on-headers "~1.0.1" -ms@2.0.0: +ms@2.0.0, ms@^2.1.1: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" -ms@^2.0.0, ms@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" - -nan@^2.3.0: - version "2.8.0" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.8.0.tgz#ed715f3fe9de02b57a5e6252d90a96675e1f085a" +multer@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/multer/-/multer-1.3.0.tgz#092b2670f6846fa4914965efc8cf94c20fec6cd2" + dependencies: + append-field "^0.1.0" + busboy "^0.2.11" + concat-stream "^1.5.0" + mkdirp "^0.5.1" + object-assign "^3.0.0" + on-finished "^2.3.0" + type-is "^1.6.4" + xtend "^4.0.0" -nan@^2.9.2, nan@~2.9.2: - version "2.9.2" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.9.2.tgz#f564d75f5f8f36a6d9456cca7a6c4fe488ab7866" +nan@2.10.0, nan@^2.10.0, nan@^2.3.0, nan@~2.9.2: + version "2.10.0" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.10.0.tgz#96d0cd610ebd58d4b4de9cc0c6828cda99c7548f" needle@^2.2.0: version "2.2.0" @@ -1451,8 +1367,8 @@ node-abi@^2.2.0: semver "^5.4.1" node-pre-gyp@~0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.9.0.tgz#bdd4c3afac9b1b1ebff0a9ff3362859eb6781bb8" + version "0.9.1" + resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.9.1.tgz#f11c07516dd92f87199dbc7e1838eab7cd56c9e0" dependencies: detect-libc "^1.0.2" mkdirp "^0.5.1" @@ -1500,11 +1416,15 @@ number-is-nan@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" +object-assign@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-3.0.0.tgz#9bedd5ca0897949bca47e7ff408062d549f587f2" + object-assign@^4.1.0: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" -on-finished@~2.3.0: +on-finished@^2.3.0, on-finished@~2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" dependencies: @@ -1591,17 +1511,13 @@ pg-connection-string@0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-0.1.3.tgz#da1847b20940e42ee1492beaf65d49d91b245df7" -pg-hstore@^2.3.2: +pg-hstore@^2.3.1: version "2.3.2" resolved "https://registry.yarnpkg.com/pg-hstore/-/pg-hstore-2.3.2.tgz#f7ef053e7b9b892ae986af2f7cbe86432dfcf24f" dependencies: underscore "^1.7.0" -pg-int8@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/pg-int8/-/pg-int8-1.0.1.tgz#943bd463bf5b71b4170115f80f8efc9a0c0eb78c" - -pg-native@^2.2.0: +pg-native@^2.1.9: version "2.2.0" resolved "https://registry.yarnpkg.com/pg-native/-/pg-native-2.2.0.tgz#bc84756f4ecbf600ff7cb48ea5854141830cf1e4" dependencies: @@ -1613,26 +1529,17 @@ pg-pool@~2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-2.0.3.tgz#c022032c8949f312a4f91fb6409ce04076be3257" -pg-types@^1.12.1: - version "1.13.0" - resolved "https://registry.yarnpkg.com/pg-types/-/pg-types-1.13.0.tgz#75f490b8a8abf75f1386ef5ec4455ecf6b345c63" - dependencies: - pg-int8 "1.0.1" - postgres-array "~1.0.0" - postgres-bytea "~1.0.0" - postgres-date "~1.0.0" - postgres-interval "^1.1.0" - -pg-types@~1.12.1: - version "1.12.1" - resolved "https://registry.yarnpkg.com/pg-types/-/pg-types-1.12.1.tgz#d64087e3903b58ffaad279e7595c52208a14c3d2" +pg-types@1.12.0, pg-types@^1.12.1, pg-types@~1.12.1: + version "1.12.0" + resolved "https://registry.yarnpkg.com/pg-types/-/pg-types-1.12.0.tgz#8ad3b7b897e3fd463e62de241ad5fc640b4a66f0" dependencies: + ap "~0.2.0" postgres-array "~1.0.0" postgres-bytea "~1.0.0" postgres-date "~1.0.0" postgres-interval "^1.1.0" -pg@^7.4.1: +pg@^7.3.0: version "7.4.1" resolved "https://registry.yarnpkg.com/pg/-/pg-7.4.1.tgz#f3411c8ddf9f692322fe05e7017a1888e47f78f1" dependencies: @@ -1680,8 +1587,8 @@ postgres-interval@^1.1.0: xtend "^4.0.0" prebuild-install@^2.5.1: - version "2.5.1" - resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-2.5.1.tgz#0f234140a73760813657c413cdccdda58296b1da" + version "2.5.3" + resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-2.5.3.tgz#9f65f242782d370296353710e9bc843490c19f69" dependencies: detect-libc "^1.0.3" expand-template "^1.0.2" @@ -1703,36 +1610,25 @@ printj@~1.1.0, printj@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/printj/-/printj-1.1.2.tgz#d90deb2975a8b9f600fb3a1c94e3f4c53c78a222" -process-nextick-args@~2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa" - progress@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f" -proxy-addr@~2.0.2: +proxy-addr@~2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.3.tgz#355f262505a621646b3130a728eb647e22055341" dependencies: forwarded "~0.1.2" ipaddr.js "1.6.0" -pump@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/pump/-/pump-1.0.3.tgz#5dfe8311c33bbf6fc18261f9f34702c47c08a954" - dependencies: - end-of-stream "^1.1.0" - once "^1.3.1" - -pump@^2.0.1: +pump@2.0.1, pump@^1.0.0, pump@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/pump/-/pump-2.0.1.tgz#12399add6e4cf7526d973cbc8b5ce2e2908b3909" dependencies: end-of-stream "^1.1.0" once "^1.3.1" -qs@6.5.1, qs@^6.1.0, qs@^6.2.0, qs@^6.5.1: +qs@6.5.1, qs@^6.2.0, qs@^6.5.1: version "6.5.1" resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" @@ -1749,16 +1645,7 @@ raw-body@2.3.2: iconv-lite "0.4.19" unpipe "1.0.0" -rc@^1.1.6: - version "1.2.5" - resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.5.tgz#275cd687f6e3b36cc756baa26dfee80a790301fd" - dependencies: - deep-extend "~0.4.0" - ini "~1.3.0" - minimist "^1.2.0" - strip-json-comments "~2.0.1" - -rc@^1.1.7: +rc@^1.1.6, rc@^1.1.7: version "1.2.6" resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.6.tgz#eb18989c6d4f4f162c399f79ddd29f3835568092" dependencies: @@ -1767,7 +1654,7 @@ rc@^1.1.7: minimist "^1.2.0" strip-json-comments "~2.0.1" -readable-stream@1.0.31: +readable-stream@1.0.31, readable-stream@1.1.x, readable-stream@^2.0.0, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.2.2, readable-stream@^2.3.5: version "1.0.31" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.31.tgz#8f2502e0bc9e3b0da1b94520aabb4e2603ecafae" dependencies: @@ -1776,18 +1663,6 @@ readable-stream@1.0.31: isarray "0.0.1" string_decoder "~0.10.x" -readable-stream@^2.0.0, readable-stream@^2.0.5, readable-stream@^2.0.6: - version "2.3.5" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.5.tgz#b4f85003a938cbb6ecbce2a124fb1012bd1a838d" - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.3" - isarray "~1.0.0" - process-nextick-args "~2.0.0" - safe-buffer "~5.1.1" - string_decoder "~1.0.3" - util-deprecate "~1.0.1" - rechoir@^0.6.2: version "0.6.2" resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" @@ -1803,8 +1678,8 @@ repeat-string@^1.5.2: resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" resolve@^1.1.6, resolve@^1.3.2: - version "1.5.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.5.0.tgz#1f09acce796c9a762579f31b2c1cc4c3cddf9f36" + version "1.7.1" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.7.1.tgz#aadd656374fd298aee895bc026b8297418677fd3" dependencies: path-parse "^1.0.5" @@ -1827,7 +1702,7 @@ rimraf@^2.6.1: dependencies: glob "^7.0.5" -safe-buffer@5.1.1, safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1: +safe-buffer@5.1.1, safe-buffer@^5.0.1, safe-buffer@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" @@ -1835,22 +1710,18 @@ sax@^1.2.4: version "1.2.4" resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" -semver@4.3.2: +semver@4.3.2, semver@5.*, semver@^5.0.1, semver@^5.3.0, semver@^5.4.1, semver@^5.5.0: version "4.3.2" resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.2.tgz#c7a07158a80bedd052355b770d82d6640f803be7" -semver@5.*, semver@^5.0.1, semver@^5.3.0, semver@^5.4.1, semver@^5.5.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab" - -send@0.16.1: - version "0.16.1" - resolved "https://registry.yarnpkg.com/send/-/send-0.16.1.tgz#a70e1ca21d1382c11d0d9f6231deb281080d7ab3" +send@0.16.2: + version "0.16.2" + resolved "https://registry.yarnpkg.com/send/-/send-0.16.2.tgz#6ecca1e0f8c156d141597559848df64730a6bbc1" dependencies: debug "2.6.9" - depd "~1.1.1" + depd "~1.1.2" destroy "~1.0.4" - encodeurl "~1.0.1" + encodeurl "~1.0.2" escape-html "~1.0.3" etag "~1.8.1" fresh "0.5.2" @@ -1859,7 +1730,7 @@ send@0.16.1: ms "2.0.0" on-finished "~2.3.0" range-parser "~1.2.0" - statuses "~1.3.1" + statuses "~1.4.0" sequelize-typescript@^0.6.2: version "0.6.3" @@ -1873,8 +1744,8 @@ sequelize-typescript@^0.6.2: glob "7.1.2" sequelize@^4.32.7: - version "4.35.2" - resolved "https://registry.yarnpkg.com/sequelize/-/sequelize-4.35.2.tgz#936db62c0bb63368bdb33ae58e76282aae5ec360" + version "4.37.6" + resolved "https://registry.yarnpkg.com/sequelize/-/sequelize-4.37.6.tgz#f37eec55a285cfdeab27f8a85c5db38034f87126" dependencies: bluebird "^3.5.0" cls-bluebird "^2.1.0" @@ -1894,35 +1765,31 @@ sequelize@^4.32.7: validator "^9.4.1" wkx "^0.4.1" -serve-static@1.13.1: - version "1.13.1" - resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.13.1.tgz#4c57d53404a761d8f2e7c1e8a18a47dbf278a719" +serve-static@1.13.2: + version "1.13.2" + resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.13.2.tgz#095e8472fd5b46237db50ce486a43f4b86c6cec1" dependencies: - encodeurl "~1.0.1" + encodeurl "~1.0.2" escape-html "~1.0.3" parseurl "~1.3.2" - send "0.16.1" + send "0.16.2" set-blocking@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" -setprototypeof@1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.0.3.tgz#66567e37043eeb4f04d91bd658c0cbefb55b8e04" - setprototypeof@1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.0.tgz#d0bd85536887b6fe7c0d818cb962d9d91c54e656" sharp@^0.20.0: - version "0.20.0" - resolved "https://registry.yarnpkg.com/sharp/-/sharp-0.20.0.tgz#2ff9f1ae11f068ce7d7591f531cad52c7821d033" + version "0.20.1" + resolved "https://registry.yarnpkg.com/sharp/-/sharp-0.20.1.tgz#13adde896bc9ec0372b0907554e0329f35a7bce6" dependencies: color "^3.0.0" detect-libc "^1.0.3" fs-copy-file-sync "^1.0.1" - nan "^2.9.2" + nan "^2.10.0" npmlog "^4.1.2" prebuild-install "^2.5.1" semver "^5.5.0" @@ -1970,13 +1837,7 @@ source-map-support@^0.4.0: dependencies: source-map "^0.5.6" -source-map@^0.4.4: - version "0.4.4" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b" - dependencies: - amdefine ">=0.0.4" - -source-map@^0.5.6, source-map@~0.5.1: +source-map@0.5.7, source-map@^0.4.4, source-map@^0.5.6, source-map@~0.5.1: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" @@ -1986,14 +1847,10 @@ split@^1.0.0: dependencies: through "2" -sprintf-js@^1.0.3: +sprintf-js@1.1.1, sprintf-js@^1.0.3, sprintf-js@~1.0.2: version "1.1.1" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.1.tgz#36be78320afe5801f6cea3ee78b6e5aab940ea0c" -sprintf-js@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - sqlite3@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/sqlite3/-/sqlite3-4.0.0.tgz#cc0e093ab51873f50d9dfc4126fcbef15d486570" @@ -2011,13 +1868,13 @@ stack-trace@0.0.x: version "0.0.10" resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0" -"statuses@>= 1.3.1 < 2": - version "1.4.0" - resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.4.0.tgz#bb73d446da2796106efcc1b601a253d6c46bd087" +statuses@1.5.0, "statuses@>= 1.4.0 < 2", statuses@~1.4.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" -statuses@~1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e" +streamsearch@0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/streamsearch/-/streamsearch-0.1.2.tgz#808b9d0e56fc273d809ba57338e929919a1a9f1a" string-width@^1.0.1, string-width@^1.0.2: version "1.0.2" @@ -2027,16 +1884,10 @@ string-width@^1.0.1, string-width@^1.0.2: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -string_decoder@~0.10.x: +string_decoder@0.10.31, string_decoder@~0.10.x: version "0.10.31" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" -string_decoder@~1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab" - dependencies: - safe-buffer "~5.1.0" - strip-ansi@^3.0.0, strip-ansi@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" @@ -2051,22 +1902,7 @@ strip-json-comments@^2.0.0, strip-json-comments@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" -superagent@^2.0.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/superagent/-/superagent-2.3.0.tgz#703529a0714e57e123959ddefbce193b2e50d115" - dependencies: - component-emitter "^1.2.0" - cookiejar "^2.0.6" - debug "^2.2.0" - extend "^3.0.0" - form-data "1.0.0-rc4" - formidable "^1.0.17" - methods "^1.1.1" - mime "^1.3.4" - qs "^6.1.0" - readable-stream "^2.0.5" - -superagent@^3.0.0: +superagent@3.8.2, superagent@^2.0.0, superagent@^3.0.0: version "3.8.2" resolved "https://registry.yarnpkg.com/superagent/-/superagent-3.8.2.tgz#e4a11b9d047f7d3efeb3bbe536d9ec0021d16403" dependencies: @@ -2088,19 +1924,9 @@ supertest@^3.0.0: methods "~1.1.2" superagent "^3.0.0" -supports-color@3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.1.2.tgz#72a262894d9d408b956ca05ff37b2ed8a6e2a2d5" - dependencies: - has-flag "^1.0.0" - -supports-color@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" - -supports-color@^5.3.0: - version "5.3.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.3.0.tgz#5b24ac15db80fa927cf5227a4a33fd3c4c7676c0" +supports-color@3.1.2, supports-color@5.4.0, supports-color@^5.3.0: + version "5.4.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.4.0.tgz#1c6b337402c2137605efe19f10fec390f6faab54" dependencies: has-flag "^3.0.0" @@ -2122,7 +1948,7 @@ tar-stream@^1.1.2: readable-stream "^2.0.0" xtend "^4.0.0" -tar@^4: +tar@^4, tar@^4.4.0: version "4.4.1" resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.1.tgz#b25d5a8470c976fd7a9a8a350f42c59e9fa81749" dependencies: @@ -2134,17 +1960,6 @@ tar@^4: safe-buffer "^5.1.1" yallist "^3.0.2" -tar@^4.4.0: - version "4.4.0" - resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.0.tgz#3aaf8c29b6b800a8215f33efb4df1c95ce2ac2f5" - dependencies: - chownr "^1.0.1" - fs-minipass "^1.2.3" - minipass "^2.2.1" - minizlib "^1.1.0" - mkdirp "^0.5.0" - yallist "^3.0.2" - terraformer-wkt-parser@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/terraformer-wkt-parser/-/terraformer-wkt-parser-1.1.2.tgz#336a0c8fc82094a5aff83288f69aedecd369bf0c" @@ -2161,12 +1976,6 @@ through@2: version "2.3.8" resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" -topo@1.x.x: - version "1.1.0" - resolved "https://registry.yarnpkg.com/topo/-/topo-1.1.0.tgz#e9d751615d1bb87dc865db182fa1ca0a5ef536d5" - dependencies: - hoek "2.x.x" - toposort-class@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/toposort-class/-/toposort-class-1.0.1.tgz#7ffd1f78c8be28c3ba45cd4e1a3f5ee193bd9988" @@ -2215,8 +2024,8 @@ tslint@^5.9.1: tsutils "^2.12.1" tsutils@^2.12.1: - version "2.22.2" - resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.22.2.tgz#0b9f3d87aa3eb95bd32d26ce2b88aa329a657951" + version "2.26.1" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.26.1.tgz#9e4a0cb9ff173863f34c22a961969081270d1878" dependencies: tslib "^1.8.1" @@ -2226,21 +2035,21 @@ tunnel-agent@^0.6.0: dependencies: safe-buffer "^5.0.1" -type-detect@0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-0.1.1.tgz#0ba5ec2a885640e470ea4e8505971900dac58822" - -type-detect@^1.0.0: +type-detect@0.1.1, type-detect@1.0.0, type-detect@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-1.0.0.tgz#762217cc06db258ec48908a1298e8b95121e8ea2" -type-is@~1.6.15: +type-is@^1.6.4, type-is@~1.6.15, type-is@~1.6.16: version "1.6.16" resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.16.tgz#f89ce341541c672b25ee7ae3c73dee3b2be50194" dependencies: media-typer "0.3.0" mime-types "~2.1.18" +typedarray@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" + typedoc-default-themes@^0.5.0: version "0.5.0" resolved "https://registry.yarnpkg.com/typedoc-default-themes/-/typedoc-default-themes-0.5.0.tgz#6dc2433e78ed8bea8e887a3acde2f31785bd6227" @@ -2272,8 +2081,8 @@ typescript@2.7.1: resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.7.1.tgz#bb3682c2c791ac90e7c6210b26478a8da085c359" typescript@^2.7.1: - version "2.7.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.7.2.tgz#2d615a1ef4aee4f574425cdff7026edf81919836" + version "2.8.1" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.8.1.tgz#6160e4f8f195d5ba81d4876f9c0cc1fbc0820624" uglify-js@^2.6: version "2.8.29" @@ -2300,10 +2109,6 @@ unpipe@1.0.0, unpipe@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" -util-deprecate@~1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - utils-extend@^1.0.4, utils-extend@^1.0.6: version "1.0.8" resolved "https://registry.yarnpkg.com/utils-extend/-/utils-extend-1.0.8.tgz#ccfd7b64540f8e90ee21eec57769d0651cab8a5f" @@ -2361,8 +2166,8 @@ window-size@0.1.0: resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d" winston@^2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/winston/-/winston-2.4.0.tgz#808050b93d52661ed9fb6c26b3f0c826708b0aee" + version "2.4.1" + resolved "https://registry.yarnpkg.com/winston/-/winston-2.4.1.tgz#a3a9265105564263c6785b4583b8c8aca26fded6" dependencies: async "~1.0.0" colors "1.0.x" @@ -2377,11 +2182,7 @@ wkx@^0.4.1: dependencies: "@types/node" "*" -wordwrap@0.0.2: - version "0.0.2" - resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" - -wordwrap@~0.0.2: +wordwrap@0.0.2, wordwrap@0.0.3, wordwrap@~0.0.2: version "0.0.3" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" -- cgit v1.2.1 From f37c8433ea3bca786898c46c03b86557fa0b6bb3 Mon Sep 17 00:00:00 2001 From: jw255 Date: Wed, 18 Apr 2018 16:50:30 +0100 Subject: POST file parameters maybe working --- res/file_upload.ods | Bin 0 -> 14061 bytes src/FileRouter.ts | 177 ++++++++++++++++++++++++++++++++++++++++------------ src/files.ts | 26 +++++++- 3 files changed, 160 insertions(+), 43 deletions(-) create mode 100644 res/file_upload.ods diff --git a/res/file_upload.ods b/res/file_upload.ods new file mode 100644 index 0000000..d20cffe Binary files /dev/null and b/res/file_upload.ods differ diff --git a/src/FileRouter.ts b/src/FileRouter.ts index 8dc8468..3796544 100644 --- a/src/FileRouter.ts +++ b/src/FileRouter.ts @@ -7,7 +7,7 @@ import { default as UserGroup } from './db/model/UserGroup'; import { NextFunction, Request, Response, Router } from 'express'; import { RequestError } from './errors/errorware'; -import { addSubFileToFolder, View, files, views, rootPathId, createProjectFolder, upload, moveFile } from './files'; +import { addSubFileToFolder, View, files, views, rootPathId, createProjectFolder, upload, deleteFile, truncateFile, saveFile } from './files'; import { logger } from './logger'; import { Property, default as serverConfig } from './serverConfig'; import { uuid } from './uuid'; @@ -546,7 +546,9 @@ const getFile: Middleware = async( } const project: Project = res.locals.project; const view: View = views[req.query.view || 'meta']; - res.locals.function = view.getResponseFunction(req, res); + // TODO return 400 for unsuported views + // TODO raw view accepts extra query params offset and length + res.locals.function = view.getResponseFunction(req, res); res.locals.data = view.getResponseData(file, project, req.query); next(); }; @@ -561,6 +563,42 @@ const getFilePath: Middleware = getFile; */ const getFileId: Middleware = getFile; +namespace qH { + export const hasAction: ((req: Request) => boolean) = (req: Request): boolean => { + return (req.query.action ? true : false); + } + export const setsMetadata: ((req: Request) => boolean) = (req: Request): boolean => { + return (req.query.action && req.query.action == 'set_metadata' ? true : false); + } + export const mksDir: ((req: Request) => boolean) = (req: Request): boolean => { + return (req.query.action && req.query.action == 'mkdir' ? true : false); + } + export const deletes: ((req: Request) => boolean) = (req: Request): boolean => { + return (req.query.action && req.query.action == 'delete' ? true : false); + } + export const moves: ((req: Request) => boolean) = (req: Request): boolean => { + return (req.query.action && req.query.action == 'move' ? true : false); + } + export const copys: ((req: Request) => boolean) = (req: Request): boolean => { + return (req.query.action && req.query.action == 'copy' ? true : false); + } + export const overwrites: ((req: Request) => boolean) = (req: Request): boolean => { + return (req.query.overwrite ? req.query.overwrite : false); + } + export const offset: ((req: Request) => number) = (req: Request): number => { + return (req.query.offset ? req.query.offset : 0); + } + export const truncates: ((req: Request) => boolean) = (req: Request): boolean => { + return (req.query.truncate ? req.query.truncate : false); + } + export const isFinal: ((req: Request) => boolean) = (req: Request): boolean => { + return (req.query.final ? req.query.final : false); + } + export const nothingSet: ((req: Request) => boolean) = (req: Request): boolean => { + return (!hasAction(req) && !overwrites(req) && !truncates(req) && !isFinal(req)); + } +} + /** * Post a File. / delete / move / etc */ @@ -568,60 +606,119 @@ const getFileId: Middleware = getFile; const postFilePath: Middleware = async(req: Request, res: Response, next: NextFunction): Promise => { logger.debug(`Receiving file ${res.locals.path}`); console.log(req.file); - // req.query.action + // req.query.action: set_metadata, mkdir, delete, move, copy + // req.query.overwrite (bool) + // req.query.offset (int) + // req.query.truncate (bool) + // req.query.final (bool) + + // Return 404 when one of these actions is attempted on non-existing file + if (res.locals.file == null && (qH.setsMetadata(req) || qH.deletes(req) || qH.moves(req) || qH.copys(req))){ + logger.debug(`Action \'${req.query.action}\' not valid if file does not exist`); + next(new RequestError(404, 'file_not_found')); + } - if (res.locals.file != null) { - // TODO update metadata or append to file + // Return 400 when one of these actions is attempted on existing file + if (res.locals.file != null && (qH.nothingSet(req) || qH.mksDir(req))) { + logger.debug(`Action \'${req.query.action}\' not valid if file exists`); next(new RequestError(400, 'file_exists')); } - // lets have a res.locals.deepestFolderName (and Id) which is a string of the deepest parent folder found - let remainingPath: string = (res.locals.deepestFolderName == '') ? '/' + res.locals.path - : res.locals.path.split(res.locals.deepestFolderName)[1]; - - // Loop the part of the path that doesn't exist yet and create all the folders - while((remainingPath.match(/\//g) || []).length > 1){ - // If there are more subfolders that dont exist, then create them - const subFolder: string = remainingPath.split("/")[1] - logger.debug(`Adding subfolder \'${subFolder}\'`); - const dir: File = new File({ + // Sets final if requested + if (res.locals.file && qH.isFinal(req)) { + res.locals.file.status = 'final'; + } + + // Sets Metadata if requested + if(qH.setsMetadata(req)){ + res.locals.file.metadata = req.body; + await res.locals.file.save(); + next(); + } + + // Deletes File if requested + if(qH.deletes(req)){ + deleteFile(res.locals.file.uuid, res.locals.project.name); + await res.locals.file.delete(); + next(); + } + + // Moves File if requested + if(qH.moves(req)){ + // TODO + next(new RequestError(500, 'not_implemented')); + } + + // Copies File if requested + if(qH.copys(req)){ + // TODO + next(new RequestError(500, 'not_implemented')); + } + + // Overwrite data but not truncate + // eg. OOOONNNNNNOOOO (O = old data, N = new data) + if(qH.overwrites(req) && !qH.truncates(req)){ + // TODO + next(new RequestError(500, 'not_implemented', 'please specify truncate parameter')); + } + + // Create File or Folder if file doesn't exist + if (res.locals.file == null){ + // lets have a res.locals.deepestFolderName (and Id) which is a string of the deepest parent folder found + let remainingPath: string = (res.locals.deepestFolderName == '') ? '/' + res.locals.path + : res.locals.path.split(res.locals.deepestFolderName)[1]; + + // Loop the part of the path that doesn't exist yet and create all the folders + while((remainingPath.match(/\//g) || []).length > 1){ + // If there are more subfolders that dont exist, then create them + const subFolder: string = remainingPath.split("/")[1] + logger.debug(`Adding subfolder \'${subFolder}\'`); + const dir: File = new File({ + uuid: uuid.generate(), + mimetype: 'inode/directory', + nameInternal: subFolder + }); + await dir.save(); + + // update parent directory of new directory + if(!await addSubFileToFolder(res.locals.deepestFolderId, dir.uuid)){ + logger.debug("adding file to folder failed!") + next(new RequestError(500, 'Adding file to folder failed')) + } + // update vars + remainingPath = remainingPath.split(subFolder)[1] + res.locals.deepestFolderName = subFolder; + res.locals.deepestFolderId = dir.uuid; + } + + logger.debug(`Writing file \'${res.locals.filename}\' to folder \'${res.locals.deepestFolderName}\'`) + res.locals.file = new File({ uuid: uuid.generate(), - mimetype: 'inode/directory', - nameInternal: subFolder//, - //parentFolderId: res.locals.deepestFolderId + nameInternal: res.locals.filename }); - await dir.save(); + res.locals.file.mimetype = qH.mksDir(req) ? 'inode/directory' : req.file.mimetype; + + await res.locals.file.save(); // update parent directory of new directory - if(!await addSubFileToFolder(res.locals.deepestFolderId, dir.uuid)){ + if(!await addSubFileToFolder(res.locals.deepestFolderId, res.locals.file.uuid)){ logger.debug("adding file to folder failed!") next(new RequestError(500, 'Adding file to folder failed')) } - // update vars - remainingPath = remainingPath.split(subFolder)[1] - res.locals.deepestFolderName = subFolder; - res.locals.deepestFolderId = dir.uuid; } - logger.debug(`now adding the actual file \'${res.locals.filename}\' to folder \'${res.locals.deepestFolderName}\'`) - - const file: File = new File({ - uuid: uuid.generate(), - nameInternal: res.locals.filename - }); - file.mimetype = req.file.mimetype; - - await file.save(); - - // update parent directory of new directory - if(!await addSubFileToFolder(res.locals.deepestFolderId, file.uuid)){ - logger.debug("adding file to folder failed!") - next(new RequestError(500, 'Adding file to folder failed')) + // Move temp file to proper location (if not directory) + if(!qH.mksDir(req)){ + saveFile(req.file.originalname, res.locals.project.name, res.locals.file.uuid, qH.offset(req)); } - // Move temp file to proper location - moveFile(req.file.originalname, res.locals.project.name, file.uuid); + // Sets final if requested + if (qH.isFinal(req)) { + res.locals.file.status = 'final'; + } + next(); + }; /* tslint:enable */ diff --git a/src/files.ts b/src/files.ts index b0e63aa..92ed165 100644 --- a/src/files.ts +++ b/src/files.ts @@ -50,10 +50,30 @@ let storage = Multer.diskStorage({ export const upload: Multer.Instance = Multer({ storage: storage }); -export const moveFile: (filename: string, projectname: string, fileId: string) => void = - (filename: string, projectname: string, fileId: string): void => { +export const saveFile: (filename: string, projectname: string, fileId: string, offset: number, truncate?: boolean) => void = + (filename: string, projectname: string, fileId: string, offset: number, truncate?: boolean): void => { + // TODO only overwrite beginning of file and keep rest of data + // ensure file exists + fs.ensureFileSync(`${CONTENT_BASE_DIRECTORY}/${projectname}/${fileId}`); + // truncate to offset + truncateFile(fileId, projectname, offset); + // open streams to append to file + let rStream = fs.createReadStream(`${CONTENT_BASE_DIRECTORY}/temp-${filename}`); + let wStream = fs.createWriteStream(`${CONTENT_BASE_DIRECTORY}/${projectname}/${fileId}`, {'flags':'a'}); + rStream.pipe(wStream); +} + +export const deleteFile: (fileId: string, projectName: string) => void = + (fileId: string, projectName: string): void => { - fs.moveSync(`${CONTENT_BASE_DIRECTORY}/temp-${filename}`, `${CONTENT_BASE_DIRECTORY}/${projectname}/${fileId}`); + fs.removeSync(`${CONTENT_BASE_DIRECTORY}/${projectName}/${fileId}`); +} + +export const truncateFile: (fileId: string, projectName: string, newLength: number) => void = + (fileId: string, projectName: string, newLength: number): void => { + // get the file descriptor of the file to be truncated + const fd: number = fs.openSync(`${CONTENT_BASE_DIRECTORY}/${projectName}/${fileId}`, 'r+'); + fs.ftruncateSync(fd, newLength); } export const files: { -- cgit v1.2.1 From b9cb14f9368e281ab01d92cc8864cdcb4a0cb386 Mon Sep 17 00:00:00 2001 From: jw255 Date: Thu, 19 Apr 2018 11:08:40 +0100 Subject: minor fixes --- src/FileRouter.ts | 6 +++++- src/files.ts | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/FileRouter.ts b/src/FileRouter.ts index 3796544..70d3d51 100644 --- a/src/FileRouter.ts +++ b/src/FileRouter.ts @@ -563,6 +563,9 @@ const getFilePath: Middleware = getFile; */ const getFileId: Middleware = getFile; +/** + * Checks the parameters for file posting + */ namespace qH { export const hasAction: ((req: Request) => boolean) = (req: Request): boolean => { return (req.query.action ? true : false); @@ -638,8 +641,9 @@ const postFilePath: Middleware = async(req: Request, res: Response, next: NextFu // Deletes File if requested if(qH.deletes(req)){ + logger.info(`File ${res.locals.file.name} will be deleted`) deleteFile(res.locals.file.uuid, res.locals.project.name); - await res.locals.file.delete(); + await res.locals.file.destroy(); next(); } diff --git a/src/files.ts b/src/files.ts index 92ed165..1b8a652 100644 --- a/src/files.ts +++ b/src/files.ts @@ -60,7 +60,11 @@ export const saveFile: (filename: string, projectname: string, fileId: string, o // open streams to append to file let rStream = fs.createReadStream(`${CONTENT_BASE_DIRECTORY}/temp-${filename}`); let wStream = fs.createWriteStream(`${CONTENT_BASE_DIRECTORY}/${projectname}/${fileId}`, {'flags':'a'}); - rStream.pipe(wStream); + rStream.pipe(wStream).on('finish', () => { + fs.removeSync(`${CONTENT_BASE_DIRECTORY}/temp-${filename}`); + }).on('error', (err: any) => { + logger.debug(`Error while saving file to proper location: ${err}`); + }); } export const deleteFile: (fileId: string, projectName: string) => void = -- cgit v1.2.1 From 8af06a4e7ea7ebaa29559a345d28791079b77dd3 Mon Sep 17 00:00:00 2001 From: jw255 Date: Thu, 19 Apr 2018 14:21:38 +0100 Subject: no reset --- iris.csv | 151 +++++++++++++++++ report/deliverable-3.zip | Bin 0 -> 6265275 bytes report/deliverable-3/Makefile | 9 ++ report/deliverable-3/appendix/minutes.tex | 68 ++++++++ report/deliverable-3/appendix/scrumboard.tex | 8 + report/deliverable-3/biblio.bib | 189 ++++++++++++++++++++++ report/deliverable-3/graphics/1.png | Bin 0 -> 23078 bytes report/deliverable-3/graphics/2.png | Bin 0 -> 76186 bytes report/deliverable-3/graphics/3.png | Bin 0 -> 37309 bytes report/deliverable-3/graphics/4.png | Bin 0 -> 17337 bytes report/deliverable-3/graphics/5.png | Bin 0 -> 21343 bytes report/deliverable-3/graphics/6.png | Bin 0 -> 28793 bytes report/deliverable-3/graphics/7.png | Bin 0 -> 30848 bytes report/deliverable-3/graphics/burndown.png | Bin 0 -> 21982 bytes report/deliverable-3/graphics/km-dash.png | Bin 0 -> 97345 bytes report/deliverable-3/graphics/scrum.jpg | Bin 0 -> 1829499 bytes report/deliverable-3/graphics/scrum2.jpg | Bin 0 -> 1746169 bytes report/deliverable-3/graphics/scrum3.jpg | Bin 0 -> 1830134 bytes report/deliverable-3/graphics/scrum4.jpg | Bin 0 -> 164302 bytes report/deliverable-3/graphics/scrum5.jpg | Bin 0 -> 152855 bytes report/deliverable-3/graphics/title-logo.png | Bin 0 -> 220102 bytes report/deliverable-3/main.tex | 38 +++++ report/deliverable-3/preamble.tex | 13 ++ report/deliverable-3/texts/aims.tex | 7 + report/deliverable-3/texts/conclusion.tex | 5 + report/deliverable-3/texts/conversion.tex | 135 ++++++++++++++++ report/deliverable-3/texts/logging.tex | 38 +++++ report/deliverable-3/texts/minutes.tex | 72 +++++++++ report/deliverable-3/texts/process-management.tex | 56 +++++++ report/deliverable-3/texts/scrum.tex | 17 ++ report/deliverable-3/texts/testing.tex | 15 ++ report/deliverable-3/texts/typings.tex | 27 ++++ report/deliverable-3/title.tex | 15 ++ src/FileRouter.ts | 5 +- src/files.ts | 2 +- src/index.ts | 25 +-- 36 files changed, 880 insertions(+), 15 deletions(-) create mode 100644 iris.csv create mode 100644 report/deliverable-3.zip create mode 100644 report/deliverable-3/Makefile create mode 100644 report/deliverable-3/appendix/minutes.tex create mode 100644 report/deliverable-3/appendix/scrumboard.tex create mode 100644 report/deliverable-3/biblio.bib create mode 100644 report/deliverable-3/graphics/1.png create mode 100644 report/deliverable-3/graphics/2.png create mode 100644 report/deliverable-3/graphics/3.png create mode 100644 report/deliverable-3/graphics/4.png create mode 100644 report/deliverable-3/graphics/5.png create mode 100644 report/deliverable-3/graphics/6.png create mode 100644 report/deliverable-3/graphics/7.png create mode 100644 report/deliverable-3/graphics/burndown.png create mode 100644 report/deliverable-3/graphics/km-dash.png create mode 100644 report/deliverable-3/graphics/scrum.jpg create mode 100644 report/deliverable-3/graphics/scrum2.jpg create mode 100644 report/deliverable-3/graphics/scrum3.jpg create mode 100644 report/deliverable-3/graphics/scrum4.jpg create mode 100644 report/deliverable-3/graphics/scrum5.jpg create mode 100644 report/deliverable-3/graphics/title-logo.png create mode 100644 report/deliverable-3/main.tex create mode 100644 report/deliverable-3/preamble.tex create mode 100644 report/deliverable-3/texts/aims.tex create mode 100644 report/deliverable-3/texts/conclusion.tex create mode 100644 report/deliverable-3/texts/conversion.tex create mode 100644 report/deliverable-3/texts/logging.tex create mode 100644 report/deliverable-3/texts/minutes.tex create mode 100644 report/deliverable-3/texts/process-management.tex create mode 100644 report/deliverable-3/texts/scrum.tex create mode 100644 report/deliverable-3/texts/testing.tex create mode 100644 report/deliverable-3/texts/typings.tex create mode 100644 report/deliverable-3/title.tex diff --git a/iris.csv b/iris.csv new file mode 100644 index 0000000..6464198 --- /dev/null +++ b/iris.csv @@ -0,0 +1,151 @@ +sepal_length,sepal_width,petal_length,petal_width,species +5.1,3.5,1.4,0.2,setosa +4.9,3,1.4,0.2,setosa +4.7,3.2,1.3,0.2,setosa +4.6,3.1,1.5,0.2,setosa +5,3.6,1.4,0.2,setosa +5.4,3.9,1.7,0.4,setosa +4.6,3.4,1.4,0.3,setosa +5,3.4,1.5,0.2,setosa +4.4,2.9,1.4,0.2,setosa +4.9,3.1,1.5,0.1,setosa +5.4,3.7,1.5,0.2,setosa +4.8,3.4,1.6,0.2,setosa +4.8,3,1.4,0.1,setosa +4.3,3,1.1,0.1,setosa +5.8,4,1.2,0.2,setosa +5.7,4.4,1.5,0.4,setosa +5.4,3.9,1.3,0.4,setosa +5.1,3.5,1.4,0.3,setosa +5.7,3.8,1.7,0.3,setosa +5.1,3.8,1.5,0.3,setosa +5.4,3.4,1.7,0.2,setosa +5.1,3.7,1.5,0.4,setosa +4.6,3.6,1,0.2,setosa +5.1,3.3,1.7,0.5,setosa +4.8,3.4,1.9,0.2,setosa +5,3,1.6,0.2,setosa +5,3.4,1.6,0.4,setosa +5.2,3.5,1.5,0.2,setosa +5.2,3.4,1.4,0.2,setosa +4.7,3.2,1.6,0.2,setosa +4.8,3.1,1.6,0.2,setosa +5.4,3.4,1.5,0.4,setosa +5.2,4.1,1.5,0.1,setosa +5.5,4.2,1.4,0.2,setosa +4.9,3.1,1.5,0.1,setosa +5,3.2,1.2,0.2,setosa +5.5,3.5,1.3,0.2,setosa +4.9,3.1,1.5,0.1,setosa +4.4,3,1.3,0.2,setosa +5.1,3.4,1.5,0.2,setosa +5,3.5,1.3,0.3,setosa +4.5,2.3,1.3,0.3,setosa +4.4,3.2,1.3,0.2,setosa +5,3.5,1.6,0.6,setosa +5.1,3.8,1.9,0.4,setosa +4.8,3,1.4,0.3,setosa +5.1,3.8,1.6,0.2,setosa +4.6,3.2,1.4,0.2,setosa +5.3,3.7,1.5,0.2,setosa +5,3.3,1.4,0.2,setosa +7,3.2,4.7,1.4,versicolor +6.4,3.2,4.5,1.5,versicolor +6.9,3.1,4.9,1.5,versicolor +5.5,2.3,4,1.3,versicolor +6.5,2.8,4.6,1.5,versicolor +5.7,2.8,4.5,1.3,versicolor +6.3,3.3,4.7,1.6,versicolor +4.9,2.4,3.3,1,versicolor +6.6,2.9,4.6,1.3,versicolor +5.2,2.7,3.9,1.4,versicolor +5,2,3.5,1,versicolor +5.9,3,4.2,1.5,versicolor +6,2.2,4,1,versicolor +6.1,2.9,4.7,1.4,versicolor +5.6,2.9,3.6,1.3,versicolor +6.7,3.1,4.4,1.4,versicolor +5.6,3,4.5,1.5,versicolor +5.8,2.7,4.1,1,versicolor +6.2,2.2,4.5,1.5,versicolor +5.6,2.5,3.9,1.1,versicolor +5.9,3.2,4.8,1.8,versicolor +6.1,2.8,4,1.3,versicolor +6.3,2.5,4.9,1.5,versicolor +6.1,2.8,4.7,1.2,versicolor +6.4,2.9,4.3,1.3,versicolor +6.6,3,4.4,1.4,versicolor +6.8,2.8,4.8,1.4,versicolor +6.7,3,5,1.7,versicolor +6,2.9,4.5,1.5,versicolor +5.7,2.6,3.5,1,versicolor +5.5,2.4,3.8,1.1,versicolor +5.5,2.4,3.7,1,versicolor +5.8,2.7,3.9,1.2,versicolor +6,2.7,5.1,1.6,versicolor +5.4,3,4.5,1.5,versicolor +6,3.4,4.5,1.6,versicolor +6.7,3.1,4.7,1.5,versicolor +6.3,2.3,4.4,1.3,versicolor +5.6,3,4.1,1.3,versicolor +5.5,2.5,4,1.3,versicolor +5.5,2.6,4.4,1.2,versicolor +6.1,3,4.6,1.4,versicolor +5.8,2.6,4,1.2,versicolor +5,2.3,3.3,1,versicolor +5.6,2.7,4.2,1.3,versicolor +5.7,3,4.2,1.2,versicolor +5.7,2.9,4.2,1.3,versicolor +6.2,2.9,4.3,1.3,versicolor +5.1,2.5,3,1.1,versicolor +5.7,2.8,4.1,1.3,versicolor +6.3,3.3,6,2.5,virginica +5.8,2.7,5.1,1.9,virginica +7.1,3,5.9,2.1,virginica +6.3,2.9,5.6,1.8,virginica +6.5,3,5.8,2.2,virginica +7.6,3,6.6,2.1,virginica +4.9,2.5,4.5,1.7,virginica +7.3,2.9,6.3,1.8,virginica +6.7,2.5,5.8,1.8,virginica +7.2,3.6,6.1,2.5,virginica +6.5,3.2,5.1,2,virginica +6.4,2.7,5.3,1.9,virginica +6.8,3,5.5,2.1,virginica +5.7,2.5,5,2,virginica +5.8,2.8,5.1,2.4,virginica +6.4,3.2,5.3,2.3,virginica +6.5,3,5.5,1.8,virginica +7.7,3.8,6.7,2.2,virginica +7.7,2.6,6.9,2.3,virginica +6,2.2,5,1.5,virginica +6.9,3.2,5.7,2.3,virginica +5.6,2.8,4.9,2,virginica +7.7,2.8,6.7,2,virginica +6.3,2.7,4.9,1.8,virginica +6.7,3.3,5.7,2.1,virginica +7.2,3.2,6,1.8,virginica +6.2,2.8,4.8,1.8,virginica +6.1,3,4.9,1.8,virginica +6.4,2.8,5.6,2.1,virginica +7.2,3,5.8,1.6,virginica +7.4,2.8,6.1,1.9,virginica +7.9,3.8,6.4,2,virginica +6.4,2.8,5.6,2.2,virginica +6.3,2.8,5.1,1.5,virginica +6.1,2.6,5.6,1.4,virginica +7.7,3,6.1,2.3,virginica +6.3,3.4,5.6,2.4,virginica +6.4,3.1,5.5,1.8,virginica +6,3,4.8,1.8,virginica +6.9,3.1,5.4,2.1,virginica +6.7,3.1,5.6,2.4,virginica +6.9,3.1,5.1,2.3,virginica +5.8,2.7,5.1,1.9,virginica +6.8,3.2,5.9,2.3,virginica +6.7,3.3,5.7,2.5,virginica +6.7,3,5.2,2.3,virginica +6.3,2.5,5,1.9,virginica +6.5,3,5.2,2,virginica +6.2,3.4,5.4,2.3,virginica +5.9,3,5.1,1.8,virginica diff --git a/report/deliverable-3.zip b/report/deliverable-3.zip new file mode 100644 index 0000000..9271bc1 Binary files /dev/null and b/report/deliverable-3.zip differ diff --git a/report/deliverable-3/Makefile b/report/deliverable-3/Makefile new file mode 100644 index 0000000..135009b --- /dev/null +++ b/report/deliverable-3/Makefile @@ -0,0 +1,9 @@ +.PHONY: default clean FORCE + +default : main.pdf + +%.pdf : %.tex FORCE + latexmk -pdf $< + +clean : + latexmk -C diff --git a/report/deliverable-3/appendix/minutes.tex b/report/deliverable-3/appendix/minutes.tex new file mode 100644 index 0000000..44aa702 --- /dev/null +++ b/report/deliverable-3/appendix/minutes.tex @@ -0,0 +1,68 @@ +\section{Meeting Minutes}\label{app:meet} +\begin{lstlisting} + +Group Project Meeting 1 post submission +Date: 12/02/18 +Topics: +Reassigning scrum roles +Creating next set of tasks +Task allocation + +Outcomes: +* Scrum: + * scrum master - Hafeez + * project owner - Calum + +*Tasks: + * Implementing endpoints + * Implementing file conversions + * Improving test coverage + * Writing tests for untested sections + * Connecting all middleware + * Decide on how to deal with errors + * Organising file-system + * Creating a Linter to maintain a consistent file structure + +Group Project Meeting 2 Pre-sprint +Date 19/02/18 +Topics: +Define user stories +Task allocation + +Outcomes: +* Sprint + * 2 Week long sprint + * Mid sprint meeting set for 26/02/18 +* Images + * Dealing with leica and zeiss files +* Testing + * Implementing unit and integration tests +* Logger + * Standard and SQL logger + + +Group Project Meeting 3 mid-Sprint +Date 26/02/18 +Topics: +updating progress + +Outcomes: +* Images + * Continued work on image files + * File extraction and testing + * Stitching +* Logger + * Needed a better one to log problems + +Group Project Meeting 4 post-sprint +Date 05/03/18 +Topics +Final tasks required before deadline + +Outcomes: + * Finishing off of the report + * Finish testing + * Process manager + * Hosting on heroku + +\end{lstlisting} diff --git a/report/deliverable-3/appendix/scrumboard.tex b/report/deliverable-3/appendix/scrumboard.tex new file mode 100644 index 0000000..e868278 --- /dev/null +++ b/report/deliverable-3/appendix/scrumboard.tex @@ -0,0 +1,8 @@ +\section{Scrum Board Images} \label{app:board} + +{ +\centering +\includegraphics[width=\textwidth]{graphics/scrum.jpg} +\includegraphics[width=\textwidth]{graphics/scrum3.jpg} +\includegraphics[width=\textwidth]{graphics/scrum4.jpg} +} diff --git a/report/deliverable-3/biblio.bib b/report/deliverable-3/biblio.bib new file mode 100644 index 0000000..fdfc56b --- /dev/null +++ b/report/deliverable-3/biblio.bib @@ -0,0 +1,189 @@ +@misc {tslint, + howpublished = {https://palantir.github.io/tslint/}, + title = {TSLint}, + publisher = {Palantir Technologies}, + year = {2016}, + note = {Accessed: 2018-03-01} +} + +@misc {protocol, + howpublished = {https://github.com/CS3099JH2017/cs3099jh/tree/master/protocols}, + title = {CS3099JH2017 Protocol}, + publisher = {CS3099 Year Group of 2017/18}, + year = {2018}, + note = {Accessed: 2018-03-02} +} + +@misc {yarn, + howpublished = {https://yarnpkg.com/en/docs}, + title = {Yarn}, + publisher = {Yarn Organization}, + note = {Accessed: 2018-03-02} +} + +@misc {typescript, + howpublished = {https://www.typescriptlang.org/docs/home.html}, + title = {TypeScript}, + publisher = {Microsoft}, + year = {2017}, + note = {Accessed: 2018-03-02} +} + +@misc {sequelize, + howpublished = {http://docs.sequelizejs.com/}, + title = {Sequelize}, + publisher = {Sequelize}, + note = {Accessed: 2018-03-02} +} + +@misc {sequelize-typescript, + howpublished = {https://github.com/RobinBuschmann/sequelize-typescript}, + title = {sequelize-typescript}, + publisher = {Robin Buschmann}, + note = {Accessed: 2018-03-02} +} + +@misc {postgres, + howpublished = {https://www.postgresql.org/docs/}, + title = {PostreSQL}, + publisher = {The PostgreSQL Global Development Group}, + year = {2018}, + note = {Accessed: 2018-03-02} +} + +@misc {mocha, + howpublished = {https://mochajs.org/}, + title = {Mocha}, + publisher = {mochajs}, + note = {Accessed: 2018-03-02} +} + +@misc {mocha-each, + howpublished = {https://github.com/ryym/mocha-each}, + title = {mocha-each}, + publisher = {ryym}, + note = {Accessed: 2018-03-02} +} + +@misc {chai, + howpublished = {http://chaijs.com/api/bdd/}, + title = {Chai Assertion Library}, + publisher = {chaijs}, + note = {Accessed: 2018-03-02} +} + +@misc {chai-http, + howpublished = {http://chaijs.com/plugins/chai-http/}, + title = {Chai HTTP}, + publisher = {chaijs}, + note = {Accessed: 2018-03-02} +} + +@misc {express, + howpublished = {https://expressjs.com/en/4x/api.html}, + title = {Express 4.x}, + publisher = {expressjs}, + year = {2017}, + note = {Accessed: 2018-03-02} +} + +@misc {passport, + howpublished = {http://www.passportjs.org/docs/}, + title = {Passport}, + publisher = {Jared Hanson}, + note = {Accessed: 2018-03-02} +} + +@misc {passport-local, + howpublished = {https://github.com/jaredhanson/passport-local}, + title = {passport-local}, + publisher = {Jared Hanson}, + note = {Accessed: 2018-03-02} +} + +@misc {morgan, + howpublished = {https://github.com/expressjs/morgan}, + title = {morgan}, + publisher = {expressjs}, + note = {Accessed: 2018-03-02} +} + +@misc {typedoc, + howpublished = {http://typedoc.org/guides/usage/}, + title = {TypeDoc}, + publisher = {TypeStrong}, + note = {Accessed: 2018-03-02} +} + +@misc {xlsx, + howpublished = {https://github.com/sheetjs/js-xlsx}, + title = {js-xlsx}, + publisher = {SheetJS}, + note = {Accessed: 2018-03-02} +} + +@misc {docker, + howpublished = {https://hub.docker.com/}, + title = {Docker Hub}, + publisher = {Docker Inc.}, + year = {2016}, + note = {Accessed: 2018-03-02} +} + +@misc {@types, + howpublished = {http://definitelytyped.org/}, + title = {DefinitelyTyped}, + publisher = {DefinitelyTyped}, + year = {2017}, + note = {Accessed: 2018-03-02} +} + +@misc {strongloop, + howpublished = {https://strongloop.com/}, + title = {StrongLoop}, + publisher = {IBM}, + year = {2018}, + note = {Accessed: 2018-03-07} +} + +@misc {pm2, + howpublished = {http://pm2.keymetrics.io/}, + title = {pm2}, + publisher = {KeyMetrics}, + note = {Accessed: 2018-03-07} +} + +@misc {forever, + howpublished = {https://github.com/foreverjs/forever}, + title = {foreverjs}, + publisher = {foreverjs}, + note = {Accessed: 2018-03-07} +} + +@misc {sharp, + howpublished = {https://github.com/lovell/sharp}, + title = {sharp}, + publisher = {Lovell Fuller}, + note = {Accessed: 2018-03-06} +} + +@misc {sharpPerformance, + howpublished = {http://sharp.pixelplumbing.com/en/stable/performance/}, + title = {Sharp Performance}, + publisher = {Lovell Fuller}, + note = {Accessed: 2018-03-06} +} + +@misc {zeissLicence, + howpublished = {https://www.zeiss.com/microscopy/int/products/microscope-software/czi/czi-download.html}, + title = {Apply for Zeiss Licence}, + publisher = {Carl Zeiss Microscopy GmbH}, + note = {Accessed: 2018-03-06} +} + +@misc {openseadragon, + howpublished = {https://openseadragon.github.io/docs/}, + title = {OpenSeadDragon}, + publisher = {openseadragon}, + note = {Accessed: 2019-03-07} +} diff --git a/report/deliverable-3/graphics/1.png b/report/deliverable-3/graphics/1.png new file mode 100644 index 0000000..089b8ef Binary files /dev/null and b/report/deliverable-3/graphics/1.png differ diff --git a/report/deliverable-3/graphics/2.png b/report/deliverable-3/graphics/2.png new file mode 100644 index 0000000..1714110 Binary files /dev/null and b/report/deliverable-3/graphics/2.png differ diff --git a/report/deliverable-3/graphics/3.png b/report/deliverable-3/graphics/3.png new file mode 100644 index 0000000..7eef8dc Binary files /dev/null and b/report/deliverable-3/graphics/3.png differ diff --git a/report/deliverable-3/graphics/4.png b/report/deliverable-3/graphics/4.png new file mode 100644 index 0000000..8379ef7 Binary files /dev/null and b/report/deliverable-3/graphics/4.png differ diff --git a/report/deliverable-3/graphics/5.png b/report/deliverable-3/graphics/5.png new file mode 100644 index 0000000..aeea913 Binary files /dev/null and b/report/deliverable-3/graphics/5.png differ diff --git a/report/deliverable-3/graphics/6.png b/report/deliverable-3/graphics/6.png new file mode 100644 index 0000000..e3fb624 Binary files /dev/null and b/report/deliverable-3/graphics/6.png differ diff --git a/report/deliverable-3/graphics/7.png b/report/deliverable-3/graphics/7.png new file mode 100644 index 0000000..a917d83 Binary files /dev/null and b/report/deliverable-3/graphics/7.png differ diff --git a/report/deliverable-3/graphics/burndown.png b/report/deliverable-3/graphics/burndown.png new file mode 100644 index 0000000..f3ae71d Binary files /dev/null and b/report/deliverable-3/graphics/burndown.png differ diff --git a/report/deliverable-3/graphics/km-dash.png b/report/deliverable-3/graphics/km-dash.png new file mode 100644 index 0000000..840395d Binary files /dev/null and b/report/deliverable-3/graphics/km-dash.png differ diff --git a/report/deliverable-3/graphics/scrum.jpg b/report/deliverable-3/graphics/scrum.jpg new file mode 100644 index 0000000..4b5c911 Binary files /dev/null and b/report/deliverable-3/graphics/scrum.jpg differ diff --git a/report/deliverable-3/graphics/scrum2.jpg b/report/deliverable-3/graphics/scrum2.jpg new file mode 100644 index 0000000..231cf1f Binary files /dev/null and b/report/deliverable-3/graphics/scrum2.jpg differ diff --git a/report/deliverable-3/graphics/scrum3.jpg b/report/deliverable-3/graphics/scrum3.jpg new file mode 100644 index 0000000..012e9b3 Binary files /dev/null and b/report/deliverable-3/graphics/scrum3.jpg differ diff --git a/report/deliverable-3/graphics/scrum4.jpg b/report/deliverable-3/graphics/scrum4.jpg new file mode 100644 index 0000000..ab1f7a5 Binary files /dev/null and b/report/deliverable-3/graphics/scrum4.jpg differ diff --git a/report/deliverable-3/graphics/scrum5.jpg b/report/deliverable-3/graphics/scrum5.jpg new file mode 100644 index 0000000..e79e828 Binary files /dev/null and b/report/deliverable-3/graphics/scrum5.jpg differ diff --git a/report/deliverable-3/graphics/title-logo.png b/report/deliverable-3/graphics/title-logo.png new file mode 100644 index 0000000..8a72423 Binary files /dev/null and b/report/deliverable-3/graphics/title-logo.png differ diff --git a/report/deliverable-3/main.tex b/report/deliverable-3/main.tex new file mode 100644 index 0000000..dce9106 --- /dev/null +++ b/report/deliverable-3/main.tex @@ -0,0 +1,38 @@ +\input{preamble} + +\input{title} + +\begin{document} + + \maketitle + \thispagestyle{empty} + \newpage + \setcounter{page}{1} + + \tableofcontents + \newpage + + \input{texts/aims} + \input{texts/scrum} + \input{texts/conversion} + % \input{texts/protocol} + % \input{texts/auth} + \input{texts/logging} + \input{texts/process-management} + \input{texts/testing} + \input{texts/typings} + \input{texts/conclusion} + + \appendix + \newpage + \input{appendix/scrumboard} + \newpage + \input{appendix/minutes} + + \clearpage + + \nocite{*} + \bibliography{biblio}{} + \bibliographystyle{plain} + +\end{document} diff --git a/report/deliverable-3/preamble.tex b/report/deliverable-3/preamble.tex new file mode 100644 index 0000000..14787a9 --- /dev/null +++ b/report/deliverable-3/preamble.tex @@ -0,0 +1,13 @@ +\documentclass{article} + +\usepackage[margin=1in]{geometry} +\usepackage{a4wide} + +\usepackage{graphicx} +\graphicspath{{./graphics/}} + +\usepackage{float} +\usepackage{listings} +\usepackage{cite} + +\def\file{\texttt} diff --git a/report/deliverable-3/texts/aims.tex b/report/deliverable-3/texts/aims.tex new file mode 100644 index 0000000..e1da3ee --- /dev/null +++ b/report/deliverable-3/texts/aims.tex @@ -0,0 +1,7 @@ +\section{Aims for submission 2} +From our first submission, we now had a working server that allowed a user to access our own mock user interface to log in and access data based on their level of authorisation. Following this we set up a meeting to lay out goals for ourselves that would act as requirements for the second submission. +\begin{description} + \item[Define Specific Protocol] Now that we had a working server, we next wanted to define specific protocol in order to demo our progress using work from another Junior Honours HCI groups. + \item[Manage Filetype Conversions] A main part of this submission was creating a file converter for all the required file types that would be needed. + \item[Testing] As our code was getting more complicated we wanted to make sure that extensive testing was implemented to create a more secure and consistent system. +\end{description} diff --git a/report/deliverable-3/texts/conclusion.tex b/report/deliverable-3/texts/conclusion.tex new file mode 100644 index 0000000..0e40979 --- /dev/null +++ b/report/deliverable-3/texts/conclusion.tex @@ -0,0 +1,5 @@ +\section{Conclusion} +As a group a lot of progress was made for this submission, we were proactive in setting out goals for ourselves and feel we are now well on track to produce an outstanding final hand in. Our continued use of scrum has helped keep workload consistent and effective right through to this submission and we hope to continue in this way. Scrum is essential in our progress as it helps to manage time and organise the team work and so this process will be used for the duration of the project. Having now combined our work with the HCI group we are looking forward to working with teams focused on machine learning to tie together all 3 sections of the application to create the desired system set out by the project owner. + +\subsection{Next Tasks} +Viewing the system as a whole, substantial progress has been made in completing each required task whilst also managing time for each task appropriately. Looking further ahead, our next objectives will surround performance enhancing, further testing and finally completing the integration process with the rest of the system. The process for these will include a large amount of analysis on the working server, which include finding delays between certain requests and responses, measuring time taken for converting files and testing for bugs after integration. Another important aspect is the security of the application, and preventing bugs from leading to exploits which can be used for malicious use. This is particularly important within the medical industry as data confidentiality and integrity are apart of practitioners' policy. One method of testing for this task would be penetration testing, using a suite of tools to attack the application, which would determine any vulnerabilities that exist. \ No newline at end of file diff --git a/report/deliverable-3/texts/conversion.tex b/report/deliverable-3/texts/conversion.tex new file mode 100644 index 0000000..87db332 --- /dev/null +++ b/report/deliverable-3/texts/conversion.tex @@ -0,0 +1,135 @@ +\section{File Conversion} +One of the most key pieces of functionality for the backend groups is the facilitation of the agnosticity of +original file formats to the end user. No matter the original upload format, backend groups should all be +capable of returning files in standard file formats. +These specific ``standards'' were not hard-defined by the specification, however as part of our whole year +protocol, it was decided that \emph{JSON} would be used for file meta-information, as well as the +main structure of all responses from a backend server. \emph{PNG} was decided upon as the standard file format +for all images, since it is very widely supported and has other favourable properties we would like to +take advantage of. + +\subsection{Dealing with Images} +The nature of the file formats that we were expected to abstract over however turned out to be significantly +more challenging than was initially perceived. The file formats of `Leica' and `Zeiss' are widely used in the +medical field (the department we are providing this service for), however almost nowhere else. Upon looking +into this more closely, it was found that the Zeiss file format is very proprietary and licensed. + +This means that in order to even gain access to simply read the documentation you must fill in your details +and make an application for the documentation~\cite{zeissLicence}. Part of the agreement for this documentation is that you are +not allowed to share it with anyone else; you are allowed to write software to \emph{deconstruct} them; you +are strictly \emph{not} allowed to write any software to construct them. + +The documentation gives a description of the various ``segments'' of binary that can appear in the file, and +attempts to assist you in the method to read them. Given the large nature of the file size of a Zeiss, it makes +sense for them to be designed to be `streamable', which they are --- allowing you to read smaller chunks at a +time rather than loading the whole object into memory simultaneously. + +After reading the specification in great detail, it was clear that it was extremely specialised and has +the potential to nest a variety of other file types within itself, as well as have many fields missing +--- as they are optional --- making it quite complex to interpret. In addition to this, the major difficulty +came from the fact that the base file is a proprietary binary file, which also contains things such as 128bit +unsigned integers. This fact, coupled with the substantial file sizes made the choice for languages to deal +with them limited to a systems programming language. Since I had most experience in `C99', then this seemed +the only realistic possibility. + +\subsubsection{Extraction of Zeiss Within `C'} +One major consideration was that --- due to the sheer file size of many of these images --- we would need +to store them on the local \file{/cs/scratch} drive of the lab machines: they are simply too +large to store either on our host servers statically, let alone when working on extracting and expanding the +thousands of smaller files within them. + +With this in mind, and closely comparing the +`C' code against the rough documentation licensed to me, the structures possible within a Zeiss file were +slowly built up. + +Methods were written to print out the contents of various structures as progress was made, in +order to ensure that the offsets for file streaming were continually at the correct locations and the data we +were parsing out of the file was as expected. To this effect, testing of the extraction was run continually +in the standard `C' approach of a couple lines at a time before re-compilation, along with using flags such as +`\verb|--pedantic|' in order to try to catch as many errors as possible. Occasionally \verb|valgrind| was also +run on this extraction code, since significant chunks of memory are allocated and freed during the +extraction process. \verb|valgrind| reports that there are no memory leaks at all --- even +on the larger 12Gb \file{.czi} files. + +\subsubsection{Converting Extracted Files} +Once the files/metadata/attachments had been successfully extracted from the target file, multiple issues were +discovered. +\begin{itemize} + \item The container format for the image segments was in \emph{JPEG-XR}. This is another proprietary + file format, which does not appear to be supported by anything at all, other than Microsoft's own software. + There is also extremely limited library support, especially for non-Windows platforms. + Fortunately, a C++-written \file{.jxr} decoder was found, and could + be compiled on the destination machine. Enough of the executable is able to be compiled before any problems + occur, and this decoder can be copied into the relative path for our own C source. + \item The library for decoding JXR's is only + capable of conversion to \emph{BMP} or \emph{TIFF}, which is not our desired format. Therefore an additional step of + converting the `JXR' to `TIFF', and then to `PNG' using the `imagemagick' command line tools like \verb|convert| + became necessary. + This is an annoying overhead, which is unfortunately unavoidable. + \item By simply extracting every image tile found within the JXR tile, we found that + there were also tiles found at non 1:1 zoom levels, which was wasteful to deal with, since we will be building + a custom image pyramid anyway. This issue was mitigated by adding some logic to only extract the tile to disk if + it was determined to have a 1:1 scaling and thus be on the base layer. + \item In a similar fashion to the previous issue, it also became apparent that there were many tiles in the + base layer which were of non-standard sizes, with some having tiny slivers as they came to edges etc. + The only solution to make these tiles appear on a nice grid of $n^2$ sizes, was to iterate over the fragmented + canvas and stitch together the portions we want. +\end{itemize} + +In order to complete the conversion side of things, it seemed appropriate to move away from C programming, and +even away from the scripts that were being using to control the C, to something like \emph{Python}. +The thought process behind this decision is the fact that Python supports multithreading --- which for something +as parallel as multiple image conversions seemed extremely advantageous. The code to do this section is fairly +small, but absolutely crucial to the overall pipeline of Zeiss format support. + +\subsubsection{Stitching Base Tiles} +Once we finally had all of the base tiles in a 1:1 scale and a format that was easier to deal with, the first task +was to figure out how to build up our own grid across the mismatch of sizes of existing base tiles.\\ +The tile dimensions decided on were 1024:1024. The reason for this, is that it is large enough to contain a +reasonable amount of information, without being so large that our server could provide or clients could load in +a timely manner. + +In order to do this stitching process, a decision was required as to the package to manage the image operations. +After a vast amount of searching and comparisons, the selection was made for \emph{Sharp}~\cite{sharp}. The reason for +this, was that it appeared to be the single library which was capable of all of the different kinds of image +processing jobs we expected to be doing. Another key reason is the fact that it is known in advance that a very +large number of images will need to be processed here, so performance is critical. Sharp appears to perform +very significantly better than its competitors~\cite{sharpPerformance}. Finally, it has typing +support to work with our environment. + +With this set, high level logic was written to check various image bounds for related base tiles to a specific +region request. Regions were then selected out, sorted by x and y offsets, then relevant chunks chopped out of +them and stitched together into a coherent region of our selected size. + +\subsubsection{Building Up Hierarchy of Zoom Levels} +These finalised base layer tiles are written to disk in an output directory and details about their creation +are recorded in a new data structure which will map out the pyramid style hierarchy of the tiles. +A small example of these final titles are shown on the cover page of our Report for interest as they are +legitimate generations in a format we would like. + +Now that the base layer exists, gaining the rest of the tile zoom levels, should be fairly simple --- by moving +up to the next power of two (2048) and collecting 4 images together then scaling this back down to 1024 pixels. +This process can be repeated for each level of zoom we would like to raise to. This will massively speed up +the process of searching through base tiles and stitching many together if we pre-process all of the intermediate +layers. Since most HCI groups are using OpenSeaDragon (which requests things in scales of powers +of two~\cite{openseadragon}), our approach should be a very fast performer with the trade off of larger up-front processing time.\\ +Indexing into this pyramid will be fast with each request too, as they will be separated by `C' value, which is +one of the image's layering options, then by zoom level. + +\subsection{Leica \& Other Formats} +As Zeiss is such a difficult and mammoth file format almost all of my time was spent dealing with purely this, +and it is still not even complete yet. However having looked quickly into Leica, there appears to be +library support, which may make life easier, along with the fact the internal structure appears to be similar to +a BigTiff. More progress on this format will take place for the next deliverable. + +As for other image formats such as JPEG, TIFF etc. These are standard formats and so will be trivial to +convert to our required standard of PNG so is not a significant point of progress currently. + +\subsection{Non image formats (\file{.csv} etc.)} +As for non image formats such as \file{.csv}, it has been decided that the backend should only be responsible of hosting these +files, since there is no way that a backend server could possibly predict what the file should be processed into. +Additionally, there are also many cases where an end-user may wish to deliberately store something in a format +which a backend server checking legitimacy of the file would complain about incorrectly. + +The team hasn't really looked into things such as Excel (\file{.xlsx}) files, however again, pre-emptively looking, there seems to +be fairly wide library support for things like this, so it was not a major concern for this deliverable. diff --git a/report/deliverable-3/texts/logging.tex b/report/deliverable-3/texts/logging.tex new file mode 100644 index 0000000..d0a7255 --- /dev/null +++ b/report/deliverable-3/texts/logging.tex @@ -0,0 +1,38 @@ +\section{Logging} +Server logging has now been formalised: the functionality is imported into +a file and can then be used to log messages at the selection of urgencies +specified in Protocol BE01~\cite{protocol}. + +These outputs have many configuration options, which ideally will be +incorporated into a global configuration handler in future development. + +\subsection{Standard Logging} +By default, the standard logger logs to three places: +\begin{enumerate} + \item Colourised, human-readable messages are printed to the console. + Any error- or critical-level messages are printed through stderr. + \item More verbose JSON editions of messages are written to a basic + logfile. + \item Critical-level messages are additionally written to an extra + logfile. +\end{enumerate} + +\subsection{SQL Query Logging} +A separate logger has been designed for logging the output of +Sequelize~\cite{sequelize}. Since Protocol BE01 does not specify that they +should be retreivable, the output queries can be stored with less associated +metadata. In addition, Sequelize can output the total required time to +process the query, which is stored in the log for future use as profiling +data. + +\subsection{Motivation} +Since basic server functionality has been implemented, the errors produced +will likely be caused by difficult-to-debug problems, such as edge-cases or +data races. With a verbose and thorough logging system, these problems +should be much easier to detect and rectify. + +In addition, Protocol BE01~\cite{protocol} requires of the backend support +for receiving and storing logs from other services. The introduction of a +well-implemented logging system abstracts this from the common use-case of +logging while keeping powerful functionality of forwarding and fetching logs +available for when it is needed. diff --git a/report/deliverable-3/texts/minutes.tex b/report/deliverable-3/texts/minutes.tex new file mode 100644 index 0000000..55aab2a --- /dev/null +++ b/report/deliverable-3/texts/minutes.tex @@ -0,0 +1,72 @@ +\begin{lstlisting} + +Group Project Meeting 1 post submission +Date: 12/02/18 +Topics: +Reassigning scrum roles +Creating next set of tasks +Task allocation + +Outcomes: +* Scrum: + * scrum master - Hafeez + * project owner - Calum + +*Tasks: + * Implementing endpoints + * Implementing file conversions + * Improving test coverage + * Writing tests for untested sections + * Connecting all middleware + * Decide on how to deal with errors + * Organising file-system + * Creating a Linter to maintain a consistent file structure + +Group Project Meeting 2 Pre-sprint +Date 15/02/18 +Topics: +Define user stories +Task allocation + +Outcomes: +* Sprint + * Week long sprint + * Meeting set for 22/02/18 + +Group Project Meeting 3 Post-Sprint +Date 22/02/18 +Topics: +Analysis of work +Next task assignment + +Outcomes: + +Group Project Meeting 4 +Date 24/02/18 +Topics: +Sprint aims +Sprint deadline + +Outcomes: + *Decided to hold a sprint now to leave time + before next submission to finish off all leftover work + +Group Project Meeting 5 +Date 03/03/18 +Topics +Analysis of work todo after sprint +Work needed to complete before deadline + + +Outcomes: + * Finishing off of the report + *Connecting work with another HCI group + *Finish testing + + + + + + + +\end{lstlisting} diff --git a/report/deliverable-3/texts/process-management.tex b/report/deliverable-3/texts/process-management.tex new file mode 100644 index 0000000..d99a73c --- /dev/null +++ b/report/deliverable-3/texts/process-management.tex @@ -0,0 +1,56 @@ +\section{Process Management and Deployment}\label{sec:pm} +In a production environment, many instances of a NodeJS server are run on +one machine; this way NodeJS applications can make use of multiple +processors. For this purpose, research into \emph{process managers} --- +applications used for running and managing production-level systems --- +was carried out. + +\subsection{Process Manager Selection}\label{sec:pms} +A number of process managers were investigated with the hope of +incorporating them into the production +system~\cite{strongloop}\cite{pm2}\cite{forever}. The application pm2 was +chosen, primarily for its highly-configurable \emph{ecosystem}-config files, +and \emph{pmx}\footnote{https://github.com/keymetrics/pmx}, +its profiling extension. + +\subsection{pm2 and KeyMetrics}\label{sec:pm2} + +\begin{figure} + \centering + \includegraphics[width=0.95\linewidth]{km-dash} + \caption{The KeyMetrics dashboard web client in use.}\label{fig:dash} +\end{figure} + +A feature available in \emph{pm2} is the ability to transmit profiling +statistics to a web client, as a dashboard. The dashboard also allows the +user to remotely issue commands to the running instances. Further, +custom profiling information, and custom remote commands, can be created +through the introduction of simple logic into the codebase. + +\subsection{Process Limitations}\label{sec:plim} +Running multiple NodeJS instances can quickly accumulate counts towards a +user process limit: each instance hosts several threads, and each connection +to the PostgreSQL database can pool several threads also, resulting in many +threads per instance. Compounded with the fact that pm2 itself also runs +as a NodeJS instance, this means that a user can reach their process limit +on the host labs very quickly. Using \texttt{nolimit} on process +instantiation is one solution, however this means having to run +\texttt{nolimit} when starting the databse, deamonising the process manager, +starting the server instances, and doing any miscellaneous tasks. This +limitation has stunted hindered attempts to connect to other teams' +products. + +\subsection{Heroku Hosting}\label{sec:her} +In response to the issues addressed in \S\ref{sec:plim}, an attempt to host +an instance of the server on hosting service +\emph{Heroku}\footnote{https://heroku.com/} has been started. This would +alloow the team to interact with other teams, without using a member's +process limit and hindering their productivity. Additionally, it would show +the deployability of the system --- an important factor for a backend +server. + +\subsection{External System Hosting}\label{sec:ext} +Another option is to host instances of the system on devices personally +owned by members of the team. This would give the team absolute control over +configuration of the sytem, and would have the potential to outperform an +instance running on a complementary Heroku service. diff --git a/report/deliverable-3/texts/scrum.tex b/report/deliverable-3/texts/scrum.tex new file mode 100644 index 0000000..ca724c8 --- /dev/null +++ b/report/deliverable-3/texts/scrum.tex @@ -0,0 +1,17 @@ +\section{Continued use of Scrum} +The scrum process was continued as we found this very useful in terms of clearly setting out tasks for each member and managing the progress of the implementation. One of the changes that was made for this sprint was the change in roles between team members. The change in responsibility allows team members to complete new and different jobs. In general the size and the time taken of each individual task was a lot more varied when comparing to the last submission, however, there were certain tasks which were larger in terms of hours put in. These large tasks included creating a logger system and a file converter. +\subsection{Sprints} + +\begin{figure}[h] + \centering + \includegraphics[width=0.6\textwidth]{burndown} + \caption{A Burndown Chart for the past 14 days.}\label{fig:burn} +\end{figure} + +As a team, it was decided that there would only be a single sprint, up until the next point of submission. This was because of the short time period, enough for only a two week sprint. In addition to this, the sprint assessment process was completed more often to ensure that as a team time was managed well and sufficient progress was being made. All the tasks that was set for this sprint were completed within the required time frame. +\subsection{Scrum board} +Again, the scrum board was used to outline and track the completion of each task. The same whiteboard in the John Honey main computer lab was used in order to maintain consistency. This gave a clear visual representation of the objectives. During the sprint, the main jobs required for completion were to further enhance the testing unit to increase its coverage across the implemented systems, implement a simple file converter and introduce a logging system for the server. Much experience was gained from completing previous sprints and so using this experience we were better equipped to handle larger tasks. Examples of the board in use can be found in Appendix \ref{app:board}. + +\subsection{Meetings} +Regular meetings were also held to discuss and evaluate progress. This was crucial in the scrum process and as working in a team to allow a point of communication between each member at the same point in time. An example of a major decision being made during the discussion was the change of language of the file converter implementation. It was decided that the more appropriate language to use would be C as there would more extensive libraries for this particular operation and would also have the advantage of greater efficiency. Multiple meetings were held during the most recent sprint to determine the tasks required for completion, to evaluate whether each task was completed and track progress in between. +The minutes for formal meetings are available in Appendix \ref{app:meet}. diff --git a/report/deliverable-3/texts/testing.tex b/report/deliverable-3/texts/testing.tex new file mode 100644 index 0000000..e3f709b --- /dev/null +++ b/report/deliverable-3/texts/testing.tex @@ -0,0 +1,15 @@ +\section{Testing} +Tests do not currently run on the gitlab server, as the postgres integration with the docker gitlab-ci is still missing. This means any tests run automatically when pushing will fail. \par +When running integration tests locally, please make sure the postgres server is up and running on localhost. +\subsection{Structure} +Testing files were restructured for a more organised and professional approach. All test files end in ``*.\(<\)context\(>\).test.ts'' and were moved to the ``test'' directory. At this moment, ``\(<\)context\(>\)'' includes ``unit'' and ``routes''. Further, they were categorised into \textit{integration} and \textit{unit} tests and moved into corresponding sub-directories. \par +Apart from making test files easier to find, this new structure also allowed us to run specific tests independently to isolate failures and quickly rerun individual tests. For example \texttt{yarn test:routes:auth} runs all authentication tests. +\subsection{Integration Testing} +\texttt{yarn test:routes} +This category of tests targeted the interplay of different server components as it tested server endpoints (routes) rather than internal functions. We aimed to test all routes for responses of success, and various degrees of failure. \par +E.g. \textbf{``auth.routes.test.ts''} tested the authentication middle-ware, checking existing users could log in only with correct usernames, passwords and reauthentication tokens. During our later meetings, we realised that security is a key-component of medical systems, and requires further much more in-depth testing to guarantee safety of patient data. \par +\textbf{``protocol.routes.test.ts''} aims to cover all endpoints specified in the agreed protocol by using the \textit{mocha-each} npm module. This allowed us to write few mocha testing functions iterating over the long list of endpoints, checking HTTP responses to fit the JSON response templates to conform to the protocol. This form of testing is still incomplete. +\subsection{Unit Testing} +\texttt{yarn test:unit} +The main motivation for this category of tests was to find bugs early on without having to run the whole server. This saves time and uncovers new code breaking old functionality. We also found that unit tests improved the design process by forcing implementation of code that is testable. Furthermore, unit tests were often used as a form of documentation, as it aided in understanding how code of other team members worked and could be used. \par +We decided that each team-member was responsible for creating the unit tests for their code. Unfortunately the number and coverage of unit tests is still quite low. This may be the result of prioritising functionality over bug-resilience and test-driven development. diff --git a/report/deliverable-3/texts/typings.tex b/report/deliverable-3/texts/typings.tex new file mode 100644 index 0000000..36297b7 --- /dev/null +++ b/report/deliverable-3/texts/typings.tex @@ -0,0 +1,27 @@ +\section{Type Enforcement} +In order to run JavaScript code as TypeScript code, typings (usually +supplied in a \file{.d.ts}-extended file) are applied at compile-time to +make sense of the original source's variable types. For a couple of +packages that have been used in the submission, these typings are not +available, due to a lack of desirablilty --- the packages in question are +niche and as such see little use. + +\subsection{mocha-each} +One such package is \emph{mocha-each}, a utility package for compacting +Mocha tests for readability and classification~\cite{mocha-each}. Without +typings, this package cannot be used in TypeScript projects. Due to its +single-facet use, however, it was simple to design a custom +\file{.d.ts} file. With small edits to conform to +guidelines~\cite{@types}, typings for +mocha-test were contributed to the DefinitelyTyped types repository\footnote{% +https://github.com/DefinitelyTyped/DefinitelyTyped/% +tree/master/types/mocha-each}. + +\subsection{pmx} +The package pmx (as previously described in \S\ref{sec:pms}) is useful for +profiling. Similarly to mocha-each, however, it does not have supported typing. +Since this package covers a far wider range of functionality, and since said +functionality is very involved with sensitive run-time engine manipulation, +typings were written only for the functions being used by the team, and have +been kept in-house for their incompleteness. The files in question can be found +in \file{src/profiler}. diff --git a/report/deliverable-3/title.tex b/report/deliverable-3/title.tex new file mode 100644 index 0000000..4406ef6 --- /dev/null +++ b/report/deliverable-3/title.tex @@ -0,0 +1,15 @@ +\title{Report \\ Juniour Honours Project \\[0.5ex] Submission 2} +\author{Hafeez Abdul-Rehaman \\[1ex] Johannes Weck \\[1ex] Josh Lee \\[1ex] Calum Duff \\[2ex] Tom Harley} +\date{\today} + +\makeatletter + \def\@maketitle{ + \begin{center} + \includegraphics[width=0.7\linewidth]{title-logo}\\[10ex] + {\huge \bfseries \@title{ }}\\[1ex] + \rule{0.5\textwidth}{.4pt}\\[1ex] + {\LARGE \@author}\\[15ex] + {\large \@date} + \end{center} + } +\makeatother diff --git a/src/FileRouter.ts b/src/FileRouter.ts index 70d3d51..0798ce8 100644 --- a/src/FileRouter.ts +++ b/src/FileRouter.ts @@ -548,7 +548,7 @@ const getFile: Middleware = async( const view: View = views[req.query.view || 'meta']; // TODO return 400 for unsuported views // TODO raw view accepts extra query params offset and length - res.locals.function = view.getResponseFunction(req, res); + res.locals.function = view.getResponseFunction(req, res); res.locals.data = view.getResponseData(file, project, req.query); next(); }; @@ -832,9 +832,6 @@ export class FileRouter { // Vars arleady assigned: // - res.locals.project: requested project object - //console.log(`req.file.filename: ${req.file}`) - console.log(req.file) - // Replace + with / res.locals.path = filename.replace(/\+/g, '/'); logger.debug(`Searching for path \'${res.locals.path}\'`); diff --git a/src/files.ts b/src/files.ts index 1b8a652..5b15a10 100644 --- a/src/files.ts +++ b/src/files.ts @@ -169,7 +169,7 @@ export const views: { getResponseData: async( file: File, project: Project, query: Query ): Promise => { - return readableStream(file.name, project.name, query); + return readableStream(file.uuid, project.name, query); }, getResponseFunction: (req: Request, res: Response): Function | null => { return res.send; diff --git a/src/index.ts b/src/index.ts index 5960374..1ce284d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,16 +22,7 @@ const port: number = process.env.PORT : DEFAULT_PORT; logger.info(`Port ${port} chosen`); -// tslint:disable:no-floating-promises -(async(): Promise => { - try { - logger.info('Authenticating with database'); - await seq.authenticate(); - } catch (err) { - logger.error(`Cannot authenticate with database: ${err}`); - process.exit(1); - } - +async function reset(): Promise { try { logger.info('Resetting Database'); await seq.sync({ @@ -91,6 +82,20 @@ logger.info(`Port ${port} chosen`); } }); +} + +// tslint:disable:no-floating-promises +(async(): Promise => { + try { + logger.info('Authenticating with database'); + await seq.authenticate(); + } catch (err) { + logger.error(`Cannot authenticate with database: ${err}`); + process.exit(1); + } + + //await reset(); + logger.info('Booting ExpressJS server'); app.listen(port, (err: Error) => { if (err) { -- cgit v1.2.1 From 2c7cebcd140cc5413118d8246aa9f51b756c512d Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Thu, 19 Apr 2018 15:24:55 +0100 Subject: Change minimum recording level for logs --- src/logger.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/logger.ts b/src/logger.ts index 9025814..74ae1f7 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -138,7 +138,7 @@ const consoleTransport: winston.TransportInstance = const basicFileTransport: winston.TransportInstance = new winston.transports.File({ name: 'basicFileTransport', - level: 'info', + level: 'debug', label: 'Basic File Transport', silent: false, colorize: false, @@ -193,7 +193,7 @@ const criticalFileTransport: winston.TransportInstance = const queryFileTransport: winston.TransportInstance = new winston.transports.File({ name: 'queryFileTransport', - level: 'info', + level: 'debug', label: 'Query Logs', silent: false, colorize: false, @@ -271,7 +271,7 @@ interface LogItem { timestamp: string; } -/* tslint:disable */ +/* tslint:disable */ const fetchLogs2: (level?: LogLevel, params?: FetchParams) => Promise = (level?: LogLevel, params: FetchParams = {}): Promise => { const options: winston.QueryOptions = { from: params.after, -- cgit v1.2.1 From ec1162de99e1744b52fcce0c5341649a7e9a2955 Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Thu, 19 Apr 2018 16:19:46 +0100 Subject: Add CORS support --- src/app.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/app.ts b/src/app.ts index 4dfeeda..09b9e6a 100644 --- a/src/app.ts +++ b/src/app.ts @@ -43,6 +43,7 @@ class App { logger.debug('Constructing router'); this.logEnabled = enableLog; this.express = ex(); + this.cors(); this.express.use( (req: ex.Request, res: ex.Response, next: ex.NextFunction): void => { logger.info(`Connection from ${req.ip} requesting ${req.url}`); @@ -68,6 +69,22 @@ class App { this.errorware(); } + /** + * Enables Cross-Origin for the server. + */ + public cors(): void { + this.express.use(( + req: ex.Request, res: ex.Response, next: ex.NextFunction + ): void => { + res.header('Access-Control-Allow-Origin', '*'); + res.header( + 'Access-Control-Allow-Headers', + 'Origin, X-Requested-With, Content-Type, Accept' + ); + next(); + }); + } + /** * Configures regular Express middleware. */ @@ -114,8 +131,8 @@ class App { this.express.use('/cs3099group-be-4', FileRouter); this.express.use('/cs3099group-be-4', authRouter); this.express.use('/', defRouter); - this.express.use((req: ex.Request, res: ex.Response, - next: ex.NextFunction): void => { + this.express.use( + (req: ex.Request, res: ex.Response, next: ex.NextFunction): void => { if (Object.keys(res.locals).length === 0) { res.status(404) .json({ -- cgit v1.2.1 From 1fa968fa485cd7253b77412cdaa66c01a8adc8eb Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Thu, 19 Apr 2018 17:18:57 +0100 Subject: Add further CORS support --- src/app.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app.ts b/src/app.ts index 09b9e6a..d94011a 100644 --- a/src/app.ts +++ b/src/app.ts @@ -81,6 +81,7 @@ class App { 'Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept' ); + res.header('Access-Control-Allow-Methods', '*'); next(); }); } -- cgit v1.2.1 From e28cc777e4956f718e0dc6387b94b53cf6be8417 Mon Sep 17 00:00:00 2001 From: jw255 Date: Thu, 19 Apr 2018 19:47:22 +0100 Subject: fixed test-crash --- package.json | 36 ------- src/files.ts | 10 +- src/logger.ts | 8 +- yarn.lock | 334 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 302 insertions(+), 86 deletions(-) diff --git a/package.json b/package.json index f26bbe9..e5e63cd 100644 --- a/package.json +++ b/package.json @@ -90,41 +90,5 @@ "winston": "^2.4.0", "xlsx": "^0.11.19", "xml-parser": "^1.2.1" - }, - "resolutions": { - "@types/node": "9.6.5", - "@types/lodash": "4.14.107", - "@types/bluebird": "3.5.20", - "debug": "2.6.9", - "depd": "1.1.2", - "http-errors": "1.6.3", - "iconv-lite": "0.4.19", - "ms": "2.0.0", - "setprototypeof": "1.1.0", - "statuses": "1.5.0", - "mime": "1.4.1", - "async": "1.5.2", - "sprintf-js": "1.1.1", - "pg-types": "1.12.0", - "semver": "4.3.2", - "readable-stream": "1.0.31", - "nan": "2.10.0", - "isarray": "0.0.1", - "string_decoder": "0.10.31", - "glob": "7.1.2", - "minimist": "1.2.0", - "pump": "2.0.1", - "superagent": "3.8.2", - "cookiejar": "2.1.1", - "form-data": "2.3.2", - "chalk": "2.4.0", - "diff": "3.5.0", - "ansi-styles": "3.2.1", - "supports-color": "5.4.0", - "has-flag": "3.0.0", - "source-map": "0.5.7", - "commander": "2.13.0", - "type-detect": "1.0.0", - "wordwrap": "0.0.3" } } diff --git a/src/files.ts b/src/files.ts index 5b15a10..e87d8da 100644 --- a/src/files.ts +++ b/src/files.ts @@ -32,12 +32,20 @@ const readableStream: (filename: string, projectName: string, { offset, length } return fs.createReadStream(path(filename, projectName), options); }; -const logPath: (type: string, projectName?: string) => string = ( +export function logPath (type: string, projectName?: string){ + return projectName + ? `${LOG_BASE_DIRECTORY}/projects/${projectName}/${type}` + : `${LOG_BASE_DIRECTORY}/general/${type}`; +} + +/* +export const logPath: (type: string, projectName?: string) => string = ( type: string, projectName?: string): string => { return projectName ? `${LOG_BASE_DIRECTORY}/projects/${projectName}/${type}` : `${LOG_BASE_DIRECTORY}/general/${type}`; }; +*/ let storage = Multer.diskStorage({ destination: function (req, file, cb) { diff --git a/src/logger.ts b/src/logger.ts index 74ae1f7..ba66650 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -3,7 +3,7 @@ import * as colors from 'colors/safe'; import * as winston from 'winston'; -import { files } from './files'; +import { logPath } from './files'; import { QueryOptions } from 'sequelize'; type Colour = (s: string) => string; @@ -143,7 +143,7 @@ const basicFileTransport: winston.TransportInstance = silent: false, colorize: false, timestamp: true, - filename: files.logPath('basic'), + filename: './logs/general/basic',//logPath('basic'), maxSize: 1000000, maxFiles: 100, stream: undefined, @@ -170,7 +170,7 @@ const criticalFileTransport: winston.TransportInstance = silent: false, colorize: false, timestamp: true, - filename: files.logPath('critical'), + filename: './logs/general/critical' ,//logPath('critical'), maxSize: 1000000, maxFiles: 10, stream: undefined, @@ -198,7 +198,7 @@ const queryFileTransport: winston.TransportInstance = silent: false, colorize: false, timestamp: true, - filename: files.logPath('queries'), + filename: './logs/general/queries',//logPath('queries'), maxSize: 1000000, maxFiles: 100, stream: undefined, diff --git a/yarn.lock b/yarn.lock index 1a2cc9f..f4094a6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,10 +2,14 @@ # yarn lockfile v1 -"@types/bluebird@*", "@types/bluebird@3.5.18", "@types/bluebird@3.5.20": +"@types/bluebird@*": version "3.5.20" resolved "https://registry.yarnpkg.com/@types/bluebird/-/bluebird-3.5.20.tgz#f6363172add6f4eabb8cada53ca9af2781e8d6a1" +"@types/bluebird@3.5.18": + version "3.5.18" + resolved "https://registry.yarnpkg.com/@types/bluebird/-/bluebird-3.5.18.tgz#6a60435d4663e290f3709898a4f75014f279c4d6" + "@types/body-parser@*": version "1.16.8" resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.16.8.tgz#687ec34140624a3bec2b1a8ea9268478ae8f3be3" @@ -120,10 +124,14 @@ dependencies: "@types/node" "*" -"@types/lodash@*", "@types/lodash@4.14.107", "@types/lodash@4.14.99": +"@types/lodash@*": version "4.14.107" resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.107.tgz#b2d2ae3958bfb8ff828495cbe12214af9e4d035e" +"@types/lodash@4.14.99": + version "4.14.99" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.99.tgz#e6e10c0a4cc16c7409b3181f1e66880d2fb7d4dc" + "@types/marked@0.3.0": version "0.3.0" resolved "https://registry.yarnpkg.com/@types/marked/-/marked-0.3.0.tgz#583c223dd33385a1dda01aaf77b0cd0411c4b524" @@ -162,10 +170,14 @@ dependencies: "@types/express" "*" -"@types/node@*", "@types/node@6.0.41", "@types/node@9.6.5": +"@types/node@*": version "9.6.5" resolved "https://registry.yarnpkg.com/@types/node/-/node-9.6.5.tgz#ee700810fdf49ac1c399fc5980b7559b3e5a381d" +"@types/node@6.0.41": + version "6.0.41" + resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.41.tgz#578cf53aaec65887bcaf16792f8722932e8ff8ea" + "@types/node@^6.0.46": version "6.0.106" resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.106.tgz#391bc3598ab5823563f7155847212152893edcd7" @@ -298,20 +310,24 @@ align-text@^0.1.1, align-text@^0.1.3: longest "^1.0.1" repeat-string "^1.5.2" +amdefine@>=0.0.4: + version "1.0.1" + resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" + ansi-regex@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" -ansi-styles@3.2.1, ansi-styles@^3.2.1: +ansi-styles@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" + +ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" dependencies: color-convert "^1.9.0" -ap@~0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/ap/-/ap-0.2.0.tgz#ae0942600b29912f0d2b14ec60c45e8f330b6110" - append-field@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/append-field/-/append-field-0.1.0.tgz#6ddc58fa083c7bc545d3c5995b2830cc2366d44a" @@ -352,10 +368,14 @@ async-listener@^0.6.0: semver "^5.3.0" shimmer "^1.1.0" -async@1.5.2, async@^1.4.0, async@^1.5.0, async@~1.0.0: +async@^1.4.0, async@^1.5.0, async@^1.5.2: version "1.5.2" resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" +async@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/async/-/async-1.0.0.tgz#f8fc04ca3a13784ade9e1641af98578cfbd647a9" + asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" @@ -486,7 +506,17 @@ chai@^3.5.0: deep-eql "^0.1.3" type-detect "^1.0.0" -chalk@2.4.0, chalk@^1.1.3, chalk@^2.0.0, chalk@^2.3.0: +chalk@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" + dependencies: + ansi-styles "^2.2.1" + escape-string-regexp "^1.0.2" + has-ansi "^2.0.0" + strip-ansi "^3.0.0" + supports-color "^2.0.0" + +chalk@^2.0.0, chalk@^2.3.0: version "2.4.0" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.0.tgz#a060a297a6b57e15b61ca63ce84995daa0fe6e52" dependencies: @@ -556,16 +586,30 @@ colors@1.0.x: version "1.0.3" resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b" -combined-stream@1.0.6: +combined-stream@1.0.6, combined-stream@^1.0.5: version "1.0.6" resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.6.tgz#723e7df6e801ac5613113a7e445a9b69cb632818" dependencies: delayed-stream "~1.0.0" -commander@2.13.0, commander@2.9.0, commander@^2.12.1, commander@^2.14.1, commander@~2.13.0, commander@~2.14.1: +commander@2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" + dependencies: + graceful-readlink ">= 1.0.0" + +commander@^2.12.1, commander@~2.13.0: version "2.13.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c" +commander@^2.14.1: + version "2.15.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f" + +commander@~2.14.1: + version "2.14.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.14.1.tgz#2235123e37af8ca3c65df45b026dbd357b01b9aa" + component-emitter@^1.2.0: version "1.2.1" resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6" @@ -610,7 +654,11 @@ cookie@0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" -cookiejar@2.0.x, cookiejar@2.1.1, cookiejar@^2.1.0: +cookiejar@2.0.x: + version "2.0.6" + resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.0.6.tgz#0abf356ad00d1c5a219d88d44518046dd026acfe" + +cookiejar@^2.0.6, cookiejar@^2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.1.tgz#41ad57b1b555951ec171412a81942b1e8200d34a" @@ -629,12 +677,24 @@ cycle@1.0.x: version "1.0.3" resolved "https://registry.yarnpkg.com/cycle/-/cycle-1.0.3.tgz#21e80b2be8580f98b468f379430662b046c34ad2" -debug@2.6.8, debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.6.3, debug@^2.6.9, debug@^3, debug@^3.1.0: +debug@2.6.8: + version "2.6.8" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" + dependencies: + ms "2.0.0" + +debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.6.3, debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" dependencies: ms "2.0.0" +debug@^3, debug@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + dependencies: + ms "2.0.0" + decamelize@^1.0.0: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -669,7 +729,11 @@ delegates@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" -depd@1.1.2, depd@^1.1.0, depd@~1.1.1, depd@~1.1.2: +depd@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.1.tgz#5783b4e1c459f06fa5ca27f991f3d06e7a310359" + +depd@^1.1.0, depd@~1.1.1, depd@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" @@ -688,7 +752,11 @@ dicer@0.2.5: readable-stream "1.1.x" streamsearch "0.1.2" -diff@3.2.0, diff@3.5.0, diff@^3.1.0, diff@^3.2.0: +diff@3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9" + +diff@^3.1.0, diff@^3.2.0: version "3.5.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" @@ -731,7 +799,7 @@ escape-html@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" -escape-string-regexp@1.0.5, escape-string-regexp@^1.0.5: +escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" @@ -836,7 +904,15 @@ finalhandler@1.1.1: statuses "~1.4.0" unpipe "~1.0.0" -form-data@2.3.2, form-data@^2.3.1: +form-data@1.0.0-rc4: + version "1.0.0-rc4" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-1.0.0-rc4.tgz#05ac6bc22227b43e4461f488161554699d4f8b5e" + dependencies: + async "^1.5.2" + combined-stream "^1.0.5" + mime-types "^2.1.10" + +form-data@^2.3.1: version "2.3.2" resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.2.tgz#4970498be604c20c005d4f5c23aecd21d6b49099" dependencies: @@ -844,7 +920,7 @@ form-data@2.3.2, form-data@^2.3.1: combined-stream "1.0.6" mime-types "^2.1.12" -formidable@^1.1.1: +formidable@^1.0.17, formidable@^1.1.1: version "1.2.1" resolved "https://registry.yarnpkg.com/formidable/-/formidable-1.2.1.tgz#70fb7ca0290ee6ff961090415f4b3df3d2082659" @@ -903,7 +979,18 @@ github-from-package@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/github-from-package/-/github-from-package-0.0.0.tgz#97fb5d96bfde8973313f20e8288ef9a167fa64ce" -glob@7.1.1, glob@7.1.2, glob@^7.0.0, glob@^7.0.5, glob@^7.1.1: +glob@7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.2" + once "^1.3.0" + path-is-absolute "^1.0.0" + +glob@7.1.2, glob@^7.0.0, glob@^7.0.5, glob@^7.1.1: version "7.1.2" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" dependencies: @@ -918,6 +1005,10 @@ graceful-fs@^4.1.2, graceful-fs@^4.1.6: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" +"graceful-readlink@>= 1.0.0": + version "1.0.1" + resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" + growl@1.9.2: version "1.9.2" resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f" @@ -932,7 +1023,17 @@ handlebars@^4.0.6: optionalDependencies: uglify-js "^2.6" -has-flag@3.0.0, has-flag@^3.0.0: +has-ansi@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" + dependencies: + ansi-regex "^2.0.0" + +has-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" + +has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" @@ -954,7 +1055,16 @@ homedir-polyfill@^1.0.1: dependencies: parse-passwd "^1.0.0" -http-errors@1.6.2, http-errors@1.6.3, http-errors@~1.6.2: +http-errors@1.6.2: + version "1.6.2" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.2.tgz#0a002cc85707192a7e7946ceedc11155f60ec736" + dependencies: + depd "1.1.1" + inherits "2.0.3" + setprototypeof "1.0.3" + statuses ">= 1.3.1 < 2" + +http-errors@~1.6.2: version "1.6.3" resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.3.tgz#8b55680bb4be283a0b5bf4ea2e38580be1d9320d" dependencies: @@ -984,7 +1094,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@2.0.3, inherits@^2.0.3, inherits@~2.0.1: +inherits@2, inherits@2.0.3, inherits@^2.0.3, inherits@~2.0.1, inherits@~2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" @@ -1036,6 +1146,10 @@ isarray@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" +isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + isstream@0.1.x: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" @@ -1241,7 +1355,7 @@ mime-db@~1.33.0: version "1.33.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.33.0.tgz#a3492050a5cb9b63450541e39d9788d2272783db" -mime-types@^2.1.12, mime-types@~2.1.18: +mime-types@^2.1.10, mime-types@^2.1.12, mime-types@~2.1.18: version "2.1.18" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.18.tgz#6f323f60a83d11146f831ff11fd66e2fe5503bb8" dependencies: @@ -1251,20 +1365,32 @@ mime@1.4.1, mime@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/mime/-/mime-1.4.1.tgz#121f9ebc49e3766f311a76e1fa1c8003c4b03aa6" +mime@^1.3.4: + version "1.6.0" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" + mimic-response@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.0.tgz#df3d3652a73fded6b9b0b24146e6fd052353458e" -minimatch@^3.0.0, minimatch@^3.0.4: +minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" dependencies: brace-expansion "^1.1.7" -minimist@0.0.8, minimist@1.2.0, minimist@^1.2.0, minimist@~0.0.1: +minimist@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" + +minimist@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" +minimist@~0.0.1: + version "0.0.10" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" + minipass@^2.2.1, minipass@^2.2.4: version "2.2.4" resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.2.4.tgz#03c824d84551ec38a8d1bb5bc350a5a30a354a40" @@ -1327,10 +1453,14 @@ morgan@^1.9.0: on-finished "~2.3.0" on-headers "~1.0.1" -ms@2.0.0, ms@^2.1.1: +ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" +ms@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" + multer@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/multer/-/multer-1.3.0.tgz#092b2670f6846fa4914965efc8cf94c20fec6cd2" @@ -1344,10 +1474,14 @@ multer@^1.3.0: type-is "^1.6.4" xtend "^4.0.0" -nan@2.10.0, nan@^2.10.0, nan@^2.3.0, nan@~2.9.2: +nan@^2.10.0, nan@^2.3.0: version "2.10.0" resolved "https://registry.yarnpkg.com/nan/-/nan-2.10.0.tgz#96d0cd610ebd58d4b4de9cc0c6828cda99c7548f" +nan@~2.9.2: + version "2.9.2" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.9.2.tgz#f564d75f5f8f36a6d9456cca7a6c4fe488ab7866" + needle@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/needle/-/needle-2.2.0.tgz#f14efc69cee1024b72c8b21c7bdf94a731dc12fa" @@ -1517,6 +1651,10 @@ pg-hstore@^2.3.1: dependencies: underscore "^1.7.0" +pg-int8@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/pg-int8/-/pg-int8-1.0.1.tgz#943bd463bf5b71b4170115f80f8efc9a0c0eb78c" + pg-native@^2.1.9: version "2.2.0" resolved "https://registry.yarnpkg.com/pg-native/-/pg-native-2.2.0.tgz#bc84756f4ecbf600ff7cb48ea5854141830cf1e4" @@ -1529,11 +1667,20 @@ pg-pool@~2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-2.0.3.tgz#c022032c8949f312a4f91fb6409ce04076be3257" -pg-types@1.12.0, pg-types@^1.12.1, pg-types@~1.12.1: - version "1.12.0" - resolved "https://registry.yarnpkg.com/pg-types/-/pg-types-1.12.0.tgz#8ad3b7b897e3fd463e62de241ad5fc640b4a66f0" +pg-types@^1.12.1: + version "1.13.0" + resolved "https://registry.yarnpkg.com/pg-types/-/pg-types-1.13.0.tgz#75f490b8a8abf75f1386ef5ec4455ecf6b345c63" + dependencies: + pg-int8 "1.0.1" + postgres-array "~1.0.0" + postgres-bytea "~1.0.0" + postgres-date "~1.0.0" + postgres-interval "^1.1.0" + +pg-types@~1.12.1: + version "1.12.1" + resolved "https://registry.yarnpkg.com/pg-types/-/pg-types-1.12.1.tgz#d64087e3903b58ffaad279e7595c52208a14c3d2" dependencies: - ap "~0.2.0" postgres-array "~1.0.0" postgres-bytea "~1.0.0" postgres-date "~1.0.0" @@ -1610,6 +1757,10 @@ printj@~1.1.0, printj@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/printj/-/printj-1.1.2.tgz#d90deb2975a8b9f600fb3a1c94e3f4c53c78a222" +process-nextick-args@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa" + progress@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f" @@ -1621,14 +1772,21 @@ proxy-addr@~2.0.3: forwarded "~0.1.2" ipaddr.js "1.6.0" -pump@2.0.1, pump@^1.0.0, pump@^2.0.1: +pump@^1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/pump/-/pump-1.0.3.tgz#5dfe8311c33bbf6fc18261f9f34702c47c08a954" + dependencies: + end-of-stream "^1.1.0" + once "^1.3.1" + +pump@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/pump/-/pump-2.0.1.tgz#12399add6e4cf7526d973cbc8b5ce2e2908b3909" dependencies: end-of-stream "^1.1.0" once "^1.3.1" -qs@6.5.1, qs@^6.2.0, qs@^6.5.1: +qs@6.5.1, qs@^6.1.0, qs@^6.2.0, qs@^6.5.1: version "6.5.1" resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" @@ -1654,7 +1812,7 @@ rc@^1.1.6, rc@^1.1.7: minimist "^1.2.0" strip-json-comments "~2.0.1" -readable-stream@1.0.31, readable-stream@1.1.x, readable-stream@^2.0.0, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.2.2, readable-stream@^2.3.5: +readable-stream@1.0.31: version "1.0.31" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.31.tgz#8f2502e0bc9e3b0da1b94520aabb4e2603ecafae" dependencies: @@ -1663,6 +1821,27 @@ readable-stream@1.0.31, readable-stream@1.1.x, readable-stream@^2.0.0, readable- isarray "0.0.1" string_decoder "~0.10.x" +readable-stream@1.1.x: + version "1.1.14" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readable-stream@^2.0.0, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.2.2, readable-stream@^2.3.5: + version "2.3.6" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.1.1" + util-deprecate "~1.0.1" + rechoir@^0.6.2: version "0.6.2" resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" @@ -1702,7 +1881,7 @@ rimraf@^2.6.1: dependencies: glob "^7.0.5" -safe-buffer@5.1.1, safe-buffer@^5.0.1, safe-buffer@^5.1.1: +safe-buffer@5.1.1, safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" @@ -1710,10 +1889,14 @@ sax@^1.2.4: version "1.2.4" resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" -semver@4.3.2, semver@5.*, semver@^5.0.1, semver@^5.3.0, semver@^5.4.1, semver@^5.5.0: +semver@4.3.2: version "4.3.2" resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.2.tgz#c7a07158a80bedd052355b770d82d6640f803be7" +semver@5.*, semver@^5.0.1, semver@^5.3.0, semver@^5.4.1, semver@^5.5.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab" + send@0.16.2: version "0.16.2" resolved "https://registry.yarnpkg.com/send/-/send-0.16.2.tgz#6ecca1e0f8c156d141597559848df64730a6bbc1" @@ -1778,6 +1961,10 @@ set-blocking@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" +setprototypeof@1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.0.3.tgz#66567e37043eeb4f04d91bd658c0cbefb55b8e04" + setprototypeof@1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.0.tgz#d0bd85536887b6fe7c0d818cb962d9d91c54e656" @@ -1837,7 +2024,13 @@ source-map-support@^0.4.0: dependencies: source-map "^0.5.6" -source-map@0.5.7, source-map@^0.4.4, source-map@^0.5.6, source-map@~0.5.1: +source-map@^0.4.4: + version "0.4.4" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b" + dependencies: + amdefine ">=0.0.4" + +source-map@^0.5.6, source-map@~0.5.1: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" @@ -1847,10 +2040,14 @@ split@^1.0.0: dependencies: through "2" -sprintf-js@1.1.1, sprintf-js@^1.0.3, sprintf-js@~1.0.2: +sprintf-js@^1.0.3: version "1.1.1" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.1.tgz#36be78320afe5801f6cea3ee78b6e5aab940ea0c" +sprintf-js@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + sqlite3@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/sqlite3/-/sqlite3-4.0.0.tgz#cc0e093ab51873f50d9dfc4126fcbef15d486570" @@ -1868,10 +2065,14 @@ stack-trace@0.0.x: version "0.0.10" resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0" -statuses@1.5.0, "statuses@>= 1.4.0 < 2", statuses@~1.4.0: +"statuses@>= 1.3.1 < 2", "statuses@>= 1.4.0 < 2": version "1.5.0" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" +statuses@~1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.4.0.tgz#bb73d446da2796106efcc1b601a253d6c46bd087" + streamsearch@0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/streamsearch/-/streamsearch-0.1.2.tgz#808b9d0e56fc273d809ba57338e929919a1a9f1a" @@ -1884,10 +2085,16 @@ string-width@^1.0.1, string-width@^1.0.2: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -string_decoder@0.10.31, string_decoder@~0.10.x: +string_decoder@~0.10.x: version "0.10.31" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" +string_decoder@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" + dependencies: + safe-buffer "~5.1.0" + strip-ansi@^3.0.0, strip-ansi@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" @@ -1902,7 +2109,22 @@ strip-json-comments@^2.0.0, strip-json-comments@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" -superagent@3.8.2, superagent@^2.0.0, superagent@^3.0.0: +superagent@^2.0.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/superagent/-/superagent-2.3.0.tgz#703529a0714e57e123959ddefbce193b2e50d115" + dependencies: + component-emitter "^1.2.0" + cookiejar "^2.0.6" + debug "^2.2.0" + extend "^3.0.0" + form-data "1.0.0-rc4" + formidable "^1.0.17" + methods "^1.1.1" + mime "^1.3.4" + qs "^6.1.0" + readable-stream "^2.0.5" + +superagent@^3.0.0: version "3.8.2" resolved "https://registry.yarnpkg.com/superagent/-/superagent-3.8.2.tgz#e4a11b9d047f7d3efeb3bbe536d9ec0021d16403" dependencies: @@ -1924,7 +2146,17 @@ supertest@^3.0.0: methods "~1.1.2" superagent "^3.0.0" -supports-color@3.1.2, supports-color@5.4.0, supports-color@^5.3.0: +supports-color@3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.1.2.tgz#72a262894d9d408b956ca05ff37b2ed8a6e2a2d5" + dependencies: + has-flag "^1.0.0" + +supports-color@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" + +supports-color@^5.3.0: version "5.4.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.4.0.tgz#1c6b337402c2137605efe19f10fec390f6faab54" dependencies: @@ -2035,7 +2267,11 @@ tunnel-agent@^0.6.0: dependencies: safe-buffer "^5.0.1" -type-detect@0.1.1, type-detect@1.0.0, type-detect@^1.0.0: +type-detect@0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-0.1.1.tgz#0ba5ec2a885640e470ea4e8505971900dac58822" + +type-detect@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-1.0.0.tgz#762217cc06db258ec48908a1298e8b95121e8ea2" @@ -2109,6 +2345,10 @@ unpipe@1.0.0, unpipe@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" +util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + utils-extend@^1.0.4, utils-extend@^1.0.6: version "1.0.8" resolved "https://registry.yarnpkg.com/utils-extend/-/utils-extend-1.0.8.tgz#ccfd7b64540f8e90ee21eec57769d0651cab8a5f" @@ -2182,7 +2422,11 @@ wkx@^0.4.1: dependencies: "@types/node" "*" -wordwrap@0.0.2, wordwrap@0.0.3, wordwrap@~0.0.2: +wordwrap@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" + +wordwrap@~0.0.2: version "0.0.3" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" -- cgit v1.2.1 From b8ed41883fb0b9faf2733632657243c7dece4d6e Mon Sep 17 00:00:00 2001 From: jw255 Date: Thu, 19 Apr 2018 21:10:18 +0100 Subject: reduced # of failing tests --- src/FileRouter.ts | 8 +++++--- src/logger.ts | 6 +++--- src/matcher/options.ts | 13 +------------ test/integration/protocol.routes.test.ts | 32 ++++++++++++++++++-------------- 4 files changed, 27 insertions(+), 32 deletions(-) diff --git a/src/FileRouter.ts b/src/FileRouter.ts index 53fc537..3f966c2 100644 --- a/src/FileRouter.ts +++ b/src/FileRouter.ts @@ -168,7 +168,7 @@ const getProperties: Middleware = ( const postProperties: Middleware = ( req: Request, res: Response, next: NextFunction ): void => { - logger.debug('Editing server properties'); + console.log('Editing server properties'); res.locals.modified = true; for (const newProp of req.body) { const prop: Property | undefined = serverConfig.find( @@ -189,6 +189,7 @@ const postProperties: Middleware = ( return; } } + console.log("Posted Properties successfully"); next(); }; @@ -629,7 +630,8 @@ const postFilePath: Middleware = async(req: Request, res: Response, next: NextFu // Sets final if requested if (res.locals.file && qH.isFinal(req)) { - res.locals.file.status = 'final'; + res.locals.file.status = 'preprocessing'; + // start file conversion } // Sets Metadata if requested @@ -767,7 +769,7 @@ export class FileRouter { // File access this.router.get ('/projects/:project_name/files/:path', getFilePath); this.router.post('/projects/:project_name/files/:path', - upload.single('userfile'), postFilePath); + upload.single('userfile'), postFilePath); this.router.get ('/projects/:project_name/files_by_id/:id', getFileId); } diff --git a/src/logger.ts b/src/logger.ts index ba66650..bdd8fbc 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -143,7 +143,7 @@ const basicFileTransport: winston.TransportInstance = silent: false, colorize: false, timestamp: true, - filename: './logs/general/basic',//logPath('basic'), + filename: './logs/general/basic', //logPath('basic'), maxSize: 1000000, maxFiles: 100, stream: undefined, @@ -170,7 +170,7 @@ const criticalFileTransport: winston.TransportInstance = silent: false, colorize: false, timestamp: true, - filename: './logs/general/critical' ,//logPath('critical'), + filename: './logs/general/critical', //logPath('critical'), maxSize: 1000000, maxFiles: 10, stream: undefined, @@ -198,7 +198,7 @@ const queryFileTransport: winston.TransportInstance = silent: false, colorize: false, timestamp: true, - filename: './logs/general/queries',//logPath('queries'), + filename: './logs/general/queries', //logPath('queries'), maxSize: 1000000, maxFiles: 100, stream: undefined, diff --git a/src/matcher/options.ts b/src/matcher/options.ts index 967a6f9..62e4985 100644 --- a/src/matcher/options.ts +++ b/src/matcher/options.ts @@ -15,20 +15,13 @@ export type Value = const matchNoCurry: (template: TemplateValue, value: Value | undefined) => boolean = (template: TemplateValue, value: Value | undefined): boolean => { - console.log("matchNoCurry()") - console.log(template) - console.log(value) if (types.atom(template)) { - console.log("atom") return template === value; } else if (types.function(template)) { - console.log("function") return template(value); } else if (types.atom(value) || value === undefined) { - console.log("atom2") return false; } else if (types.object(template)) { - console.log("object") return Object.keys(template) .every((key: string): boolean => { const v: Value | undefined = value[key]; @@ -41,11 +34,7 @@ const matchNoCurry: // tslint:disable-next-line:typedef export const match = (template: TemplateValue, value?: Value) => { - console.log("match()") - console.log(template) - console.log(value) if (value === undefined) { - console.log("is undefined") return matchNoCurry.bind(null, template); } return matchNoCurry(template, value); @@ -96,7 +85,7 @@ export const array = (template: TemplateValue, values?: Value[]) => { const m: Checker = types.function(template) ? template : match.bind(null, template); - return values.every(m); // + return values.every(m); }; // tslint:disable-next-line:typedef diff --git a/test/integration/protocol.routes.test.ts b/test/integration/protocol.routes.test.ts index 1e8bf63..a371fd5 100644 --- a/test/integration/protocol.routes.test.ts +++ b/test/integration/protocol.routes.test.ts @@ -94,16 +94,19 @@ const completeProtocol: MochaForEachInput[] = [ required: array(types.string) }, 200], ['get', '/log', array({ + user: optional(types.string), component: types.string, level: alternative([ + 'debug', 'info', 'security', 'warning', 'error', - 'critical' + 'critical', + 'success' ]), - value: types.anything, - username: types.string, + message: types.anything, + label: optional(types.string), timestamp: types.string }), 200], ['post', '/log', [{ @@ -116,22 +119,23 @@ const completeProtocol: MochaForEachInput[] = [ display: optional(match({ category: types.string, group: types.string, - display_name: types.string, + displayName: types.string, description: types.string })), - read_only: types.boolean, + readOnly: types.boolean, type: alternative([ 'string', 'integer', 'boolean' ]), - value: alternative([ + valueInternal: alternative([ types.string, types.integer, types.boolean ]) }), 200], - ['post', '/properties?action=update', null, 200], + ['post', '/properties?action=update', + [{id: 'new_prop', value: 'some_value'}], 200], ['get', '/user_privileges', array({ privilege: types.string, description: types.string, @@ -139,8 +143,8 @@ const completeProtocol: MochaForEachInput[] = [ }), 200], ['get', '/users', array({ username: types.string, - privileges: types.array(types.string), - projects: types.array({ + privileges: array(types.string), + projects: array({ project_name: types.string, access_level: types.string }), @@ -168,8 +172,8 @@ const completeProtocol: MochaForEachInput[] = [ }, 200], ['get', '/current_user', { username: types.string, - privileges: types.array(types.string), - projects: types.array({ + privileges: array(types.string), + projects: array({ project_name: types.string, access_level: types.string }), @@ -186,7 +190,7 @@ const completeProtocol: MochaForEachInput[] = [ }), 200], ['get', '/projects', array({ project_name: types.string, - users: types.array({ + users: array({ username: types.string, access_level: types.string }), @@ -206,8 +210,8 @@ const completeProtocol: MochaForEachInput[] = [ }, 200], ['post', '/projects/mocky', null, 200], ['get', '/projects/mocky/properties', null, 200], - ['get', '/projects/mocky/files/example/path', null, 200], - ['post', '/projects/mocky/files/some_file?action=overwrite', {}, 200], + ['post', '/projects/mocky/files/folder+some_file?action=overwrite', {}, 200], + ['get', '/projects/mocky/files/folder+some_file', null, 200], ['get', '/projects/mocky/files_by_id/file1', null, 200] ]; -- cgit v1.2.1