@malevich-studio/strapi-sdk-typescript 1.2.4 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +31 -3
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -108,13 +108,41 @@ const articles = api.articles(
108
108
  );
109
109
  ```
110
110
 
111
+ ### Login Example
112
+
113
+ Next.js
114
+
115
+ ```ts
116
+ 'use server';
117
+
118
+ import Strapi from '@/strapi';
119
+ import { cookies } from 'next/headers';
120
+
121
+ export async function login(email: string, password: string) {
122
+ const strapi = new Strapi(process.env.STRAPI_URL || '');
123
+ const response = await strapi.login(email, password);
124
+
125
+ if (!response.error) {
126
+ (await cookies()).set('access_token', response.jwt, {
127
+ httpOnly: true,
128
+ secure: process.env.NODE_ENV === 'production',
129
+ sameSite: 'lax',
130
+ path: '/',
131
+ maxAge: 3600 * 24 * 365 * 10,
132
+ });
133
+ }
134
+
135
+ return response;
136
+ }
137
+ ```
138
+
111
139
  ## 📌 TODO List
112
140
 
113
141
  - [ ] Add authentication features:
114
- - [ ] Log In functionality
115
- - [ ] User Registration
142
+ - [x] Log In functionality
143
+ - [x] User Registration
116
144
  - [ ] User privileges check
117
- - [ ] Add localization features
145
+ - [x] Add localization features
118
146
  - [ ] Refactor `src/generator/index.ts` for better maintainability
119
147
  - [ ] Enable passing Strapi credentials via CLI parameters
120
148
  - [ ] Allow customization of API class path
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malevich-studio/strapi-sdk-typescript",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "sideEffects": false,
5
5
  "bin": {
6
6
  "generate-strapi-types": "./dist/cli.mjs"