This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: expose router for serving user interface (#419)
* feat: expose router for serving user interface * fix: upgrade UI package to version for /ui path * style: update README.md to reflect UI changes
- Loading branch information
1 parent
e91eacc
commit 94864b9
Showing
8 changed files
with
71 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
import * as express from 'express' | ||
import * as clUI from '@conversationlearner/ui' | ||
|
||
// console.log(`@conversationlearner/ui directory path: `, clUI.directoryPath) | ||
// console.log(`@conversationlearner/ui default file path: `, clUI.defaultFilePath) | ||
|
||
const router = express.Router({ caseSensitive: false }) | ||
router.use('/ui', express.static(clUI.directoryPath)); | ||
router.get('/ui/*', (_, res) => { | ||
res.sendFile(clUI.defaultFilePath) | ||
}) | ||
|
||
export default router |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
/** | ||
* This is just a convenience for @conversationlearner/sdk developers to test the UI | ||
*/ | ||
import uiRouter from './uiRouter' | ||
import * as express from 'express' | ||
|
||
const app = express() | ||
app.use(uiRouter) | ||
|
||
const port = 5053 | ||
const listener = app.listen(port, () => | ||
console.log(`Navigate to http://localhost:${listener.address().port}/ui to view Conversation Learner administration application.`) | ||
).on('error', (error: NodeJS.ErrnoException) => { | ||
if (error.code === 'EADDRINUSE') { | ||
console.log(`ERROR: The UI is already running or the port (${port}) is in use by another process`) | ||
return | ||
} | ||
|
||
throw error | ||
}); |