Copying over from WrenchBoradWeb to new repository
This commit is contained in:
@@ -0,0 +1,151 @@
|
||||
const express = require('express');
|
||||
const logger = require('./app/logger');
|
||||
const swaggerUI = require('swagger-ui-express');
|
||||
const swaggerJSDocs = require('swagger-jsdoc');
|
||||
|
||||
const port = process.env.PORT || 3000;
|
||||
|
||||
const definition = {
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"version": "0.0.4",
|
||||
"title": "flutterwave-transfer-micro",
|
||||
"description": "A microservice to handle flitterware payment services"
|
||||
},
|
||||
"host": "localhost:3000",
|
||||
"basePath": "/",
|
||||
"tags": [],
|
||||
"schemes": [
|
||||
"http"
|
||||
],
|
||||
"consumes": ['application/json'],
|
||||
"produces": ['application/json'],
|
||||
"paths": {
|
||||
"/about": {
|
||||
"get": {
|
||||
"tags": [],
|
||||
"description": "About the microservice (service status)",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/create": {
|
||||
"post": {
|
||||
"tags": [],
|
||||
"description": "Create new transfer",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"parameters": [{
|
||||
"name":"transfer",
|
||||
"in": "body",
|
||||
"description": "Transfer to create",
|
||||
"required": true,
|
||||
"type":"object",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/NewTransfer"
|
||||
},
|
||||
"example": {
|
||||
"account_bank": "044",
|
||||
"account_number": "0690000040",
|
||||
"amount": 5500,
|
||||
"narration": "Akhlm Pstmn Trnsfr xx007",
|
||||
"currency": "NGN",
|
||||
"reference": "akhlm-pstmnpyt-rfxx007_PMCKDU_1",
|
||||
"debit_currency": "NGN"
|
||||
}
|
||||
}],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/status/{id}": {
|
||||
"get": {
|
||||
"tags": [],
|
||||
"description": "Get transfer status",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"NewTransfer": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"account_bank",
|
||||
"account_number",
|
||||
"amount",
|
||||
"narration",
|
||||
"currency",
|
||||
"reference",
|
||||
"debit_currency"
|
||||
],
|
||||
"properties": {
|
||||
"account_bank": {
|
||||
"type": "string"
|
||||
},
|
||||
"account_number": {
|
||||
"type": "string"
|
||||
},
|
||||
"amount": {
|
||||
"type": "integer"
|
||||
},
|
||||
"narration": {
|
||||
"type": "string"
|
||||
},
|
||||
"currency": {
|
||||
"type": "string"
|
||||
},
|
||||
"reference": {
|
||||
"type": "string"
|
||||
},
|
||||
"debit_currency": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
const options = {
|
||||
definition,
|
||||
apis: ['./server.js'],
|
||||
};
|
||||
|
||||
const swaggerSpec = swaggerJSDocs(options);
|
||||
|
||||
const app = express();
|
||||
|
||||
app.get('/swagger.json', (req, res) => {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.send(swaggerSpec);
|
||||
});
|
||||
app.use('/api-docs', swaggerUI.serve, swaggerUI.setup(swaggerSpec));
|
||||
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded());
|
||||
|
||||
const routes = require('./api/routes');
|
||||
routes(app);
|
||||
|
||||
app.listen(port, "0.0.0.0", function() {
|
||||
logger.info('***** Server started on port: ' + port + ' *****');
|
||||
});
|
||||
Reference in New Issue
Block a user