From d8688e99fd945122548876466dece0cca8bc315b Mon Sep 17 00:00:00 2001 From: Hafeez Date: Fri, 13 Apr 2018 16:37:01 +0100 Subject: added include --- src/FileRouter.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/FileRouter.ts b/src/FileRouter.ts index b750094..990110a 100644 --- a/src/FileRouter.ts +++ b/src/FileRouter.ts @@ -639,6 +639,7 @@ export class FileRouter { projectName: string ): Promise => { res.locals.project = await Project.findOne({ + include: [{all: true}], where: { name: projectName } -- cgit v1.2.1 From 9367a9510726a3751cb2ea6eee52cec1fb658767 Mon Sep 17 00:00:00 2001 From: Hafeez Date: Fri, 13 Apr 2018 16:46:44 +0100 Subject: changed something --- test/integration/protocol.routes.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/protocol.routes.test.ts b/test/integration/protocol.routes.test.ts index 2a7cf54..866ac2a 100644 --- a/test/integration/protocol.routes.test.ts +++ b/test/integration/protocol.routes.test.ts @@ -184,7 +184,7 @@ describe('routes : protocol', () => { public_admin_metadata: types.anything, private_admin_metadata: types.anything }, 200], - ['post', '/users/mock_user', null, 200], + ['post', '/users/new_user', null, 200], ['get', '/users/mock_user/properties', { data: optional(types.anything) }, 200], -- cgit v1.2.1 From 8555711c7f408e74ea8ad3da1875ddbdef36c509 Mon Sep 17 00:00:00 2001 From: Hafeez Date: Fri, 13 Apr 2018 16:58:50 +0100 Subject: prevent 404 on params --- src/FileRouter.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/FileRouter.ts b/src/FileRouter.ts index e890241..f4d2fdc 100644 --- a/src/FileRouter.ts +++ b/src/FileRouter.ts @@ -716,11 +716,8 @@ export class FileRouter { uuid: fileId } }); - if (file == null) { - return next(new RequestError(404, 'file_not_found')); - } else { - res.locals.file = file; - } + + res.locals.file = file; next(); } ); -- cgit v1.2.1 From 72704a9fb688acdb57b33846796b13abbeb18a3c Mon Sep 17 00:00:00 2001 From: Hafeez Date: Sat, 14 Apr 2018 18:26:36 +0100 Subject: returns 404 for unused routes only if logged in --- src/app.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app.ts b/src/app.ts index c299cf7..6854c46 100644 --- a/src/app.ts +++ b/src/app.ts @@ -77,7 +77,7 @@ class App { .unless({path: [ '/', '/cs3099group-be-4/oauth/token', - '/cs3099group-be-4/_supported_protocols_' + '/cs3099group-be-4/_supported_protocols_' ] }) ); this.express.use(passport.initialize()); @@ -110,20 +110,20 @@ class App { message: 'Welcome to the CS3099 BE4 server!', important: 'Endpoints start from /cs3099group-be-4/' }); - }); - const errRouter: ex.Router = ex.Router(); - errRouter.get('/*', (req: ex.Request, res: ex.Response): void => { + }); + const errRouter: ex.Router = ex.Router(); + errRouter.get('*', (req: ex.Request, res: ex.Response): void => { res.status(404) .json({ status: 'error', error : 'invalid_route', error_description: 'Endpoints start from /cs3099group-be-4/' }); - }); + }); this.express.use('/cs3099group-be-4', FileRouter); this.express.use('/cs3099group-be-4', authRouter); this.express.use('/', defRouter); - this.express.use('/XX*', errRouter); + this.express.use('*', errRouter); } /** -- cgit v1.2.1