Skip to content

Commit 060cd7f

Browse files
committed
add the routes asynchronously, so 404 works correctly, #13
1 parent 39c9030 commit 060cd7f

12 files changed

Lines changed: 34 additions & 34 deletions

‎src/routes/execute.coffee‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ Fs = require 'fs'
44
CONFIG = require '../config'
55
Request = require 'superagent'
66

7-
module.exports = (app, opts) ->
8-
opts or= {}
7+
module.exports = (app, done) ->
98

109
app.swagger '/api/execute',
1110
post:
@@ -59,3 +58,5 @@ module.exports = (app, opts) ->
5958
res.send '@link': executionUri
6059
res.status 201
6160
return res.end()
61+
62+
done()

‎src/routes/header.coffee‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
module.exports = (app, opts) ->
2-
opts or= {}
1+
module.exports = (app, done) ->
32

43
app.get '/_header', (req, res, next) ->
54
res.render 'header'
5+
6+
done()
7+

‎src/routes/json-import.coffee‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ _postResource = (origDB, resourceEndpoint, callback) ->
6464
return callback err if err
6565
return callback null, _replaceAll(origDB, mapping)
6666

67-
module.exports = (app, opts) ->
68-
69-
opts or= {}
67+
module.exports = (app, done) ->
7068

7169
app.swagger '/api/json-import',
7270
post:
@@ -114,3 +112,5 @@ module.exports = (app, opts) ->
114112
, (err) ->
115113
return next err if err
116114
return res.send JSON.stringify JSON.parse(serializedDB), null, 2
115+
116+
done()

‎src/routes/ldf.coffee‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1+
module.exports = (app, done) ->
12

2-
module.exports = (app, opts) ->
3-
opts or= {}
4-
5-
app.schemo.handlers.ldf.inject(app, opts)
3+
app.schemo.handlers.ldf.inject(app, done)

‎src/routes/monitor.coffee‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ CONFIG = require '../config'
55

66
log = require('../log')(module)
77

8-
module.exports = (app, opts) ->
9-
opts or= {}
8+
module.exports = (app, done) ->
109

1110
app.swagger '/api/stats',
1211
get:
@@ -82,4 +81,5 @@ module.exports = (app, opts) ->
8281
return res.render 'monitor', { byStatus, statuses, allExecutions }
8382
else
8483
return res.send allExecutions
84+
done()
8585

‎src/routes/play.coffee‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ BodyParser = require 'body-parser'
22

33
log = require('../log')(module)
44

5-
module.exports = (app, opts) ->
6-
opts or= {}
5+
module.exports = (app, done) ->
76

87
app.get '/play/demo1', (req, res, next) ->
98
res.render 'demo-upload'
109

10+
done()

‎src/routes/restful.coffee‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
module.exports = (app, opts) ->
2-
opts or= {}
1+
module.exports = (app, done) ->
32

43
# restful handlers
5-
app.schemo.handlers.restful.inject(app)
4+
app.schemo.handlers.restful.inject(app, done)
65

‎src/routes/schemo.coffee‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
module.exports = setupRoutes = (app, opts) ->
2-
opts or= {}
3-
4-
# schema handlers
5-
app.schemo.handlers.schema.inject(app)
1+
module.exports = setupRoutes = (app, done) ->
62

73
# Schema handler for the ontology, i.e. /schema
84
app.get(app.schemo.schemaPrefix,
95
(req, res, next) ->
106
req.jsonld = app.schemo.jsonldTBox()
117
next()
128
app.jsonldMiddleware)
9+
10+
# schema handlers
11+
app.schemo.handlers.schema.inject(app, done)
12+

‎src/routes/swagger.coffee‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
module.exports = (app, opts) ->
2-
opts or= {}
1+
module.exports = (app, done) ->
32

43
# Swagger interface
54
app.get '/api', (req, res, next) ->
@@ -21,4 +20,4 @@ module.exports = (app, opts) ->
2120
}
2221
]
2322
paths: app.swagger()
24-
}
23+
}, done

‎src/routes/syntax-highlight.coffee‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ Vim2Html = require 'vim2html'
33

44
log = require('../log')(module)
55

6-
module.exports = (app, opts) ->
7-
opts or= {}
6+
module.exports = (app, done) ->
87

98
app.swagger '/api/syntax-highlight',
109
post:
@@ -64,3 +63,5 @@ module.exports = (app, opts) ->
6463
if err
6564
return next err
6665
res.send highlighted
66+
67+
done()

0 commit comments

Comments
 (0)