Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

[SERVICE-418] Have service deploy with empty app directory #31

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/provider/AppDirectory.ts
Expand Up @@ -14,7 +14,7 @@ export class AppDirectory {
* This URL is currently hard-coded but will eventually be defined in a place
* that can be controlled by the desktop owner.
*/
private static URL: string = 'http://localhost:3923/provider/app-directory.json';
private static URL: string = 'http://localhost:3923/provider/sample-app-directory.json';

/**
* If cached application list is older than this duration, the next request to
Expand Down Expand Up @@ -42,6 +42,10 @@ export class AppDirectory {
}

private async request(): Promise<Application[]> {
// If using the demo app directory in production, return an empty array.
if (process.env.NODE_ENV === 'production' && AppDirectory.URL === 'http://localhost:3923/provider/sample-app-directory.json') {
return [];
}
return new Promise((resolve: (value: Application[]) => void, reject: (reason: Error) => void): void => {
const xhr: XMLHttpRequest = new XMLHttpRequest();
let response: Application[];
Expand Down
4 changes: 2 additions & 2 deletions test/runner.js
Expand Up @@ -48,8 +48,8 @@ async function serve() {
const app = express();

// Sneakily return the test directory instead of the default one
app.get('/provider/app-directory.json', (req, res) => {
let testDirectory = JSON.parse(fs.readFileSync(path.join('res', 'test','app-directory.json')));
app.get('/provider/sample-app-directory.json', (req, res) => {
let testDirectory = JSON.parse(fs.readFileSync(path.join('res', 'test','sample-app-directory.json')));

res.contentType('application/json');
res.json(testDirectory);
Expand Down