Skip to content

Commit

Permalink
:q
Browse files Browse the repository at this point in the history
  • Loading branch information
IKCAP committed Jan 30, 2020
1 parent d2867a1 commit 4789d93
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
"express": "^4.17.1",
"express-openapi": "^5.0.0",
"express-openapi-validator": "^2.14.2",
"fetch": "^1.1.0",
"firebase-admin": "^8.7.0",
"fs-extra": "^8.1.0",
"js-yaml": "^3.13.1",
"request": "^2.88.0",
"request-promise-native": "^1.0.8",
"swagger-ui-express": "^4.1.3",
"yauzl": "^2.10.0"
},
"devDependencies": {
Expand All @@ -47,6 +49,7 @@
"@types/js-yaml": "^3.12.1",
"@types/morgan": "^1.7.37",
"@types/node": "^12.12.7",
"@types/swagger-ui-express": "^4.1.1",
"@types/yauzl": "^2.9.1",
"body-parser": "^1.19.0",
"cookie-parser": "^1.4.4",
Expand Down
5 changes: 3 additions & 2 deletions src/api/api-doc.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const apiDoc = {
swagger: '2.0',
basePath: '/v1',
host: 'ensemble.mint.isi.edu',
info: {
title: 'A getting started API.',
version: '1.0.0'
title: 'Ensemble Manager API',
version: '2.0.0'
},
definitions: {
ModelThread: {
Expand Down
16 changes: 15 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import bodyParser from "body-parser";
import express from "express";
import path from "path";
import cors from "cors";
import swaggerUi from "swagger-ui-express";

import v1ApiDoc from './api/api-doc';
import v1ExecutionsService from './api/api-v1/services/executionsService';
Expand All @@ -11,9 +12,11 @@ import v1LogsService from './api/api-v1/services/logsService';
import v1ThreadsService from './api/api-v1/services/threadsService';

import { initialize } from "express-openapi";
import { getResource } from "./classes/wings/xhr-requests";

const app = express();
const port = 3000; // default port to listen
const version = 'v1';

app.use(bodyParser.json());
app.use(cors());
Expand All @@ -37,4 +40,15 @@ app.use(((err, req, res, next) => {
res.status(err.status).json(err);
}) as express.ErrorRequestHandler);

app.listen(port);
app.listen(port, () => {
getResource({
url: 'http://localhost:' + port + '/' + version + '/api-docs',
onError: () => {},
onLoad: (resp:any) => {
var apidoc = JSON.parse(resp.target.responseText);
app.use('/' + version + '/ui', swaggerUi.serve, swaggerUi.setup(apidoc));
}
})
});


0 comments on commit 4789d93

Please # to comment.