Skip to content

Commit

Permalink
Merge pull request #138 from DiSSCo/ChangeAPIEndpointRouteOrder
Browse files Browse the repository at this point in the history
Change API endpoint routes to have v1 after the first route specifica…
  • Loading branch information
samleeflang authored Dec 9, 2024
2 parents e23e29e + 2580247 commit 97d9864
Show file tree
Hide file tree
Showing 28 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/api/annotation/DeleteAnnotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const DeleteAnnotation = async ({ annotationId }: { annotationId: string }): Pro
try {
const result = await axios({
method: 'delete',
url: `annotation/${annotationId.replace(RetrieveEnvVariable('HANDLE_URL'), '')}`,
url: `annotation/v1/${annotationId.replace(RetrieveEnvVariable('HANDLE_URL'), '')}`,
responseType: 'json',
headers: {
'Content-type': 'application/json',
Expand Down
2 changes: 1 addition & 1 deletion src/api/annotation/GetCreatorAnnotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const GetCreatorAnnotations = async () => {
try {
const result = await axios({
method: 'get',
url: `annotation/creator`,
url: `annotation/v1/creator`,
responseType: 'json',
headers: {
'Content-type': 'application/json',
Expand Down
2 changes: 1 addition & 1 deletion src/api/annotation/InsertAnnotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const InsertAnnotation = async ({ newAnnotation }: { newAnnotation: AnnotationTe
try {
const result = await axios({
method: 'post',
url: 'annotation',
url: 'annotation/v1',
responseType: 'json',
data: postAnnotation,
headers: {
Expand Down
2 changes: 1 addition & 1 deletion src/api/annotation/PatchAnnotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const PatchAnnotation = async ({ annotationId, updatedAnnotation }: { annotation
try {
const result = await axios({
method: 'patch',
url: `annotation/${annotationId.replace(RetrieveEnvVariable('HANDLE_URL'), '')}`,
url: `annotation/v1/${annotationId.replace(RetrieveEnvVariable('HANDLE_URL'), '')}`,
responseType: 'json',
data: patchAnnotation,
headers: {
Expand Down
2 changes: 1 addition & 1 deletion src/api/dataExport/ScheduleDataExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const ScheduleDataExport = async ({ targetType, exportType, dataExportKey, dataE
try {
await axios({
method: 'post',
url: `data-export/schedule`,
url: `data-export/v1/schedule`,
responseType: 'json',
data: exportJob,
headers: {
Expand Down
2 changes: 1 addition & 1 deletion src/api/digitalMedia/GetDigitalMedia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const GetDigitalMedia = async({ handle, version } : { handle: string, version?:
try {
const result = await axios({
method: 'get',
url: `digital-media/${handle}${version ? '/' + version : ''}`,
url: `digital-media/v1/${handle}${version ? '/' + version : ''}`,
responseType: 'json'
});

Expand Down
2 changes: 1 addition & 1 deletion src/api/digitalMedia/GetDigitalMediaAnnotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const GetDigitalMediaAnnotations = async({ handle } : { handle: string }) => {
try {
const result = await axios({
method: 'get',
url: `digital-media/${handle}/annotations`,
url: `digital-media/v1/${handle}/annotations`,
responseType: 'json'
});

Expand Down
2 changes: 1 addition & 1 deletion src/api/digitalMedia/GetDigitalMediaMas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const GetDigitalMediaMas = async ({ handle }: { handle: string }) => {
const digitalMediaMas: MachineAnnotationService[] = [];

if (handle) {
const endPoint: string = `/digital-media/${handle}/mas`;
const endPoint: string = `/digital-media/v1/${handle}/mas`;

try {
const result = await axios({
Expand Down
2 changes: 1 addition & 1 deletion src/api/digitalMedia/GetDigitalMediaMasJobRecords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const GetDigitalMediaMasJobRecords = async ({ handle, pageSize, pageNumber, stat
};

if (handle) {
const endPoint: string = `/digital-media/${handle.replace(RetrieveEnvVariable('DOI_URL'), '')}/mjr`;
const endPoint: string = `/digital-media/v1/${handle.replace(RetrieveEnvVariable('DOI_URL'), '')}/mjr`;

try {
const result = await axios({
Expand Down
2 changes: 1 addition & 1 deletion src/api/digitalMedia/GetDigitalMediaVersions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import axios from 'axios';
const GetDigitalMediaVersions = async ({ handle }: { handle: string }) => {
let digitalMediaVersions = [] as number[];

const endPoint: string = `digital-media/${handle}/versions`;
const endPoint: string = `digital-media/v1/${handle}/versions`;

try {
const result = await axios({
Expand Down
2 changes: 1 addition & 1 deletion src/api/digitalMedia/ScheduleDigitalMediaMas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const ScheduleDigitalMediaMas = async ({ handle, masList }: { handle: string, ma
try {
const result = await axios({
method: 'post',
url: `digital-media/${handle.replace(RetrieveEnvVariable('DOI_URL'), '')}/mas`,
url: `digital-media/v1/${handle.replace(RetrieveEnvVariable('DOI_URL'), '')}/mas`,
responseType: 'json',
data: masRecord,
headers: {
Expand Down
4 changes: 2 additions & 2 deletions src/api/digitalSpecimen/GetDigitalSpecimen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ const GetDigitalSpecimen = async({ handle, version } : { handle: string, version
let endPoint: string;

if (version) {
endPoint = `digital-specimen/${handle}/${version}`;
endPoint = `digital-specimen/v1/${handle}/${version}`;
} else {
endPoint = `digital-specimen/${handle}`;
endPoint = `digital-specimen/v1/${handle}`;
}

try {
Expand Down
2 changes: 1 addition & 1 deletion src/api/digitalSpecimen/GetDigitalSpecimenAggregations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const GetDigitalSpecimenAggregations = async ({ searchFilters }: { searchFilters
try {
const result = await axios({
method: 'get',
url: `/digital-specimen/aggregation${filters}`,
url: `/digital-specimen/v1/aggregation${filters}`,
responseType: 'json'
});

Expand Down
2 changes: 1 addition & 1 deletion src/api/digitalSpecimen/GetDigitalSpecimenAnnotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const GetDigitalSpecimenAnnotations = async({ handle } : { handle: string }) =>
try {
const result = await axios({
method: 'get',
url: `digital-specimen/${handle}/annotations`,
url: `digital-specimen/v1/${handle}/annotations`,
responseType: 'json'
});

Expand Down
2 changes: 1 addition & 1 deletion src/api/digitalSpecimen/GetDigitalSpecimenDigitalMedia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const GetDigitalSpecimenDigitalMedia = async({ handle } : { handle: string }) =>
try {
const result = await axios({
method: 'get',
url: `digital-specimen/${handle}/digital-media`,
url: `digital-specimen/v1/${handle}/digital-media`,
responseType: 'json'
});

Expand Down
2 changes: 1 addition & 1 deletion src/api/digitalSpecimen/GetDigitalSpecimenDisciplines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const GetDigitalSpecimenDisciplines = async () => {
try {
const result = await axios({
method: 'get',
url: '/digital-specimen/discipline',
url: '/digital-specimen/v1/discipline',
responseType: 'json'
});

Expand Down
2 changes: 1 addition & 1 deletion src/api/digitalSpecimen/GetDigitalSpecimenMas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const GetDigitalSpecimenMas = async ({ handle }: { handle: string }) => {
const digitalSpecimenMas: MachineAnnotationService[] = [];

if (handle) {
const endPoint: string = `/digital-specimen/${handle}/mas`;
const endPoint: string = `/digital-specimen/v1/${handle}/mas`;

try {
const result = await axios({
Expand Down
2 changes: 1 addition & 1 deletion src/api/digitalSpecimen/GetDigitalSpecimenMasJobRecords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const GetDigitalSpecimenMasJobRecords = async ({ handle, pageSize, pageNumber, s
};

if (handle) {
const endPoint: string = `/digital-specimen/${handle.replace(RetrieveEnvVariable('DOI_URL'), '')}/mjr`;
const endPoint: string = `/digital-specimen/v1/${handle.replace(RetrieveEnvVariable('DOI_URL'), '')}/mjr`;

try {
const result = await axios({
Expand Down
2 changes: 1 addition & 1 deletion src/api/digitalSpecimen/GetDigitalSpecimenOriginalData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const GetDigitalSpecimenOriginalData = async ({ digitalSpecimenId }: { digitalSp
try {
const result = await axios({
method: 'get',
url: `/digital-specimen/${digitalSpecimenId}/original-data`,
url: `/digital-specimen/v1/${digitalSpecimenId}/original-data`,
responseType: 'json'
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const GetDigitalSpecimenSearchTermAggregations = async ({ searchFilterName, valu
try {
const result = await axios({
method: 'get',
url: "/digital-specimen/searchTermValue",
url: "/digital-specimen/v1/searchTermValue",
params: {
term: searchFilterName,
value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const GetDigitalSpecimenTaxonomyAggregations = async ({ searchFilters }: { searc
try {
const result = await axios({
method: 'get',
url: `/digital-specimen/taxonomy/aggregation${filters}`,
url: `/digital-specimen/v1/taxonomy/aggregation${filters}`,
responseType: 'json'
});

Expand Down
2 changes: 1 addition & 1 deletion src/api/digitalSpecimen/GetDigitalSpecimenVersions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import axios from 'axios';
const GetDigitalSpecimenVersions = async ({ handle }: { handle: string }) => {
let digitalSpecimenVersions = [] as number[];

const endPoint: string = `digital-specimen/${handle}/versions`;
const endPoint: string = `digital-specimen/v1/${handle}/versions`;

try {
const result = await axios({
Expand Down
2 changes: 1 addition & 1 deletion src/api/digitalSpecimen/GetDigitalSpecimens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const GetDigitalSpecimens = async ({ pageSize, pageNumber, searchFilters }:
try {
const result = await axios({
method: 'get',
url: `digital-specimen/search${filters}`,
url: `digital-specimen/v1/search${filters}`,
params: {
pageSize,
pageNumber: pageNumber ?? 1
Expand Down
2 changes: 1 addition & 1 deletion src/api/digitalSpecimen/ScheduleDigitalSpecimenMas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const ScheduleDigitalSpecimenMas = async ({ handle, masList }: { handle: string,
try {
const result = await axios({
method: 'post',
url: `digital-specimen/${handle.replace(RetrieveEnvVariable('DOI_URL'), '')}/mas`,
url: `digital-specimen/v1/${handle.replace(RetrieveEnvVariable('DOI_URL'), '')}/mas`,
responseType: 'json',
data: masRecord,
headers: {
Expand Down
2 changes: 1 addition & 1 deletion src/api/masJobRecord/GetCreatorMasJobRecords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const GetCreatorMasJobRecords = async () => {
try {
const result = await axios({
method: 'get',
url: `mjr/creator/${KeycloakService.GetParsedToken()?.orcid}`,
url: `mjr/v1/creator/${KeycloakService.GetParsedToken()?.orcid}`,
responseType: 'json',
headers: {
'Content-type': 'application/json',
Expand Down
2 changes: 1 addition & 1 deletion src/api/sourceSystem/GetSourceSystems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { JSONResultArray } from "app/Types";
const GetSourceSystems = async () => {
const sourceSystems = <SourceSystem[]>[];

const endPoint = "/source-system";
const endPoint = "/source-system/v1";

try {
const result = await axios({
Expand Down
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import Loading from 'components/Loading';


/* Define axios base url */
axios.defaults.baseURL = `${window.location.protocol}//${window.location.hostname}${window.location.port ? ':' + window.location.port : ''}/api/v1`;
axios.defaults.baseURL = `${window.location.protocol}//${window.location.hostname}${window.location.port ? ':' + window.location.port : ''}/api`;


const root = ReactDOM.createRoot(
Expand Down
10 changes: 5 additions & 5 deletions src/tests/mock/APIMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ import SpecimenDisciplineMock from 'tests/mock/digitalSpecimen/specimenDisciplin
*/
const Server = setupServer(
/* Get Digital Specimen by ID */
http.get('/digital-specimen/20.5000.1025/DW0-BNT-FM0', () => {
http.get('/digital-specimen/v1/20.5000.1025/DW0-BNT-FM0', () => {
return HttpResponse.json(DigitalSpecimenMock);
}),
/* Get Digital Specimen's Annotations by ID */
http.get('/digital-specimen/20.5000.1025/DW0-BNT-FM0/annotations', () => {
http.get('/digital-specimen/v1/20.5000.1025/DW0-BNT-FM0/annotations', () => {
return HttpResponse.json(SpecimenAnnotationsMock);
}),
/* Get Digital Specimen, Digital Media */
http.get('/digital-specimen/20.5000.1025/DW0-BNT-FM0/digital-media', () => {
http.get('/digital-specimen/v1/20.5000.1025/DW0-BNT-FM0/digital-media', () => {
return HttpResponse.json(SpecimenDigitalMediaMock);
}),
/* Get Digital Specimen's verions by id */
http.get('/digital-specimen/20.5000.1025/DW0-BNT-FM0/versions', () => {
http.get('/digital-specimen/v1/20.5000.1025/DW0-BNT-FM0/versions', () => {
return HttpResponse.json(SpecimenVersionsMock);
}),
/* Get Topic Disciplines numbers */
http.get('/digital-specimen/discipline', () => {
http.get('/digital-specimen/v1/discipline', () => {
return HttpResponse.json(SpecimenDisciplineMock);
})
);
Expand Down

0 comments on commit 97d9864

Please sign in to comment.