Skip to content

Commit

Permalink
Merge pull request #9 from mohammadGh/release
Browse files Browse the repository at this point in the history
Prepare readme and config for release
  • Loading branch information
mohammadGh authored Mar 4, 2024
2 parents 33555b9 + bf2029a commit 4ac3647
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
5 changes: 2 additions & 3 deletions .release-it.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -13,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": {
Expand Down
39 changes: 28 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <m.ghoreshi@gmail.com>",
Expand Down

0 comments on commit 4ac3647

Please sign in to comment.