@webbycrown/webbycommerce 1.0.0
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.
- package/LICENSE +22 -0
- package/README.md +588 -0
- package/bin/setup-debug.log +6 -0
- package/bin/setup.js +157 -0
- package/dist/_chunks/Settings-BTffXkdF.mjs +31213 -0
- package/dist/_chunks/Settings-CHavEmCV.js +31253 -0
- package/dist/_chunks/en-CN5945VW.mjs +504 -0
- package/dist/_chunks/en-Dj8IzRXD.js +504 -0
- package/dist/_chunks/index-BFH1VuAA.mjs +85 -0
- package/dist/_chunks/index-DXM6qeJr.js +84 -0
- package/dist/admin/index.js +3 -0
- package/dist/admin/index.mjs +4 -0
- package/dist/data/demo-data.json +654 -0
- package/dist/robots.txt +3 -0
- package/dist/server/index.js +10734 -0
- package/dist/uploads/.gitkeep +0 -0
- package/dist/uploads/accessories_category_2a5631094b.jpeg +0 -0
- package/dist/uploads/beauty_personal_care_category_57f8a8f1e3.jpeg +0 -0
- package/dist/uploads/books_category_a9a253eada.jpeg +0 -0
- package/dist/uploads/classic_cotton_tshirt_1_cd713425f6.png +0 -0
- package/dist/uploads/clothing_category_d5c60ef07b.jpeg +0 -0
- package/dist/uploads/daviddoe_strapi_adbcd41787.jpeg +0 -0
- package/dist/uploads/electronics_category_fc3e5ef571.jpeg +0 -0
- package/dist/uploads/ergonomic_office_chair_1_c751cffb07.png +0 -0
- package/dist/uploads/home_garden_category_4f6eb3f8d6.jpeg +0 -0
- package/dist/uploads/istockphoto_1188462138_612x612_11f295b9c0.jpg +0 -0
- package/dist/uploads/istockphoto_1188462138_612x612_396fb272fd.jpg +0 -0
- package/dist/uploads/large_daviddoe_strapi_adbcd41787.jpeg +0 -0
- package/dist/uploads/leather_travel_backpack_1_238bc1ae4d.png +0 -0
- package/dist/uploads/mechanical_keyboard_pro_1_0cd391a6ac.png +0 -0
- package/dist/uploads/medium_classic_cotton_tshirt_1_cd713425f6.png +0 -0
- package/dist/uploads/medium_daviddoe_strapi_adbcd41787.jpeg +0 -0
- package/dist/uploads/medium_ergonomic_office_chair_1_c751cffb07.png +0 -0
- package/dist/uploads/medium_leather_travel_backpack_1_238bc1ae4d.png +0 -0
- package/dist/uploads/medium_mechanical_keyboard_pro_1_0cd391a6ac.png +0 -0
- package/dist/uploads/medium_smart_watch_series_5_1_cdc2511fb7.png +0 -0
- package/dist/uploads/medium_smartphone_x_pro_1_c3f0cbd080.png +0 -0
- package/dist/uploads/medium_the_great_gatsby_special_1_2e7c76d997.png +0 -0
- package/dist/uploads/medium_wireless_headphones_1_fa75cd50c3.png +0 -0
- package/dist/uploads/medium_yoga_mat_premium_1_01f9a3b5fa.png +0 -0
- package/dist/uploads/predictive_maintenance_icons_industry_automation_600nw_2685943461_e18a8aa3b0.webp +0 -0
- package/dist/uploads/small_classic_cotton_tshirt_1_cd713425f6.png +0 -0
- package/dist/uploads/small_daviddoe_strapi_adbcd41787.jpeg +0 -0
- package/dist/uploads/small_ergonomic_office_chair_1_c751cffb07.png +0 -0
- package/dist/uploads/small_leather_travel_backpack_1_238bc1ae4d.png +0 -0
- package/dist/uploads/small_mechanical_keyboard_pro_1_0cd391a6ac.png +0 -0
- package/dist/uploads/small_smart_watch_series_5_1_cdc2511fb7.png +0 -0
- package/dist/uploads/small_smartphone_x_pro_1_c3f0cbd080.png +0 -0
- package/dist/uploads/small_the_great_gatsby_special_1_2e7c76d997.png +0 -0
- package/dist/uploads/small_wireless_headphones_1_fa75cd50c3.png +0 -0
- package/dist/uploads/small_yoga_mat_premium_1_01f9a3b5fa.png +0 -0
- package/dist/uploads/smart_watch_series_5_1_cdc2511fb7.png +0 -0
- package/dist/uploads/smartphone_x_pro_1_c3f0cbd080.png +0 -0
- package/dist/uploads/the_great_gatsby_special_1_2e7c76d997.png +0 -0
- package/dist/uploads/thumbnail_accessories_category_2a5631094b.jpeg +0 -0
- package/dist/uploads/thumbnail_beauty_personal_care_category_57f8a8f1e3.jpeg +0 -0
- package/dist/uploads/thumbnail_books_category_a9a253eada.jpeg +0 -0
- package/dist/uploads/thumbnail_classic_cotton_tshirt_1_cd713425f6.png +0 -0
- package/dist/uploads/thumbnail_clothing_category_d5c60ef07b.jpeg +0 -0
- package/dist/uploads/thumbnail_daviddoe_strapi_adbcd41787.jpeg +0 -0
- package/dist/uploads/thumbnail_electronics_category_fc3e5ef571.jpeg +0 -0
- package/dist/uploads/thumbnail_ergonomic_office_chair_1_c751cffb07.png +0 -0
- package/dist/uploads/thumbnail_home_garden_category_4f6eb3f8d6.jpeg +0 -0
- package/dist/uploads/thumbnail_istockphoto_1188462138_612x612_11f295b9c0.jpg +0 -0
- package/dist/uploads/thumbnail_istockphoto_1188462138_612x612_396fb272fd.jpg +0 -0
- package/dist/uploads/thumbnail_leather_travel_backpack_1_238bc1ae4d.png +0 -0
- package/dist/uploads/thumbnail_mechanical_keyboard_pro_1_0cd391a6ac.png +0 -0
- package/dist/uploads/thumbnail_predictive_maintenance_icons_industry_automation_600nw_2685943461_e18a8aa3b0.webp +0 -0
- package/dist/uploads/thumbnail_smart_watch_series_5_1_cdc2511fb7.png +0 -0
- package/dist/uploads/thumbnail_smartphone_x_pro_1_c3f0cbd080.png +0 -0
- package/dist/uploads/thumbnail_the_great_gatsby_special_1_2e7c76d997.png +0 -0
- package/dist/uploads/thumbnail_wireless_headphones_1_fa75cd50c3.png +0 -0
- package/dist/uploads/thumbnail_yoga_mat_premium_1_01f9a3b5fa.png +0 -0
- package/dist/uploads/webby-commerce.png +0 -0
- package/dist/uploads/wireless_headphones_1_fa75cd50c3.png +0 -0
- package/dist/uploads/yoga_mat_premium_1_01f9a3b5fa.png +0 -0
- package/package.json +81 -0
- package/strapi-server.js +9 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 WebbyCrown
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
# WebbyCommerce Plugin
|
|
2
|
+
|
|
3
|
+
A complete, production-ready ecommerce solution for Strapi CMS. This plugin provides a comprehensive backend for managing ecommerce functionality without requiring developers to manually create content types, routes, or controllers. Simply install, configure, and start building your online store.
|
|
4
|
+
|
|
5
|
+
## 🎯 Plugin Goal
|
|
6
|
+
|
|
7
|
+
This plugin is designed to be a **drop-in ecommerce backend layer** for Strapi:
|
|
8
|
+
|
|
9
|
+
- **Zero Manual Setup**: No need to create content types, routes, or controllers manually
|
|
10
|
+
- **Ready-to-Use APIs**: All ecommerce endpoints are pre-built and documented
|
|
11
|
+
- **Admin Configuration**: Manage all settings through the Strapi admin panel
|
|
12
|
+
- **WooCommerce-like Flow**: Complete ecommerce workflow similar to WooCommerce
|
|
13
|
+
- **Production Ready**: Built with security, validation, and best practices in mind
|
|
14
|
+
|
|
15
|
+
## 📦 Installation
|
|
16
|
+
|
|
17
|
+
### From NPM (Published Package)
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @webbycrown/webbycommerce
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Enable in Strapi
|
|
24
|
+
|
|
25
|
+
Add the plugin to your `config/plugins.js`:
|
|
26
|
+
|
|
27
|
+
```javascript
|
|
28
|
+
module.exports = ({ env }) => ({
|
|
29
|
+
'webbycommerce': {
|
|
30
|
+
enabled: true,
|
|
31
|
+
resolve: require.resolve('@webbycrown/webbycommerce'),
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Local Development
|
|
37
|
+
|
|
38
|
+
If you're developing locally, you can enable it from the local path:
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
module.exports = ({ env }) => ({
|
|
42
|
+
'webbycommerce': {
|
|
43
|
+
enabled: true,
|
|
44
|
+
resolve: './src/plugins/webbycommerce',
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## ⚙️ Initial Setup
|
|
50
|
+
|
|
51
|
+
### 1. Enable Permissions
|
|
52
|
+
|
|
53
|
+
After installation, navigate to **Settings → Users & Permissions → Roles** and select the **Public** role (or any role you want to grant access).
|
|
54
|
+
|
|
55
|
+
Under the **WebbyCommerce** section, enable the **Enable** permission to allow access to ecommerce API endpoints.
|
|
56
|
+
|
|
57
|
+
### 2. Configure Plugin Settings
|
|
58
|
+
|
|
59
|
+
Navigate to **Settings → WebbyCommerce** in the Strapi admin panel. You'll find several configuration tabs:
|
|
60
|
+
|
|
61
|
+
#### **Configure Tab**
|
|
62
|
+
- **Allowed Frontend Domains**: Add your frontend domain(s) for CORS and security
|
|
63
|
+
- **API Route Prefix**: Customize the API route prefix (default: `webbycommerce`)
|
|
64
|
+
- Examples: `/api/ecommerce`, `/api/v1`, `/api/shop`
|
|
65
|
+
- **SMTP Configuration**: Configure email settings for OTP and notifications
|
|
66
|
+
- Host, Port, Secure (TLS), Username, Password
|
|
67
|
+
- From Email and From Name
|
|
68
|
+
|
|
69
|
+
#### **Login/Register Tab**
|
|
70
|
+
- **Authentication Method**: Choose between:
|
|
71
|
+
- **Default (Email/Password)**: Uses Strapi's built-in authentication
|
|
72
|
+
- **OTP (Email/Mobile Verification)**: One-time password authentication
|
|
73
|
+
|
|
74
|
+
#### **Shipping Type Tab**
|
|
75
|
+
- **Single Address Mode**: Users can have only one billing and one shipping address
|
|
76
|
+
- **Multiple Address Mode**: Users can create unlimited addresses
|
|
77
|
+
|
|
78
|
+
### 3. User Schema Extension
|
|
79
|
+
|
|
80
|
+
The plugin automatically extends the user schema with ecommerce-specific fields. Ensure your user schema includes:
|
|
81
|
+
|
|
82
|
+
**Required Fields:**
|
|
83
|
+
- `username` (string, required, unique)
|
|
84
|
+
- `email` (email, required)
|
|
85
|
+
- `phone_no` (string, required, unique)
|
|
86
|
+
- `first_name` (string, required)
|
|
87
|
+
- `last_name` (string, required)
|
|
88
|
+
|
|
89
|
+
**Optional Fields:**
|
|
90
|
+
- `display_name` (string)
|
|
91
|
+
- `company_name` (string)
|
|
92
|
+
|
|
93
|
+
**OTP Fields (if using OTP authentication):**
|
|
94
|
+
- `otp` (integer)
|
|
95
|
+
- `isOtpVerified` (boolean, default: false)
|
|
96
|
+
|
|
97
|
+
The plugin includes a schema extension file at `src/extensions/users-permissions/content-types/user/schema.json` that adds these fields automatically.
|
|
98
|
+
|
|
99
|
+
### 4. Address Content Type
|
|
100
|
+
|
|
101
|
+
The plugin creates an `Address` content type automatically with the following fields:
|
|
102
|
+
|
|
103
|
+
**Required Fields:**
|
|
104
|
+
- `type` (integer, 0=billing, 1=shipping)
|
|
105
|
+
- `first_name` (string)
|
|
106
|
+
- `last_name` (string)
|
|
107
|
+
- `country` (string)
|
|
108
|
+
- `city` (string)
|
|
109
|
+
- `street_address` (text)
|
|
110
|
+
- `postcode` (string)
|
|
111
|
+
- `phone` (string)
|
|
112
|
+
- `email_address` (email, required for billing addresses)
|
|
113
|
+
|
|
114
|
+
**Optional Fields:**
|
|
115
|
+
- `company_name` (string)
|
|
116
|
+
- `region` (string)
|
|
117
|
+
|
|
118
|
+
**Relations:**
|
|
119
|
+
- `user` (manyToOne → plugin::users-permissions.user)
|
|
120
|
+
|
|
121
|
+
## 📚 API Documentation
|
|
122
|
+
|
|
123
|
+
All API endpoints are documented in the Strapi admin panel under **Settings → Advanced Ecommerce → API Collections**. Each endpoint includes:
|
|
124
|
+
|
|
125
|
+
- Request/Response examples
|
|
126
|
+
- Authentication requirements
|
|
127
|
+
- Usage instructions
|
|
128
|
+
- cURL examples
|
|
129
|
+
|
|
130
|
+
### Base URL
|
|
131
|
+
|
|
132
|
+
The base URL depends on your configured route prefix:
|
|
133
|
+
|
|
134
|
+
- Default: `http://localhost:1337/api/webbycommerce`
|
|
135
|
+
- Custom: `http://localhost:1337/api/{your-prefix}`
|
|
136
|
+
|
|
137
|
+
### Authentication
|
|
138
|
+
|
|
139
|
+
Most endpoints require a JWT token. Include it in the Authorization header:
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
Authorization: Bearer YOUR_JWT_TOKEN
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## 🔐 Authentication APIs
|
|
146
|
+
|
|
147
|
+
### Default Authentication (Email/Password)
|
|
148
|
+
|
|
149
|
+
When **Default** authentication method is selected:
|
|
150
|
+
|
|
151
|
+
#### Login
|
|
152
|
+
```
|
|
153
|
+
POST /api/auth/local
|
|
154
|
+
Content-Type: application/json
|
|
155
|
+
|
|
156
|
+
{
|
|
157
|
+
"identifier": "user@example.com",
|
|
158
|
+
"password": "password"
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### Register
|
|
163
|
+
```
|
|
164
|
+
POST /api/auth/local/register
|
|
165
|
+
Content-Type: application/json
|
|
166
|
+
|
|
167
|
+
{
|
|
168
|
+
"username": "user1234",
|
|
169
|
+
"email": "user@example.com",
|
|
170
|
+
"password": "password"
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### OTP Authentication (Email/Mobile)
|
|
175
|
+
|
|
176
|
+
When **OTP** authentication method is selected:
|
|
177
|
+
|
|
178
|
+
#### Login/Register (Send OTP)
|
|
179
|
+
```
|
|
180
|
+
POST /api/{prefix}/auth/login-register
|
|
181
|
+
Content-Type: application/json
|
|
182
|
+
|
|
183
|
+
{
|
|
184
|
+
"email": "user@example.com",
|
|
185
|
+
"type": "email"
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**Response:**
|
|
190
|
+
```json
|
|
191
|
+
{
|
|
192
|
+
"message": "OTP sent to email.",
|
|
193
|
+
"userId": 1,
|
|
194
|
+
"isNewUser": false,
|
|
195
|
+
"emailSent": true
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
#### Verify OTP
|
|
200
|
+
```
|
|
201
|
+
POST /api/{prefix}/auth/verify-otp
|
|
202
|
+
Content-Type: application/json
|
|
203
|
+
|
|
204
|
+
{
|
|
205
|
+
"email": "user@example.com",
|
|
206
|
+
"otp": "123456",
|
|
207
|
+
"type": "email"
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
**Response:**
|
|
212
|
+
```json
|
|
213
|
+
{
|
|
214
|
+
"message": "Login successfully!",
|
|
215
|
+
"jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
|
|
216
|
+
"user": {
|
|
217
|
+
"id": 1,
|
|
218
|
+
"username": "user1234",
|
|
219
|
+
"email": "user@example.com",
|
|
220
|
+
"phone_no": null
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## 👤 User Profile APIs
|
|
226
|
+
|
|
227
|
+
### Get Profile
|
|
228
|
+
```
|
|
229
|
+
GET /api/{prefix}/auth/profile
|
|
230
|
+
Authorization: Bearer YOUR_JWT_TOKEN
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**Response:**
|
|
234
|
+
```json
|
|
235
|
+
{
|
|
236
|
+
"user": {
|
|
237
|
+
"id": 1,
|
|
238
|
+
"username": "user1234",
|
|
239
|
+
"email": "user@example.com",
|
|
240
|
+
"phone_no": "+1234567890",
|
|
241
|
+
"first_name": "John",
|
|
242
|
+
"last_name": "Doe",
|
|
243
|
+
"display_name": "John Doe",
|
|
244
|
+
"company_name": "WebbyCrown Solutions",
|
|
245
|
+
"confirmed": true,
|
|
246
|
+
"blocked": false,
|
|
247
|
+
"role": {
|
|
248
|
+
"id": 1,
|
|
249
|
+
"name": "Authenticated",
|
|
250
|
+
"type": "authenticated"
|
|
251
|
+
},
|
|
252
|
+
"createdAt": "2024-01-01T00:00:00.000Z",
|
|
253
|
+
"updatedAt": "2024-01-01T00:00:00.000Z"
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
**Note:** All fields (except password) are always returned, using `null` for missing values.
|
|
259
|
+
|
|
260
|
+
### Update Profile
|
|
261
|
+
```
|
|
262
|
+
PUT /api/{prefix}/auth/profile
|
|
263
|
+
Authorization: Bearer YOUR_JWT_TOKEN
|
|
264
|
+
Content-Type: application/json
|
|
265
|
+
|
|
266
|
+
{
|
|
267
|
+
"first_name": "John",
|
|
268
|
+
"last_name": "Doe",
|
|
269
|
+
"email": "user@example.com",
|
|
270
|
+
"phone_no": "+1234567890",
|
|
271
|
+
"display_name": "John Doe",
|
|
272
|
+
"company_name": "WebbyCrown Solutions",
|
|
273
|
+
"currentPassword": "oldpassword",
|
|
274
|
+
"newPassword": "newpassword"
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
**Required Fields:**
|
|
279
|
+
- `first_name`
|
|
280
|
+
- `last_name`
|
|
281
|
+
- `email` (must be unique)
|
|
282
|
+
- `phone_no` (must be unique)
|
|
283
|
+
|
|
284
|
+
**Optional Fields:**
|
|
285
|
+
- `display_name`
|
|
286
|
+
- `company_name`
|
|
287
|
+
- `currentPassword` and `newPassword` (only available when Default authentication method is enabled)
|
|
288
|
+
|
|
289
|
+
**Response:**
|
|
290
|
+
```json
|
|
291
|
+
{
|
|
292
|
+
"message": "Profile updated successfully.",
|
|
293
|
+
"user": {
|
|
294
|
+
"id": 1,
|
|
295
|
+
"username": "user1234",
|
|
296
|
+
"email": "user@example.com",
|
|
297
|
+
"phone_no": "+1234567890",
|
|
298
|
+
"first_name": "John",
|
|
299
|
+
"last_name": "Doe",
|
|
300
|
+
"display_name": "John Doe",
|
|
301
|
+
"company_name": "WebbyCrown Solutions",
|
|
302
|
+
"confirmed": true,
|
|
303
|
+
"blocked": false,
|
|
304
|
+
"updatedAt": "2024-01-01T12:00:00.000Z"
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## 📍 Address Management APIs
|
|
310
|
+
|
|
311
|
+
### Get All Addresses
|
|
312
|
+
```
|
|
313
|
+
GET /api/{prefix}/addresses
|
|
314
|
+
Authorization: Bearer YOUR_JWT_TOKEN
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
**Query Parameters:**
|
|
318
|
+
- `type` (optional): Filter by type (0=billing, 1=shipping)
|
|
319
|
+
|
|
320
|
+
**Response:**
|
|
321
|
+
```json
|
|
322
|
+
{
|
|
323
|
+
"data": [
|
|
324
|
+
{
|
|
325
|
+
"id": 1,
|
|
326
|
+
"type": 0,
|
|
327
|
+
"first_name": "John",
|
|
328
|
+
"last_name": "Doe",
|
|
329
|
+
"company_name": "WebbyCrown Solutions",
|
|
330
|
+
"country": "United States",
|
|
331
|
+
"region": "California",
|
|
332
|
+
"city": "San Francisco",
|
|
333
|
+
"street_address": "123 Main Street",
|
|
334
|
+
"postcode": "94102",
|
|
335
|
+
"phone": "+1234567890",
|
|
336
|
+
"email_address": "john@example.com",
|
|
337
|
+
"createdAt": "2024-01-01T00:00:00.000Z",
|
|
338
|
+
"updatedAt": "2024-01-01T00:00:00.000Z"
|
|
339
|
+
}
|
|
340
|
+
]
|
|
341
|
+
}
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### Get Single Address
|
|
345
|
+
```
|
|
346
|
+
GET /api/{prefix}/addresses/:id
|
|
347
|
+
Authorization: Bearer YOUR_JWT_TOKEN
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### Create Address
|
|
351
|
+
```
|
|
352
|
+
POST /api/{prefix}/addresses
|
|
353
|
+
Authorization: Bearer YOUR_JWT_TOKEN
|
|
354
|
+
Content-Type: application/json
|
|
355
|
+
|
|
356
|
+
{
|
|
357
|
+
"type": 0,
|
|
358
|
+
"first_name": "John",
|
|
359
|
+
"last_name": "Doe",
|
|
360
|
+
"company_name": "WebbyCrown Solutions",
|
|
361
|
+
"country": "United States",
|
|
362
|
+
"region": "California",
|
|
363
|
+
"city": "San Francisco",
|
|
364
|
+
"street_address": "123 Main Street",
|
|
365
|
+
"postcode": "94102",
|
|
366
|
+
"phone": "+1234567890",
|
|
367
|
+
"email_address": "john@example.com"
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
**Required Fields:**
|
|
372
|
+
- `type` (0=billing, 1=shipping)
|
|
373
|
+
- `first_name`
|
|
374
|
+
- `last_name`
|
|
375
|
+
- `country`
|
|
376
|
+
- `city`
|
|
377
|
+
- `street_address`
|
|
378
|
+
- `postcode`
|
|
379
|
+
- `phone`
|
|
380
|
+
- `email_address` (required for billing addresses, type=0)
|
|
381
|
+
|
|
382
|
+
**Optional Fields:**
|
|
383
|
+
- `company_name`
|
|
384
|
+
- `region`
|
|
385
|
+
|
|
386
|
+
**Single Address Mode:**
|
|
387
|
+
- In single address mode, only one billing (type=0) and one shipping (type=1) address are allowed per user
|
|
388
|
+
- Attempting to create a duplicate address type returns `403 Forbidden`
|
|
389
|
+
|
|
390
|
+
**Multiple Address Mode:**
|
|
391
|
+
- Users can create unlimited addresses
|
|
392
|
+
|
|
393
|
+
### Update Address
|
|
394
|
+
```
|
|
395
|
+
PUT /api/{prefix}/addresses/:id
|
|
396
|
+
Authorization: Bearer YOUR_JWT_TOKEN
|
|
397
|
+
Content-Type: application/json
|
|
398
|
+
|
|
399
|
+
{
|
|
400
|
+
"street_address": "456 Updated Street",
|
|
401
|
+
"city": "Los Angeles"
|
|
402
|
+
}
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
All fields are optional. Only provided fields will be updated.
|
|
406
|
+
|
|
407
|
+
### Delete Address
|
|
408
|
+
```
|
|
409
|
+
DELETE /api/{prefix}/addresses/:id
|
|
410
|
+
Authorization: Bearer YOUR_JWT_TOKEN
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
## 🔒 Security Features
|
|
414
|
+
|
|
415
|
+
### Permission System
|
|
416
|
+
- All endpoints require the **Enable** permission to be granted in Users & Permissions
|
|
417
|
+
- Custom permission checking via `ensureEcommercePermission` utility
|
|
418
|
+
|
|
419
|
+
### Origin Validation
|
|
420
|
+
- CORS protection through allowed frontend domains configuration
|
|
421
|
+
- API token validation for additional security layers
|
|
422
|
+
|
|
423
|
+
### Authentication Enforcement
|
|
424
|
+
- JWT token validation for protected endpoints
|
|
425
|
+
- User-specific data isolation (users can only access their own data)
|
|
426
|
+
|
|
427
|
+
### Input Validation
|
|
428
|
+
- Comprehensive field validation (required fields, email format, etc.)
|
|
429
|
+
- Type checking and sanitization
|
|
430
|
+
- Unique constraint validation (email, phone_no)
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
### Key Components
|
|
434
|
+
|
|
435
|
+
**Controllers:**
|
|
436
|
+
- `auth.js`: Authentication and profile management
|
|
437
|
+
- `address.js`: Address CRUD operations
|
|
438
|
+
- `controller.js`: Plugin settings management
|
|
439
|
+
- `shipping.js`: Shipping CRUD operations
|
|
440
|
+
- `product.js`: Product CRUD operations
|
|
441
|
+
- `order.js`: Order CRUD operations
|
|
442
|
+
- `cart.js`: Cart CRUD operations
|
|
443
|
+
- `payment.js`: Payment CRUD operations
|
|
444
|
+
- `review.js`: Review CRUD operations
|
|
445
|
+
- `wishlist.js`: Wishlist CRUD operations
|
|
446
|
+
- `webhook.js`: Webhook CRUD operations
|
|
447
|
+
- `coupon.js`: Coupon CRUD operations
|
|
448
|
+
|
|
449
|
+
**Utilities:**
|
|
450
|
+
- `check-ecommerce-permission.js`: Permission validation
|
|
451
|
+
- `send-email.js`: Email sending (SMTP or Strapi email plugin)
|
|
452
|
+
|
|
453
|
+
### Database Schema
|
|
454
|
+
|
|
455
|
+
**User Extensions:**
|
|
456
|
+
- Custom fields added to `plugin::users-permissions.user`
|
|
457
|
+
- Relations to addresses
|
|
458
|
+
|
|
459
|
+
**Address Content Type:**
|
|
460
|
+
- Created automatically as `api::address.address`
|
|
461
|
+
- Many-to-one relation with users
|
|
462
|
+
|
|
463
|
+
## 📝 Development Notes
|
|
464
|
+
|
|
465
|
+
2. Test endpoints using:
|
|
466
|
+
- Postman
|
|
467
|
+
- cURL
|
|
468
|
+
- The API Collections page in admin panel
|
|
469
|
+
|
|
470
|
+
3. Check logs for errors:
|
|
471
|
+
```bash
|
|
472
|
+
# Strapi logs will show plugin-specific errors with [webbycommerce] prefix
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
## 🐛 Troubleshooting
|
|
476
|
+
|
|
477
|
+
### OTP Not Sending
|
|
478
|
+
- Check SMTP configuration in **Configure** tab
|
|
479
|
+
- Verify email plugin is configured (fallback)
|
|
480
|
+
- Check server logs for email errors
|
|
481
|
+
|
|
482
|
+
### 401 Unauthorized Errors
|
|
483
|
+
- Verify JWT token is valid and not expired
|
|
484
|
+
- Check that **Enable** permission is granted in Users & Permissions
|
|
485
|
+
- Ensure token is included in `Authorization: Bearer <token>` header
|
|
486
|
+
|
|
487
|
+
### 403 Forbidden on Address Creation
|
|
488
|
+
- Check shipping type mode (single vs multiple)
|
|
489
|
+
- In single mode, update existing address instead of creating duplicate
|
|
490
|
+
|
|
491
|
+
### 404 Not Found
|
|
492
|
+
- Verify route prefix matches configuration
|
|
493
|
+
- Check that plugin is enabled in `config/plugins.js`
|
|
494
|
+
- Restart Strapi after configuration changes
|
|
495
|
+
|
|
496
|
+
### Schema Errors
|
|
497
|
+
- Ensure user schema extension is properly configured
|
|
498
|
+
- Restart Strapi after schema changes
|
|
499
|
+
- Check that all required fields are present in schema
|
|
500
|
+
|
|
501
|
+
### API Collections
|
|
502
|
+
- The API Collections page in admin panel shows all available endpoints
|
|
503
|
+
- Use this page to test endpoints and view responses
|
|
504
|
+
|
|
505
|
+
---
|
|
506
|
+
|
|
507
|
+
## 📜 Changelog
|
|
508
|
+
|
|
509
|
+
### [1.0.0] – Initial Stable Release
|
|
510
|
+
|
|
511
|
+
🎉 First production-ready release of WebbyCommerce, a complete ecommerce backend plugin for Strapi CMS.
|
|
512
|
+
|
|
513
|
+
✨ Added
|
|
514
|
+
#### Core Plugin
|
|
515
|
+
|
|
516
|
+
- Drop-in ecommerce backend for Strapi with zero manual setup
|
|
517
|
+
- Automatic creation of required content types, routes, and controllers
|
|
518
|
+
- Admin panel integration for plugin configuration
|
|
519
|
+
- Customizable API route prefix support
|
|
520
|
+
- Allowed frontend domain (CORS) configuration
|
|
521
|
+
|
|
522
|
+
#### Authentication
|
|
523
|
+
|
|
524
|
+
- Default authentication (Email / Password) using Strapi auth
|
|
525
|
+
- OTP-based authentication (Email / Mobile)
|
|
526
|
+
- OTP verification and login flow
|
|
527
|
+
- JWT-based authentication enforcement
|
|
528
|
+
- Automatic user creation for new OTP users
|
|
529
|
+
|
|
530
|
+
#### User Management
|
|
531
|
+
|
|
532
|
+
- User profile APIs (get & update)
|
|
533
|
+
- Automatic user schema extension with ecommerce fields
|
|
534
|
+
- first_name, last_name
|
|
535
|
+
- phone_no
|
|
536
|
+
- display_name, company_name
|
|
537
|
+
- OTP-related fields
|
|
538
|
+
- Secure password update support (default auth)
|
|
539
|
+
|
|
540
|
+
#### Address Management
|
|
541
|
+
|
|
542
|
+
- Automatic Address content type creation
|
|
543
|
+
- Billing and Shipping address support
|
|
544
|
+
- Single-address mode (1 billing + 1 shipping)
|
|
545
|
+
- Multiple-address mode (unlimited addresses)
|
|
546
|
+
- Full CRUD APIs with user-level data isolation
|
|
547
|
+
|
|
548
|
+
#### Ecommerce APIs
|
|
549
|
+
|
|
550
|
+
- Cart management
|
|
551
|
+
- Order management
|
|
552
|
+
- Product management
|
|
553
|
+
- Shipping management
|
|
554
|
+
- Payment handling
|
|
555
|
+
- Coupon management
|
|
556
|
+
- Wishlist functionality
|
|
557
|
+
- Product reviews
|
|
558
|
+
- Webhook handling
|
|
559
|
+
|
|
560
|
+
#### Admin Configuration
|
|
561
|
+
|
|
562
|
+
- SMTP configuration for OTP & notifications
|
|
563
|
+
- Authentication method selection (Default / OTP)
|
|
564
|
+
- Shipping address mode configuration
|
|
565
|
+
- Centralized plugin settings UI in Strapi admin
|
|
566
|
+
|
|
567
|
+
#### Security
|
|
568
|
+
|
|
569
|
+
- Permission-based API access control
|
|
570
|
+
- Custom ecommerce permission validator
|
|
571
|
+
- JWT validation for protected routes
|
|
572
|
+
- User-owned resource access enforcement
|
|
573
|
+
- Input validation & sanitization
|
|
574
|
+
- Unique constraint validation (email, phone)
|
|
575
|
+
|
|
576
|
+
#### Developer Experience
|
|
577
|
+
|
|
578
|
+
- Built-in API Collections documentation in admin panel
|
|
579
|
+
- Request/response examples for all endpoints
|
|
580
|
+
- cURL examples for testing
|
|
581
|
+
- Clear plugin-specific logging with [webbycommerce] prefix
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
## Author
|
|
585
|
+
|
|
586
|
+
**WebbyCrown**
|
|
587
|
+
- Email: info@webbycrown.com
|
|
588
|
+
- Website: https://webbycrown.com
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
[2026-01-20T07:18:40.892Z] Starting setup script
|
|
2
|
+
[2026-01-20T07:18:40.900Z] Platform: Windows. Opening CONIN$ and CONOUT$
|
|
3
|
+
[2026-01-20T07:18:40.901Z] Failed to open TTY: ENOENT: no such file or directory, open 'D:\chandrika\webbycrown-ecommerce-strapi\src\plugins\webbycommerce\CONIN$'
|
|
4
|
+
[2026-01-20T07:19:24.844Z] Starting setup script
|
|
5
|
+
[2026-01-20T07:19:24.845Z] Platform: Windows. Opening CONIN$ and CONOUT$
|
|
6
|
+
[2026-01-20T07:19:24.846Z] Failed to open TTY: ENOENT: no such file or directory, open 'D:\chandrika\webbycrown-ecommerce-strapi\src\plugins\webbycommerce\CONIN$'
|