fix strapi urls and shit
This commit is contained in:
parent
0e94cb95ca
commit
0eb91d67dd
8 changed files with 92 additions and 66 deletions
0
src/lib/server/index.ts
Normal file
0
src/lib/server/index.ts
Normal file
31
src/lib/server/strapi/index.ts
Normal file
31
src/lib/server/strapi/index.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import { strapi, type StrapiClient } from "@strapi/client";
|
||||
|
||||
export class Strapi {
|
||||
private readonly client: StrapiClient;
|
||||
|
||||
constructor(
|
||||
public readonly url: string,
|
||||
auth: string,
|
||||
) {
|
||||
this.client = strapi({
|
||||
baseURL: `${url}/api`,
|
||||
auth: auth,
|
||||
});
|
||||
}
|
||||
|
||||
async Blogs() {
|
||||
const blogs = this.client.collection("blogs");
|
||||
|
||||
return await blogs.find({
|
||||
populate: ["Header", "Topics"],
|
||||
});
|
||||
}
|
||||
|
||||
async Blog(id: string) {
|
||||
const blogs = this.client.collection("blogs");
|
||||
|
||||
return await blogs.findOne(id, {
|
||||
populate: ["Header", "Topics"],
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue