Skip to content

Commit

Permalink
registries discover with local SHARE
Browse files Browse the repository at this point in the history
use existing environment variables instead of hard-coded URLs
    SHARE_BASE_URL
    SHARE_API_URL
    SHARE_SEARCH_URL
  • Loading branch information
aaxelb committed Jul 11, 2024
1 parent 6896a26 commit 13544cf
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 17 deletions.
7 changes: 0 additions & 7 deletions lib/collections/addon/components/discover-page/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { camelize } from '@ember/string';
import { waitFor } from '@ember/test-waiters';
import { keepLatestTask, timeout } from 'ember-concurrency';
import { taskFor } from 'ember-concurrency-ts';
import config from 'ember-osf-web/config/environment';
import Media from 'ember-responsive';

import { layout } from 'ember-osf-web/decorators/component';
Expand Down Expand Up @@ -226,12 +225,6 @@ export default class DiscoverPage extends Component {
return this.totalPages < maxPages ? this.totalPages : maxPages;
}

@computed('currentUser.sessionKey')
get searchUrl() {
// Pulls SHARE search url from config file.
return `${config.OSF.shareSearchUrl}?preference=${this.currentUser.sessionKey}`;
}

// Total pages of search results
@computed('numberOfResults', 'size')
get totalPages(): number {
Expand Down
1 change: 0 additions & 1 deletion lib/collections/config/environment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ declare const config: {
hostAppName: string;
modulePrefix: string;
OSF: {
shareSearchUrl: string;
url: string;
},
whiteListedProviders: string[];
Expand Down
1 change: 0 additions & 1 deletion lib/collections/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module.exports = function(environment) {
hostAppName: 'collections',
modulePrefix: 'collections',
OSF: {
shareSearchUrl: 'https://share.osf.io/api/v2/search/creativeworks/_search',
url: 'http://localhost:5000/',
},
whiteListedProviders: [
Expand Down
4 changes: 2 additions & 2 deletions lib/registries/addon/services/share-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default class ShareSearch extends Search {
osfProviders: SourceDescriptor[] = [];

url(): string {
return `${config.shareSearchBaseURL}/creativeworks/_search`;
return config.shareSearchUrl;
}

extractTotal(response: any): number {
Expand Down Expand Up @@ -201,7 +201,7 @@ export default class ShareSearch extends Search {
let mainLink: string | undefined;
const infoLinks: Array<{ type: string, uri: string }> = [];
const hyperLinks: string[] = [
`${config.shareBaseURL}/${r._source.type.replace(/ /g, '')}/${r._id}`,
`${config.shareBaseUrl}/${r._source.type.replace(/ /g, '')}/${r._id}`,
];

for (const identifier of (r._source.identifiers as string[])) {
Expand Down
4 changes: 2 additions & 2 deletions lib/registries/config/environment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ declare const config: {
hostAppName: string;
indexPageRegistrationIds: string[];
modulePrefix: string;
shareBaseURL: string;
shareSearchBaseURL: string;
shareBaseUrl: string;
shareSearchUrl: string;
externalRegistries: Array<{
name: string;
https: boolean;
Expand Down
4 changes: 2 additions & 2 deletions lib/registries/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ module.exports = function(environment) {
'ember-cli-mirage': projectConfig['ember-cli-mirage'],

// Engine specific settings
shareBaseURL: 'https://share.osf.io',
shareSearchBaseURL: 'https://share.osf.io/api/v2/search',
shareBaseUrl: projectConfig.OSF.shareBaseUrl,
shareSearchUrl: projectConfig.OSF.shareSearchUrl,
indexPageRegistrationIds: ['6tsnj', 'aurjt', 'e94t8', '2tpy9', '2ds52'],
externalRegistries: [{
https: true,
Expand Down
5 changes: 3 additions & 2 deletions mirage/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ import * as wb from './views/wb';

const { OSF: { addonServiceUrl, apiUrl, shareBaseUrl, url: osfUrl } } = config;


export default function(this: Server) {
this.passthrough(); // pass through all requests on currrent domain
this.passthrough('https://api.crossref.org/*');

// SHARE-powered registration discover endpoint
this.urlPrefix = 'https://share.osf.io';
// SHARE search
this.urlPrefix = shareBaseUrl;
this.namespace = '/api/v2/';
this.post('/search/creativeworks/_search', shareSearch);

Expand Down

0 comments on commit 13544cf

Please sign in to comment.