-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
5,670 additions
and
7,943 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,7 @@ | ||
# Sample angular app Changelog | ||
|
||
All notable changes to the sample angular app will be documented in this file. | ||
|
||
## 1.2.0 | ||
|
||
- Enhancement: Added a new dataservice 'callservice', which serves as an example for how to use the callService API. This service simply calls the 'hello' service and returns the result wrapped in a JSON message. |
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,66 @@ | ||
import { Response, Request } from "express"; | ||
import { Router } from "express-serve-static-core"; | ||
|
||
|
||
|
||
/* | ||
This program and the accompanying materials are | ||
made available under the terms of the Eclipse Public License v2.0 which accompanies | ||
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html | ||
SPDX-License-Identifier: EPL-2.0 | ||
Copyright Contributors to the Zowe Project. | ||
*/ | ||
|
||
const express = require('express'); | ||
const Promise = require('bluebird'); | ||
|
||
class CallService{ | ||
private context: any; | ||
private router: Router; | ||
|
||
constructor(context: any){ | ||
this.context = context; | ||
let router = express.Router(); | ||
router.use(function noteRequest(req: Request,res: Response,next: any) { | ||
context.logger.info('Saw request, method='+req.method); | ||
next(); | ||
}); | ||
context.addBodyParseMiddleware(router); | ||
router.post('/',function(req: Request,res: Response) { | ||
(req as any).zluxData.plugin.callService('hello', '', {method:'POST', body: req.body, contentType:req.get('content-type')}).then((callRes)=> { | ||
context.logger.info('callService Returned: statusCode=%s, statusMessage=%s, body length=%s', | ||
callRes.statusCode, | ||
callRes.statusMessage, | ||
callRes.body.length); | ||
res.status(200).json({'callService Returned':callRes.body}); | ||
}); | ||
}); | ||
this.router = router; | ||
} | ||
|
||
getRouter():Router{ | ||
return this.router; | ||
} | ||
} | ||
|
||
|
||
exports.callServiceRouter = function(context): Router { | ||
return new Promise(function(resolve, reject) { | ||
let dataservice = new CallService(context); | ||
resolve(dataservice.getRouter()); | ||
}); | ||
} | ||
|
||
|
||
/* | ||
This program and the accompanying materials are | ||
made available under the terms of the Eclipse Public License v2.0 which accompanies | ||
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html | ||
SPDX-License-Identifier: EPL-2.0 | ||
Copyright Contributors to the Zowe Project. | ||
*/ | ||
|
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.