Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
fix(examples): fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
fostyfost committed Oct 4, 2021
1 parent 9ed7157 commit 22ff44d
Show file tree
Hide file tree
Showing 30 changed files with 40 additions and 34 deletions.
7 changes: 3 additions & 4 deletions examples/example-next-gip/eggs/active-post/saga.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { call, put, select, takeLatest } from 'redux-saga/effects'

import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'
import { getServerHost } from '@/utils/get-server-host'

import type { ActivePostPublicAction } from './action-creators'
import { ActivePostReducerAction } from './action-creators'
Expand All @@ -21,9 +22,7 @@ function* loadActivePostWorker({ payload }: ReturnType<typeof ActivePostPublicAc
try {
const response: ActivePostResponseItem = yield call(
fetchAsJson,
typeof window === 'undefined'
? `http://localhost:${process.env.PORT}/api/posts/${payload}`
: `/api/posts/${payload}`,
typeof window === 'undefined' ? `${getServerHost()}/api/posts/${payload}` : `/api/posts/${payload}`,
)

yield put(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { SearchResponse } from '@/eggs/aviasales/contracts/api-response'
import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'

export const getSearchIdWithApi = (): Promise<SearchResponse> => {
return fetchAsJson('https://front-test.beta.aviasales.ru/search')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { TicketsResponse } from '@/eggs/aviasales/contracts/api-response'
import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'

export const getTicketsWithApi = (searchId: string): Promise<TicketsResponse> => {
return fetchAsJson(`https://front-test.beta.aviasales.ru/tickets?searchId=${searchId}`)
Expand Down
2 changes: 1 addition & 1 deletion examples/example-next-gip/eggs/chuck-norris/saga.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { call, delay, put, select, takeLatest } from 'redux-saga/effects'

import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'

import { ChuckNorrisReducerAction } from './action-creators'
import { ChuckNorrisActionType } from './action-types'
Expand Down
2 changes: 1 addition & 1 deletion examples/example-next-gip/eggs/dog/saga.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { call, put, select, takeLatest } from 'redux-saga/effects'

import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'

import { DogReducerAction } from './action-creators'
import { DogActionType } from './action-types'
Expand Down
2 changes: 1 addition & 1 deletion examples/example-next-gip/eggs/fox/saga.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { call, put, select, takeLatest } from 'redux-saga/effects'

import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'

import { FoxReducerAction } from './action-creators'
import { FoxActionType } from './action-types'
Expand Down
2 changes: 1 addition & 1 deletion examples/example-next-gip/eggs/picsum/saga.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { call, put, select, takeLatest } from 'redux-saga/effects'

import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'

import { PicsumReducerAction } from './action-creators'
import { PicsumActionType } from './action-types'
Expand Down
5 changes: 3 additions & 2 deletions examples/example-next-gip/eggs/posts/saga.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { call, put, select, takeLatest } from 'redux-saga/effects'

import type { PostsResponseItem } from '@/eggs/posts/contracts/api-response'
import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'
import { getServerHost } from '@/utils/get-server-host'

import { PostsReducerAction } from './action-creators'
import { PostsActionType } from './action-types'
Expand All @@ -20,7 +21,7 @@ function* loadPostsWorker() {
try {
const responseItems: PostsResponseItem[] = yield call(
fetchAsJson,
typeof window === 'undefined' ? `http://localhost:${process.env.PORT}/api/posts` : '/api/posts',
typeof window === 'undefined' ? `${getServerHost()}/api/posts` : '/api/posts',
)

yield put(
Expand Down
2 changes: 1 addition & 1 deletion examples/example-next-gip/eggs/users/saga.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { call, put, select, takeLatest } from 'redux-saga/effects'

import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'

import { UsersReducerAction } from './action-creators'
import { UsersActionType } from './action-types'
Expand Down
2 changes: 1 addition & 1 deletion examples/example-next-gip/eggs/xkcd/saga.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { call, put, select, takeLatest } from 'redux-saga/effects'

import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'

import { XkcdReducerAction } from './action-creators'
import { XkcdActionType } from './action-types'
Expand Down
2 changes: 1 addition & 1 deletion examples/example-next-gip/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"dev": "cross-env PORT=3020 next",
"build": "next build",
"start": "cross-env PORT=3001 next start",
"start": "cross-env PORT=3021 next start",
"analyze": "cross-env ANALYZE=true yarn build",
"lint": "next lint",
"type-check": "tsc --pretty --noEmit",
Expand Down
2 changes: 1 addition & 1 deletion examples/example-next-gip/pages/api/posts/[id].ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { NextApiHandler, NextApiResponse } from 'next'

import type { PostsResponseItem } from '@/eggs/posts/contracts/api-response'
import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'

const sendError = (res: NextApiResponse, id: string): void => {
res.status(404).json({ message: `Post with id ${id} not found.` })
Expand Down
2 changes: 1 addition & 1 deletion examples/example-next-gip/pages/api/posts/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { NextApiHandler } from 'next'

import type { PostsResponseItem } from '@/eggs/posts/contracts/api-response'
import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'

const handler: NextApiHandler = async (_, res) => {
try {
Expand Down
3 changes: 3 additions & 0 deletions examples/example-next-gip/utils/get-server-host.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const getServerHost = () => {
return `http://localhost${process.env.PORT ? `:${process.env.PORT}` : ''}`
}
7 changes: 3 additions & 4 deletions examples/example-next/eggs/active-post/saga.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { call, put, select, takeLatest } from 'redux-saga/effects'

import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'
import { getServerHost } from '@/utils/get-server-host'

import type { ActivePostPublicAction } from './action-creators'
import { ActivePostReducerAction } from './action-creators'
Expand All @@ -21,9 +22,7 @@ function* loadActivePostWorker({ payload }: ReturnType<typeof ActivePostPublicAc
try {
const response: ActivePostResponseItem = yield call(
fetchAsJson,
typeof window === 'undefined'
? `http://localhost:${process.env.PORT}/api/posts/${payload}`
: `/api/posts/${payload}`,
typeof window === 'undefined' ? `${getServerHost()}/api/posts/${payload}` : `/api/posts/${payload}`,
)

yield put(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { SearchResponse } from '@/eggs/aviasales/contracts/api-response'
import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'

export const getSearchIdWithApi = (): Promise<SearchResponse> => {
return fetchAsJson('https://front-test.beta.aviasales.ru/search')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { TicketsResponse } from '@/eggs/aviasales/contracts/api-response'
import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'

export const getTicketsWithApi = (searchId: string): Promise<TicketsResponse> => {
return fetchAsJson(`https://front-test.beta.aviasales.ru/tickets?searchId=${searchId}`)
Expand Down
2 changes: 1 addition & 1 deletion examples/example-next/eggs/chuck-norris/saga.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { call, delay, put, select, takeLatest } from 'redux-saga/effects'

import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'

import { ChuckNorrisReducerAction } from './action-creators'
import { ChuckNorrisActionType } from './action-types'
Expand Down
2 changes: 1 addition & 1 deletion examples/example-next/eggs/dog/saga.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { call, put, select, takeLatest } from 'redux-saga/effects'

import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'

import { DogReducerAction } from './action-creators'
import { DogActionType } from './action-types'
Expand Down
2 changes: 1 addition & 1 deletion examples/example-next/eggs/fox/saga.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { call, put, select, takeLatest } from 'redux-saga/effects'

import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'

import { FoxReducerAction } from './action-creators'
import { FoxActionType } from './action-types'
Expand Down
2 changes: 1 addition & 1 deletion examples/example-next/eggs/picsum/saga.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { call, put, select, takeLatest } from 'redux-saga/effects'

import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'

import { PicsumReducerAction } from './action-creators'
import { PicsumActionType } from './action-types'
Expand Down
5 changes: 3 additions & 2 deletions examples/example-next/eggs/posts/saga.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { call, put, select, takeLatest } from 'redux-saga/effects'

import type { PostsResponseItem } from '@/eggs/posts/contracts/api-response'
import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'
import { getServerHost } from '@/utils/get-server-host'

import { PostsReducerAction } from './action-creators'
import { PostsActionType } from './action-types'
Expand All @@ -20,7 +21,7 @@ function* loadPostsWorker() {
try {
const responseItems: PostsResponseItem[] = yield call(
fetchAsJson,
typeof window === 'undefined' ? `http://localhost:${process.env.PORT}/api/posts` : '/api/posts',
typeof window === 'undefined' ? `${getServerHost()}/api/posts` : '/api/posts',
)

yield put(
Expand Down
2 changes: 1 addition & 1 deletion examples/example-next/eggs/users/saga.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { call, put, select, takeLatest } from 'redux-saga/effects'

import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'

import { UsersReducerAction } from './action-creators'
import { UsersActionType } from './action-types'
Expand Down
2 changes: 1 addition & 1 deletion examples/example-next/eggs/xkcd/saga.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { call, put, select, takeLatest } from 'redux-saga/effects'

import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'

import { XkcdReducerAction } from './action-creators'
import { XkcdActionType } from './action-types'
Expand Down
2 changes: 1 addition & 1 deletion examples/example-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"dev": "cross-env PORT=3010 next",
"build": "next build",
"start": "cross-env PORT=3001 next start",
"start": "cross-env PORT=3011 next start",
"analyze": "cross-env ANALYZE=true yarn build",
"lint": "next lint",
"type-check": "tsc --pretty --noEmit",
Expand Down
2 changes: 1 addition & 1 deletion examples/example-next/pages/api/posts/[id].ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { NextApiHandler, NextApiResponse } from 'next'

import type { PostsResponseItem } from '@/eggs/posts/contracts/api-response'
import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'

const sendError = (res: NextApiResponse, id: string): void => {
res.status(404).json({ message: `Post with id ${id} not found.` })
Expand Down
2 changes: 1 addition & 1 deletion examples/example-next/pages/api/posts/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { NextApiHandler } from 'next'

import type { PostsResponseItem } from '@/eggs/posts/contracts/api-response'
import { fetchAsJson } from '@/utils/fetchAsJson'
import { fetchAsJson } from '@/utils/fetch-as-json'

const handler: NextApiHandler = async (_, res) => {
try {
Expand Down
3 changes: 3 additions & 0 deletions examples/example-next/utils/get-server-host.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const getServerHost = () => {
return `http://localhost${process.env.PORT ? `:${process.env.PORT}` : ''}`
}

2 comments on commit 22ff44d

@vercel
Copy link

@vercel vercel bot commented on 22ff44d Oct 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

redux-eggs-example-next – ./examples/example-next

redux-eggs-example-next-git-main-fostyfost.vercel.app
redux-eggs-example-next.vercel.app
redux-eggs-example-next-fostyfost.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 22ff44d Oct 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

redux-eggs-example-next-gip – ./examples/example-next-gip

redux-eggs-example-next-gip-fostyfost.vercel.app
redux-eggs-example-next-gip-git-main-fostyfost.vercel.app
redux-eggs-example-next-gip.vercel.app

Please sign in to comment.