Strapi SDK development

Hi there!

As you may know (or not) I already built somes SDK around strapi. I created the first one 2 years ago for Nuxt applications which use Strapi as API (a project that was mainly there to speed up development in my company Shelt.in).

I liked this kind of development and last december I decided to create an SDK for Strapi that would be more general public (a real SDK this time :rofl: ) (https://strapi-sdk-js.netlify.app), except that this first version does not suit me anymore in relation to the skills I had and the time I had to develop it. The project lacks readability, the code is not very clean (everything in one file) & all the methods are not there

That’s why I decided to develop a new one from scratch which would be truly maintain by me and maybe become the “official one” for the strapi community :heart_eyes:

Here are my first thoughts for this SDK:

  • A Typescript project that supports httpOnly, GraphQL & does not have a greedy/heavy HTTP client
  • It must handle CRUD methods as well as authentication & file upload
  • A CLI that allows to generate GraphQL types exposed by your Strapi project.
  • Provide types based on Strapi requests and contents (UserObject, EmailRequest object ect…)

Of course I’m doing this thread mainly to get your feedback! All your thoughts are good to take as long as they are constructive

2 Likes

Hi everybody!

Here is a small update on the global progress of the SDK :wink:

  • The project has been well set up!
  • I had trouble into setting up the CLI in order to make it available thanks npx & yarn
  • I just finished the CLI part. I can generate Typescript types from the schema on your Strapi application. I just have to polish it a little bit :smiley:
  • After the code cleaning phase I’ll go to the type definition of the basic SDK feature !

See you soon for a new little update :heart:

One more thing

This is the usage of the CLI :

// Without params [default folder: ./models, default name: type.ts
npx strapi-sdk generate

// With params
npx strapi-sdk generate -d ./graphql -n myOtherName
or
npx strapi-sdk generate --dir ./graphql --name myOtherName
1 Like

@Stun3R don’t forget to submit a PR to the awesome-strapi repo

1 Like

Hi, Yes I’ll do it when it’ll be finished :wink:

Little update about the CLI

I change the way the CLI would be used :smiley:
Now you’ll have a prompt asking you if you want to custom the host, filename & directory.

Before

After

I think you’ll prefer the After version :smiley:.

Don’t hesitate to tell me if I need to rewrite the questions in the prompt to be more efficient :wink:

Hiiiii!

New update :slight_smile:

I just finished the CRUD methods, implementation of GraphQL support & error handling.

For the error handling you’ll have for Strapi error a formatted object as bellow:

{
  isStrapi: true,
  response: {
    status: "400",
    statusText: "Bad Request",
    message: "Strapi error",
    original: [{...}],
    headers: [{...}],
    config: [{...}],
    request: [{...}],
  },
}

I’m going to start the development of the auth methods.

See you soon :wink: