Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6cce6a0a45 | |||
| e276b6cb7b |
@@ -1,4 +1,4 @@
|
||||
FROM node:boron
|
||||
FROM node:erbium
|
||||
|
||||
# Create app directory
|
||||
RUN mkdir -p /usr/src/app
|
||||
|
||||
+1696
-219
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "flutterwave-transfer-micro",
|
||||
"version": "0.0.2",
|
||||
"version": "0.0.4",
|
||||
"description": "A microservice to handle flutterware payment services",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
@@ -15,8 +15,12 @@
|
||||
"axios": "^0.24.0",
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"openapi-types": "^10.0.0",
|
||||
"pg": "8.7.1",
|
||||
"request": "^2.88.2",
|
||||
"swagger-autogen": "^2.17.2",
|
||||
"swagger-jsdoc": "^6.1.0",
|
||||
"swagger-ui-express": "^4.3.0",
|
||||
"underscore": "^1.8.3",
|
||||
"winston": "^2.3.1",
|
||||
"winston-papertrail": "^1.0.4"
|
||||
|
||||
@@ -1,14 +1,151 @@
|
||||
const express = require('express');
|
||||
const logger = require('./app/logger');
|
||||
const app = express();
|
||||
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, function() {
|
||||
app.listen(port, "0.0.0.0", function() {
|
||||
logger.info('***** Server started on port: ' + port + ' *****');
|
||||
});
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
const swaggerAutogen = require('swagger-autogen')();
|
||||
|
||||
const outputFile = './swagger.json';
|
||||
const endpointsFiles = ['./api/routes.js']
|
||||
|
||||
swaggerAutogen(outputFile, endpointsFiles).then(() => {
|
||||
require('./server.js')
|
||||
})
|
||||
Reference in New Issue
Block a user