Skip to content

Commit

Permalink
new test with Staging RW API
Browse files Browse the repository at this point in the history
  • Loading branch information
willian-viana committed Nov 9, 2023
1 parent cac9acc commit 9c426db
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
6 changes: 4 additions & 2 deletions pages/api/gfw/[...params].js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import httpProxyMiddleware from 'next-http-proxy-middleware';

import { GFW_API } from 'utils/apis';
import { GFW_API, GFW_STAGING_API } from 'utils/apis';
import { PROXIES } from 'utils/proxies';

const ENVIRONMENT = process.env.NEXT_PUBLIC_FEATURE_ENV;

const GFW_API_KEY = process.env.NEXT_PUBLIC_GFW_API_KEY;

// We never use the `staging-api.resourcewatch.org`
const GFW_API_URL = GFW_API;
const GFW_API_URL = ENVIRONMENT === 'staging' ? GFW_STAGING_API : GFW_API;

// https://github.com/stegano/next-http-proxy-middleware/issues/32#issuecomment-1031015850
export const config = {
Expand Down
11 changes: 6 additions & 5 deletions services/datasets.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { rwRequest, dataRequest } from 'utils/request';
import { dataRequest } from 'utils/request';
import axios from 'axios';

const environmentString = () => {
const env = process.env.NEXT_PUBLIC_FEATURE_ENV;
Expand All @@ -13,9 +14,9 @@ const environmentString = () => {
};

export const getDatasets = () =>
rwRequest
axios
.get(
`/dataset?application=gfw&includes=metadata,vocabulary,layer&published=true&page[size]=9999&env=${environmentString()}${
`https://api.resourcewatch.org/dataset?application=gfw&includes=metadata,vocabulary,layer&published=true&page[size]=9999&env=${environmentString()}${
environmentString() === 'staging'
? `&filterIncludesByEnv=true&refresh=${new Date()}`
: ''
Expand All @@ -24,8 +25,8 @@ export const getDatasets = () =>
.then((res) => res?.data);

export const getDatasetMeta = () =>
rwRequest
.get('glad-alerts/latest/')
axios
.get('https://api.resourcewatch.org/glad-alerts/latest/')
.then((res) => res?.data)
.then((data) => {
const latestDate = data?.data[0]?.attributes?.date;
Expand Down
7 changes: 3 additions & 4 deletions utils/apis.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// GFW API
export const GFW_API = 'https://staging-api.resourcewatch.org';
export const GFW_API = 'https://api.resourcewatch.org';
export const GFW_STAGING_API = 'https://staging-api.resourcewatch.org';

// GFW METADATA API
export const GFW_METADATA_API =
'https://staging-api.resourcewatch.org/v1/gfw-metadata';
export const GFW_METADATA_API = 'https://api.resourcewatch.org/v1/gfw-metadata';
export const GFW_STAGING_METADATA_API =
'https://staging-api.resourcewatch.org/v1/gfw-metadata';

Expand All @@ -14,7 +13,7 @@ export const GFW_STAGING_DATA_API =
'https://staging-data-api.globalforestwatch.org';

// RESOURCE WATCH API
export const RESOURCE_WATCH_API = 'https://staging-api.resourcewatch.org/v1';
export const RESOURCE_WATCH_API = 'https://api.resourcewatch.org/v1';
export const RESOURCE_WATCH_STAGING_API =
'https://staging-api.resourcewatch.org/v1';

Expand Down

0 comments on commit 9c426db

Please sign in to comment.