mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 15:48:11 -05:00
Pull out schema fetching, as some times we fetch schemas when we don't actually have a handler for the type.
This commit is contained in:
parent
234d1b5950
commit
836a01d1a8
2 changed files with 6 additions and 1 deletions
|
@ -42,6 +42,7 @@ module.exports.handlerUrlOverrides =
|
|||
'level_session': 'level.session'
|
||||
'level_system': 'level.system'
|
||||
'thang_type': 'thang.type'
|
||||
'thang_component': 'thang.component'
|
||||
'user_code_problem': 'user.code.problem'
|
||||
'user_remark': 'user.remark'
|
||||
'mail_sent': 'mail.sent'
|
||||
|
|
|
@ -26,7 +26,7 @@ module.exports.setup = (app) ->
|
|||
|
||||
parts = req.path[4..].split('/')
|
||||
|
||||
return getSchema(req, res, module) if parts[1] is 'schema'
|
||||
|
||||
if (not req.user) and req.route.method isnt 'get'
|
||||
return errors.unauthorized(res, 'Must have an identity to do anything with the db. Do you have cookies enabled?')
|
||||
|
||||
|
@ -56,6 +56,10 @@ module.exports.setup = (app) ->
|
|||
app.all '/db/' + moduleName + '/*', routeHandler
|
||||
app.all '/db/' + moduleName, routeHandler
|
||||
|
||||
app.get '/db/:module/schema', (req, res) ->
|
||||
res.setHeader('Content-Type', 'application/json')
|
||||
getSchema req, res, req.params.module
|
||||
|
||||
for moduleNameUnder of handlers
|
||||
name = handlers[moduleNameUnder]
|
||||
moduleName = handlerUrlOverrides[moduleNameUnder] or moduleNameUnder
|
||||
|
|
Loading…
Reference in a new issue