mirror of
https://github.com/openstf/stf
synced 2025-10-04 10:19:30 +02:00
Add basic api unit. This unit will be responsible for providing all stf restful apis.
This commit is contained in:
parent
7ea7871ec0
commit
41f306a7f0
7 changed files with 172 additions and 0 deletions
27
lib/units/api/index.js
Normal file
27
lib/units/api/index.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
var http = require('http')
|
||||
var path = require('path')
|
||||
|
||||
var express = require('express')
|
||||
var SwaggerExpress = require('swagger-express-mw')
|
||||
|
||||
var logger = require('../../util/logger')
|
||||
|
||||
module.exports = function(options) {
|
||||
var log = logger.createLogger('api')
|
||||
, app = express()
|
||||
, server = http.createServer(app)
|
||||
|
||||
var config = {
|
||||
appRoot: __dirname
|
||||
, swaggerFile: path.resolve(__dirname, 'swagger', 'api_v1.yaml')
|
||||
};
|
||||
|
||||
SwaggerExpress.create(config, function(err, swaggerExpress) {
|
||||
if (err) { throw err; }
|
||||
|
||||
swaggerExpress.register(app);
|
||||
})
|
||||
|
||||
server.listen(options.port)
|
||||
log.info('Listening on port %d', options.port)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue