@@ -7,7 +7,7 @@ const serialize = require("serialize-javascript");
77import filesToParts from "./io/filesToParts" ;
88
99const app = express ( )
10- const port = 5000
10+ const port = 5050
1111const addr = "localhost"
1212
1313app . use ( express . json ( ) ) ;
@@ -40,7 +40,14 @@ app.post('/Run', async (req, res) => {
4040 console . log ( 'run url=' + url + ' top=' + top_level + ' hostAddr=' + hostAddr )
4141 try {
4242 // Get SBOL file content string
43- const csv = await getFileData ( url ) ;
43+ let csv ;
44+ if ( req . body . token ) {
45+ csv = await getFileData ( url , req . body . token ) ;
46+ }
47+ else {
48+ csv = await getFileData ( url ) ;
49+ }
50+
4451 // parse SBOL file to get data for sequence view rendering
4552 const {
4653 displayList,
@@ -86,9 +93,17 @@ app.post('/Run', async (req, res) => {
8693 }
8794} )
8895
89- function getFileData ( url ) {
96+ function getFileData ( url , token = null ) {
9097 return new Promise ( ( resolve , reject ) => {
91- request . get ( url , function ( error , response , body ) {
98+ const options = {
99+ url : url ,
100+ headers : { }
101+ } ;
102+ if ( token ) {
103+ options . headers [ 'X-authorization' ] = token ;
104+ console . log ( 'getFileData with token' )
105+ }
106+ request . get ( options , function ( error , response , body ) {
92107 if ( ! error && response . statusCode == 200 ) {
93108 return resolve ( body ) ;
94109 } else {
0 commit comments