-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from osher/patch-1
resolving controller-interface type
- Loading branch information
Showing
12 changed files
with
381 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./cors'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
test/assets/project/api/controllers/overrides_ctrl_interface_pipe.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = { | ||
pipeInterface: pipeInterface, | ||
middlewareInterface: middlewareInterface | ||
} | ||
|
||
function pipeInterface(ctx, next) { | ||
ctx.statusCode = 200; | ||
ctx.headers = { | ||
'content-type': 'application/json', | ||
'x-interface': 'pipe' | ||
}; | ||
next(null, { interface: 'pipe' }); | ||
} | ||
|
||
function middlewareInterface(req, res, next) { | ||
res.setHeader('x-interface', 'middleware'); | ||
res.json({ interface: "middleware" }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
'use strict'; | ||
var util = require('util'); | ||
|
||
module.exports = { | ||
hello: hello, | ||
hello_body: hello_body, | ||
hello_file: hello_file, | ||
get: hello, | ||
self_multiple_writes : self_multiple_writes, | ||
hello_text_body: hello_text_body | ||
}; | ||
|
||
function hello(ctx, next) { | ||
var req = ctx.request; | ||
var name = req.swagger.params.name.value || 'stranger'; | ||
var hello = { message: util.format('Hello, %s!', name) }; | ||
ctx.statusCode = 200; | ||
ctx.headers = { 'content-type' : 'application/json' }; | ||
next(null, hello) | ||
} | ||
|
||
function hello_body(ctx, next) { | ||
var req = ctx.request; | ||
var name = req.swagger.params.nameRequest.value.name || 'stranger'; | ||
var hello = { message: util.format('Hello, %s!', name) }; | ||
ctx.statusCode = 200; | ||
ctx.headers = {}; | ||
next(null, hello) | ||
} | ||
|
||
function hello_file(ctx, next) { | ||
var req = ctx.request; | ||
var name = req.swagger.params.name.value || 'stranger'; | ||
var file = req.swagger.params.example_file.value; | ||
var hello = { message: util.format('Hello, %s!', name) }; | ||
ctx.statusCode = 200; | ||
ctx.headers = {}; | ||
next(null, hello) | ||
} | ||
|
||
function self_multiple_writes(ctx, next) { | ||
var res = ctx.response; | ||
res.write('hello'); | ||
res.write('world'); | ||
res.end('yo'); | ||
next(); | ||
} | ||
|
||
function hello_text_body(ctx, next) { | ||
var req = ctx.request; | ||
var name = req.swagger.params.name.value || 'stranger'; | ||
var hello = { message: util.format('Hello, %s!', name) }; | ||
ctx.statusCode = 200; | ||
ctx.headers = {}; | ||
next(null, hello) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# values in the swagger hash are system configuration for swagger-node | ||
swagger: | ||
|
||
fittingsDirs: [ api/fittings ] | ||
defaultPipe: null | ||
swaggerControllerPipe: swagger_controllers # defines the standard processing pipe for controllers | ||
|
||
# values defined in the bagpipes key are the bagpipes pipes and fittings definitions | ||
# (see https://github.com/apigee-127/bagpipes) | ||
bagpipes: | ||
|
||
_router: | ||
name: swagger_router | ||
mockMode: false | ||
mockControllersDirs: [ api/mocks ] | ||
controllersDirs: [ api/controllers ] | ||
controllersInterface: auto-detect | ||
|
||
_swagger_validate: | ||
name: swagger_validator | ||
validateResponse: true | ||
|
||
_swagger_security: | ||
name: swagger_security | ||
securityHandlersModule: api/helpers/securityHandlers | ||
|
||
# pipe for all swagger-node controllers | ||
swagger_controllers: | ||
- onError: json_error_handler | ||
- cors | ||
- swagger_params_parser | ||
- _swagger_security | ||
- _swagger_validate | ||
- express_compatibility | ||
- _router | ||
|
||
# pipe to serve swagger (endpoint is in swagger.yaml) | ||
swagger_raw: | ||
name: swagger_raw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# values in the swagger hash are system configuration for swagger-node | ||
swagger: | ||
|
||
fittingsDirs: [ node_modules, api/fittings ] | ||
defaultPipe: null | ||
swaggerControllerPipe: swagger_controllers # defines the standard processing pipe for controllers | ||
|
||
# values defined in the bagpipes key are the bagpipes pipes and fittings definitions | ||
# (see https://github.com/apigee-127/bagpipes) | ||
bagpipes: | ||
|
||
_router: | ||
name: swagger_router | ||
mockMode: false | ||
mockControllersDirs: [ api/mocks ] | ||
controllersDirs: [ api/pipes ] | ||
controllersInterface: pipe | ||
|
||
_swagger_validate: | ||
name: swagger_validator | ||
validateResponse: true | ||
|
||
_swagger_security: | ||
name: swagger_security | ||
securityHandlersModule: api/helpers/securityHandlers | ||
|
||
# pipe for all swagger-node controllers | ||
swagger_controllers: | ||
- onError: json_error_handler | ||
- swagger_cors | ||
- swagger_params_parser | ||
- _swagger_security | ||
- _swagger_validate | ||
- express_compatibility | ||
- _router | ||
|
||
# pipe to serve swagger (endpoint is in swagger.yaml) | ||
swagger_raw: | ||
name: swagger_raw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.