From e0dd28db987bbaeb4ebddb0bab6e0645ecce7c3e Mon Sep 17 00:00:00 2001 From: mgh Date: Mon, 4 Mar 2024 12:21:25 +0330 Subject: [PATCH 1/4] docs(readme): update config and example --- README.md | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 0756f44..71ef984 100644 --- a/README.md +++ b/README.md @@ -30,22 +30,39 @@ yarn add strapi-js ```js // ESM | Typescript -import { StrapiSdk } from 'strapi-js' // CommonJS: const { StrapiSdk } = require('strapi-js') +// CommonJS: const { StrapiSdk } = require('strapi-js') +import { StrapiSdk } from 'strapi-js' -// Usage: obtain sdk-instance and use it to login and perform other functions -const config = { url: 'http://localhost:1337', prefix: 'api' } // the default configuration -const strapiSdk = StrapiSdk (config) // or if you doesn't provide config the sdk will be use the default configuration +// Usage: 1) provide config (the default configuration) +const config = { + url: 'http://localhost:1337/', + prefix: '/api', + version: 'v4', + logType: 'info', + retry: 0, // Number of retries for requests that have encountered an error +} -const { user, jwt } = strapiSdk.users.login ({ identifier: 'username', password: 'pass' }) +// Usage: 2) obtain sdk instance +const strapi = StrapiSdk (config) + +// Usage: 3) use it +const { user, jwt } = strapi.auth.login ({ + identifier: 'mgh@gmail.com', + password: 'pass123' +}) +strapi.auth.changePassword({ + currentPassword: 'pass123', + password: 'pass123456', + passwordConfirmation: 'pass123456' +}) ``` # Docs ## Users Sdk -`strapiSdk.users` contains these methods: +`strapiSdk.auth` contains `/auth` APIs of Strapi: - `login`: login providing identifier (username or email) and password -- `getCurrentUser`: get user profile using the jwt-token received with `login` method - `register`: register new user providing username, email and password -- `sendEmailConfirmation`: resend confirmation token using a registered email address -- `changePassword`: change logged in user's password providing jwt-token, current-password and new-password +- `sendEmailConfirmation`: email confirmation token to registered user +- `changePassword`: change logged-in user's password providing jwt-token, current-password and new-password - `forgotPassword`: request to reset the password using a registered email address -- `resetPassword`: set new password using token received with previous method -- `getProviderAuthenticationUrl`: not-implemented-yet +- `resetPassword`: set new password using token received with user's email +- `currentUser`: get user information using the jwt-token From 864c7f2b9997e500a7c372d2bfc385629092d94e Mon Sep 17 00:00:00 2001 From: mgh Date: Mon, 4 Mar 2024 12:22:47 +0330 Subject: [PATCH 2/4] build(release): allow non-main branch releasing --- .release-it.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.release-it.json b/.release-it.json index dbfe05f..5be0f94 100644 --- a/.release-it.json +++ b/.release-it.json @@ -2,8 +2,7 @@ "git": { "commitMessage": "chore: release v${version}", "tagName": "v${version}", - "tagAnnotation": "Release v${version}", - "requireBranch": "main" + "tagAnnotation": "Release v${version}" }, "github": { "release": true, From cacf4e0eef992753f9f9c67e934a056e905b6546 Mon Sep 17 00:00:00 2001 From: mgh Date: Mon, 4 Mar 2024 12:27:04 +0330 Subject: [PATCH 3/4] build(release): run test befor release --- .release-it.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.release-it.json b/.release-it.json index 5be0f94..9df1e3b 100644 --- a/.release-it.json +++ b/.release-it.json @@ -12,7 +12,7 @@ "release": true }, "hooks": { - "before:init": ["git pull", "pnpm lint", "pnpm build", "pnpm coverage"] + "before:init": ["git pull", "pnpm lint", "pnpm build", "pnpm test"] }, "plugins": { "release-it-beautiful-changelog": { From bf2029a96672778dd6787398f7b4cde98ce6c5e9 Mon Sep 17 00:00:00 2001 From: mgh Date: Mon, 4 Mar 2024 12:28:06 +0330 Subject: [PATCH 4/4] build(package): fix version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0661190..31624e7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "strapi-js", "type": "module", - "version": "1.0.1", + "version": "1.1.0", "packageManager": "pnpm@8.15.3", "description": "A nodejs/browser/edge javascript SDK for Strapi headless CMS; type-safe with typescript.", "author": "mgh ",