Update oki-api with qs and new routes
This commit is contained in:
+118
-36
@@ -12,18 +12,33 @@ const readAxiosInstance = axios.create({
|
||||
})
|
||||
|
||||
export async function jwennTeksEpiSlug(slug) {
|
||||
const response = await axios.get(`${OKI_API}/teks?slug=${slug}&_where[published_at_null]=false`)
|
||||
return response.data[0]
|
||||
const query = qs.stringify({
|
||||
populate: ['artistes', 'couverture'],
|
||||
filters: {
|
||||
slug: {
|
||||
$eq: slug
|
||||
}
|
||||
}
|
||||
}, {
|
||||
encodeValuesOnly: true
|
||||
})
|
||||
const {data} = await readAxiosInstance.get(`${OKI_API}/paroles?${query}`)
|
||||
return data.data[0]
|
||||
}
|
||||
|
||||
export async function jwennAwtisEpiSlug(slug) {
|
||||
const response = await axios.get(`${OKI_API}/awtis?slug=${slug}&_where[published_at_null]=false`)
|
||||
return response.data[0]
|
||||
const query = qs.stringify({
|
||||
populate: ['paroles', 'photo'],
|
||||
filters: {
|
||||
slug: {
|
||||
$eq: slug
|
||||
}
|
||||
|
||||
export async function jwennAwtisKantite() {
|
||||
const response = await axios.get(`${OKI_API}/awtis/count?_where[published_at_null]=false`)
|
||||
return response.data
|
||||
}
|
||||
}, {
|
||||
encodeValuesOnly: true
|
||||
})
|
||||
const {data} = await readAxiosInstance.get(`${OKI_API}/artistes?${query}`)
|
||||
return data.data[0]
|
||||
}
|
||||
|
||||
export async function jwennTeksKantite() {
|
||||
@@ -33,25 +48,54 @@ export async function jwennTeksKantite() {
|
||||
|
||||
export async function jwennAwtisPajinasyon(paj) {
|
||||
const start = AWTIS_POU_CHAK_PAJ * (paj - 1)
|
||||
const query = `_sort=published_at:DESC&_start=${start}&_limit=${AWTIS_POU_CHAK_PAJ}&_where[published_at_null]=false`
|
||||
const query = qs.stringify({
|
||||
populate: ['paroles', 'photo'],
|
||||
sort: ['publishedAt:desc'],
|
||||
pagination: {
|
||||
start,
|
||||
limit: AWTIS_POU_CHAK_PAJ
|
||||
}
|
||||
}, {
|
||||
encodeValuesOnly: true
|
||||
})
|
||||
|
||||
const response = await axios.get(`${OKI_API}/awtis?${query}`)
|
||||
return response.data
|
||||
const {data} = await readAxiosInstance.get(`${OKI_API}/artistes?${query}`)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function jwennTeks() {
|
||||
const query = '_sort=tit:ASC&_where[published_at_null]=false'
|
||||
const query = qs.stringify({
|
||||
populate: ['artistes', 'couverture', 'user', 'userAdmin', 'commentaires', 'traductions', 'streamVideo', 'streamAudio'],
|
||||
sort: ['titre:asc'],
|
||||
pagination: {
|
||||
pageSize: 100
|
||||
}
|
||||
}, {
|
||||
encodeValuesOnly: true
|
||||
})
|
||||
|
||||
const response = await axios.get(`${OKI_API}/teks?${query}`)
|
||||
return response.data
|
||||
const {data} = await readAxiosInstance.get(`${OKI_API}/paroles?${query}`)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function jwennAwtisSlug() {
|
||||
const query = '_sort=published_at:DESC&_where[published_at_null]=false'
|
||||
const query = qs.stringify({
|
||||
sort: ['publishedAt:desc']
|
||||
})
|
||||
|
||||
const response = await axios.get(`${OKI_API}/awtis?${query}`)
|
||||
const response = await readAxiosInstance.get(`${OKI_API}/artistes?${query}`)
|
||||
const {data} = response
|
||||
return data.map(({slug}) => slug)
|
||||
return data.data.map(({attributes}) => attributes.slug)
|
||||
}
|
||||
|
||||
export async function jwennTeksSlug() {
|
||||
const query = qs.stringify({
|
||||
sort: ['publishedAt:desc']
|
||||
})
|
||||
|
||||
const response = await readAxiosInstance.get(`${OKI_API}/paroles?${query}`)
|
||||
const {data} = response
|
||||
return data.data.map(({attributes}) => attributes.slug)
|
||||
}
|
||||
|
||||
export async function jwennDenyeTeks() {
|
||||
@@ -61,33 +105,41 @@ export async function jwennDenyeTeks() {
|
||||
pagination: {
|
||||
limit: 6
|
||||
}
|
||||
}, {
|
||||
encodeValuesOnly: true
|
||||
})
|
||||
|
||||
const {data} = await readAxiosInstance.get(`${OKI_API}/paroles?${query}`)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function jwennAnTeks(teksId) {
|
||||
const response = await axios.get(`${OKI_API}/teks/${teksId}`)
|
||||
return response.data
|
||||
export async function jwennAnTeks(teksId, token) {
|
||||
const headers = {
|
||||
'content-type': 'application/json',
|
||||
Authorization: `Bearer ${token}`
|
||||
}
|
||||
|
||||
export async function jwennTeksEpiUserId(userId) {
|
||||
const query = `_sort=tit:ASC&_where[user.id]=${userId}&_publicationState=preview&published_at_null=true`
|
||||
|
||||
const response = await axios.get(`${OKI_API}/teks?${query}`)
|
||||
return response.data
|
||||
}
|
||||
|
||||
export async function jwennSlugs() {
|
||||
const response = await axios.get(`${OKI_API}/slugs`)
|
||||
const response = await axios.get(`${OKI_API}/paroles/${teksId}`, {headers})
|
||||
return response.data
|
||||
}
|
||||
|
||||
export async function jwennKomanteEpiTeksId(teksId) {
|
||||
const query = `_sort=published_at:DESC&_where[teks]=${teksId}&_where[published_at_null]=false`
|
||||
const response = await axios.get(`${OKI_API}/komante?${query}`)
|
||||
return response.data
|
||||
const query = qs.stringify({
|
||||
sort: ['publishedAt:desc'],
|
||||
populate: ['paroles', 'user'],
|
||||
filters: {
|
||||
parole: {
|
||||
id: {
|
||||
$eq: teksId
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
encodeValuesOnly: true
|
||||
})
|
||||
|
||||
const {data} = await readAxiosInstance.get(`${OKI_API}/commentaires?${query}`)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function jwennUserEpiToken(userToken) {
|
||||
@@ -100,13 +152,43 @@ export async function jwennUserEpiToken(userToken) {
|
||||
}
|
||||
|
||||
export async function jwennUserEpiUsername(username) {
|
||||
const query = `_where[username]=${username}&_where[confirmed]=true`
|
||||
const response = await axios.get(`${OKI_API}/users?${query}`)
|
||||
const query = qs.stringify({
|
||||
filters: {
|
||||
username: {
|
||||
$eq: username
|
||||
}
|
||||
}
|
||||
}, {
|
||||
encodeValuesOnly: true
|
||||
})
|
||||
|
||||
const response = await readAxiosInstance.get(`${OKI_API}/users?${query}`)
|
||||
return response.data[0]
|
||||
}
|
||||
|
||||
export async function jwennUserEpiEmail(email) {
|
||||
const query = `_where[email]=${email}&_where[confirmed]=false&_where[blocked]=false`
|
||||
const response = await axios.get(`${OKI_API}/users?${query}`)
|
||||
const query = qs.stringify({
|
||||
filters: {
|
||||
email: {
|
||||
$eq: email
|
||||
},
|
||||
confirmed: {
|
||||
$eq: false
|
||||
},
|
||||
blocked: {
|
||||
$eq: false
|
||||
}
|
||||
}
|
||||
}, {
|
||||
encodeValuesOnly: true
|
||||
})
|
||||
|
||||
const response = await readAxiosInstance.get(`${OKI_API}/users?${query}`)
|
||||
return response.data[0]
|
||||
}
|
||||
|
||||
export async function passwordRequest(lyen, email) {
|
||||
await axios.post(`${OKI_API}/auth/${lyen}`, {
|
||||
email
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user