Added poetry display on userPage
This commit is contained in:
18
front/src/api/poetry/index.ts
Normal file
18
front/src/api/poetry/index.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { API_URL } from '../../config'
|
||||
import { PoetryResponse, Poetry } from './types'
|
||||
|
||||
const initialPoetry: Poetry = {
|
||||
title: '',
|
||||
text: '',
|
||||
author: '',
|
||||
}
|
||||
|
||||
const composePoetryURL = () => (
|
||||
API_URL + '/poetry?'
|
||||
)
|
||||
|
||||
const processPoetry = (data: PoetryResponse): Poetry => {
|
||||
return data
|
||||
}
|
||||
|
||||
export { initialPoetry, composePoetryURL, processPoetry }
|
23
front/src/api/poetry/types.ts
Normal file
23
front/src/api/poetry/types.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { isObject } from '../../utils/types'
|
||||
|
||||
type PoetryResponse = {
|
||||
title: string,
|
||||
text: string,
|
||||
author: string,
|
||||
}
|
||||
|
||||
const isPoetryResponse = (obj: unknown): obj is PoetryResponse => (
|
||||
isObject(obj, {
|
||||
'title': 'string',
|
||||
'text': 'string',
|
||||
'author': 'string',
|
||||
})
|
||||
)
|
||||
|
||||
type Poetry = PoetryResponse
|
||||
|
||||
const isPoetry = isPoetryResponse
|
||||
|
||||
export type { PoetryResponse, Poetry }
|
||||
|
||||
export { isPoetryResponse, isPoetry }
|
Reference in New Issue
Block a user