Update oki-api with qs and new routes
This commit is contained in:
+120
-38
@@ -12,18 +12,33 @@ const readAxiosInstance = axios.create({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export async function jwennTeksEpiSlug(slug) {
|
export async function jwennTeksEpiSlug(slug) {
|
||||||
const response = await axios.get(`${OKI_API}/teks?slug=${slug}&_where[published_at_null]=false`)
|
const query = qs.stringify({
|
||||||
return response.data[0]
|
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) {
|
export async function jwennAwtisEpiSlug(slug) {
|
||||||
const response = await axios.get(`${OKI_API}/awtis?slug=${slug}&_where[published_at_null]=false`)
|
const query = qs.stringify({
|
||||||
return response.data[0]
|
populate: ['paroles', 'photo'],
|
||||||
}
|
filters: {
|
||||||
|
slug: {
|
||||||
export async function jwennAwtisKantite() {
|
$eq: slug
|
||||||
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() {
|
export async function jwennTeksKantite() {
|
||||||
@@ -33,25 +48,54 @@ export async function jwennTeksKantite() {
|
|||||||
|
|
||||||
export async function jwennAwtisPajinasyon(paj) {
|
export async function jwennAwtisPajinasyon(paj) {
|
||||||
const start = AWTIS_POU_CHAK_PAJ * (paj - 1)
|
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}`)
|
const {data} = await readAxiosInstance.get(`${OKI_API}/artistes?${query}`)
|
||||||
return response.data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function jwennTeks() {
|
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}`)
|
const {data} = await readAxiosInstance.get(`${OKI_API}/paroles?${query}`)
|
||||||
return response.data
|
return data.data
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function jwennAwtisSlug() {
|
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
|
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() {
|
export async function jwennDenyeTeks() {
|
||||||
@@ -61,33 +105,41 @@ export async function jwennDenyeTeks() {
|
|||||||
pagination: {
|
pagination: {
|
||||||
limit: 6
|
limit: 6
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
encodeValuesOnly: true
|
||||||
})
|
})
|
||||||
|
|
||||||
const {data} = await readAxiosInstance.get(`${OKI_API}/paroles?${query}`)
|
const {data} = await readAxiosInstance.get(`${OKI_API}/paroles?${query}`)
|
||||||
return data.data
|
return data.data
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function jwennAnTeks(teksId) {
|
export async function jwennAnTeks(teksId, token) {
|
||||||
const response = await axios.get(`${OKI_API}/teks/${teksId}`)
|
const headers = {
|
||||||
return response.data
|
'content-type': 'application/json',
|
||||||
}
|
Authorization: `Bearer ${token}`
|
||||||
|
}
|
||||||
|
|
||||||
export async function jwennTeksEpiUserId(userId) {
|
const response = await axios.get(`${OKI_API}/paroles/${teksId}`, {headers})
|
||||||
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`)
|
|
||||||
return response.data
|
return response.data
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function jwennKomanteEpiTeksId(teksId) {
|
export async function jwennKomanteEpiTeksId(teksId) {
|
||||||
const query = `_sort=published_at:DESC&_where[teks]=${teksId}&_where[published_at_null]=false`
|
const query = qs.stringify({
|
||||||
const response = await axios.get(`${OKI_API}/komante?${query}`)
|
sort: ['publishedAt:desc'],
|
||||||
return response.data
|
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) {
|
export async function jwennUserEpiToken(userToken) {
|
||||||
@@ -100,13 +152,43 @@ export async function jwennUserEpiToken(userToken) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function jwennUserEpiUsername(username) {
|
export async function jwennUserEpiUsername(username) {
|
||||||
const query = `_where[username]=${username}&_where[confirmed]=true`
|
const query = qs.stringify({
|
||||||
const response = await axios.get(`${OKI_API}/users?${query}`)
|
filters: {
|
||||||
|
username: {
|
||||||
|
$eq: username
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
encodeValuesOnly: true
|
||||||
|
})
|
||||||
|
|
||||||
|
const response = await readAxiosInstance.get(`${OKI_API}/users?${query}`)
|
||||||
return response.data[0]
|
return response.data[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function jwennUserEpiEmail(email) {
|
export async function jwennUserEpiEmail(email) {
|
||||||
const query = `_where[email]=${email}&_where[confirmed]=false&_where[blocked]=false`
|
const query = qs.stringify({
|
||||||
const response = await axios.get(`${OKI_API}/users?${query}`)
|
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]
|
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