Skip to content

Commit

Permalink
Move urls to variables (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
sashachabin authored Sep 19, 2023
1 parent d212959 commit 68abb9a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
5 changes: 3 additions & 2 deletions client/api/articles/articles.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { fetchApi } from 'api/utils/fetch';
import { STRAPI_URL } from 'transport-common/strapi/constants';

export const articlesApi = {
getArticles: () =>
fetchApi('https://transport-cms.ekaterinburg.city/api/articles?fields=slug', {
fetchApi(`${STRAPI_URL}/api/articles?fields=slug`, {
dataField: 'data',
}),
getArticle: (slug: string) =>
fetchApi(
`https://transport-cms.ekaterinburg.city/api/articles?filters[slug][$eq]=${encodeURIComponent(
`${STRAPI_URL}/api/articles?filters[slug][$eq]=${encodeURIComponent(
slug,
)}`,
{ dataField: 'data' },
Expand Down
9 changes: 5 additions & 4 deletions client/api/main-page/main-page.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import { Unit } from 'transport-common/types/masstrans';
import { fetchApi } from 'api/utils/fetch';
import { STRAPI_URL, TRAFFIC_JAMS_URL, TRANSPORT_API_URL } from 'transport-common/strapi/constants';

export const MainPageApi = {
getCards: async () => {
return await fetchApi(
'https://transport-cms.ekaterinburg.city/api/cards/?populate=backgroundImage,backgroundImageHover',
`${STRAPI_URL}/api/cards/?populate=backgroundImage,backgroundImageHover`,
{ dataField: 'data' },
);
},

getTrafficJamsCounter: async () => {
return await fetchApi(
'https://ekb-probki.vercel.app/api',
TRAFFIC_JAMS_URL,
{ dataField: 'score' },
);
},

getA11yTransportCounters: async () => {
const countA11yUnits = async (type) => {
const units = <Unit[]>await fetchApi(
`https://transport.ekaterinburg.city/api/masstrans/${type}`,
`${TRANSPORT_API_URL}/api/masstrans/${type}`,
{ dataField: 'data' }
);
return units
Expand All @@ -35,7 +36,7 @@ export const MainPageApi = {
},

getMarqueeItems: async () => {
return await fetchApi('https://transport-cms.ekaterinburg.city/api/marquees', {
return await fetchApi(`${STRAPI_URL}/api/marquees`, {
dataField: 'data',
});
}
Expand Down
8 changes: 4 additions & 4 deletions client/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import { Html, Head, Main, NextScript } from 'next/document';
import { SITE_URL } from 'transport-common/strapi/constants';

export default function Document() {
const siteTitle = 'Транспорт Екатеринбурга';
const siteUrl = 'https://transport.ekaterinburg.city/';
const siteDescription = 'Всё про транспорт Екатеринбурга. Цена проезда, карта транспорта, расписание маршрутов, статус пробок и правила парковок.';
const ogImage = `${siteUrl}og-preview.jpg`;
const ogImage = `${SITE_URL}/og-preview.jpg`;

return (
<Html lang="ru">
Expand All @@ -14,13 +14,13 @@ export default function Document() {
<meta name="description" content={siteDescription} />

<meta property="og:type" content="website" />
<meta property="og:url" content={siteUrl} />
<meta property="og:url" content={SITE_URL} />
<meta property="og:title" content={siteTitle} />
<meta property="og:description" content={siteDescription} />
<meta property="og:image" content={ogImage} />

<meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:url" content={siteUrl} />
<meta property="twitter:url" content={SITE_URL} />
<meta property="twitter:title" content={siteTitle} />
<meta property="twitter:description" content={siteDescription} />
<meta property="twitter:image" content={ogImage} />
Expand Down
5 changes: 3 additions & 2 deletions client/pages/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import React from 'react';
import Head from 'next/head';

import { Map as MapComponent } from 'components/Map';
import { STRAPI_URL, TILE_SERVER_URL } from 'transport-common/strapi/constants';

export default function Map() {
return (
<>
<Head>
<title>Карта транспорта Екатеринбурга</title>
<link rel="preconnect" href="https://tiles.ekaterinburg.city" />
<link rel="preconnect" href="https://transport-cms.ekaterinburg.city" />
<link rel="preconnect" href={TILE_SERVER_URL} />
<link rel="preconnect" href={STRAPI_URL} />
</Head>

<MapComponent />
Expand Down
5 changes: 5 additions & 0 deletions common/strapi/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
export const SITE_URL = 'https://transport.ekaterinburg.city';
export const STRAPI_URL = 'https://transport-cms.ekaterinburg.city';
export const TRANSPORT_API_URL = 'https://transport-api.ekaterinburg.city';
export const TILE_SERVER_URL = 'https://tiles.ekaterinburg.city';
export const TRAFFIC_JAMS_URL = 'https://ekb-probki.vercel.app/api';

// email of Authenticated User
export const EMAIL = process.env.STRAPI_EMAIL;
// password of Authenticated User
Expand Down
2 changes: 1 addition & 1 deletion vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"installCommand": "pnpm -r install",
"outputDirectory": "client/.next",
"framework": "nextjs",
"rewrites": [{ "source": "/api/:match*", "destination": "https://transport-api-test.na4u.ru/api/:match*" }]
"rewrites": [{ "source": "/api/:match*", "destination": "https://transport-api.ekaterinburg.city/api/:match*" }]
}

0 comments on commit 68abb9a

Please sign in to comment.