spurtcommerce 6.0.0 → 6.0.1
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/README.md +196 -316
- package/package.json +2 -2
- package/spurtcommerce-6.0.0.tgz +0 -0
package/README.md
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
<br>
|
|
7
7
|
🚀 <strong>SpurtCommerce v6.0</strong>
|
|
8
8
|
<br>
|
|
9
|
-
<!-- B2C & B2B APIs -->
|
|
10
9
|
</div>
|
|
11
10
|
</h1>
|
|
12
11
|
|
|
@@ -29,398 +28,281 @@
|
|
|
29
28
|
> This documentation explains how to install, configure, run, and deploy the B2C Single Vendor backend API.
|
|
30
29
|
|
|
31
30
|
---
|
|
31
|
+
# Spurtcommerce Project Setup Guide
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
SpurtCommerce **6.0 B2C & B2B APIs** is a backend application built using:
|
|
36
|
-
|
|
37
|
-
* Node.js
|
|
38
|
-
* TypeScript
|
|
39
|
-
* TypeORM
|
|
40
|
-
* MySQL
|
|
41
|
-
|
|
42
|
-
This guide covers the complete backend setup including:
|
|
43
|
-
|
|
44
|
-
* Prerequisites
|
|
45
|
-
* Backend installation
|
|
46
|
-
* Environment configuration
|
|
47
|
-
* Database setup
|
|
48
|
-
* Tenant identification
|
|
49
|
-
* API startup
|
|
50
|
-
* API access
|
|
51
|
-
* Troubleshooting
|
|
33
|
+
A complete, step-by-step guide explaining how to set up a Spurtcommerce backend project from scratch using Node.js, what files and folders are required, what each component does, how to install Spurtcommerce via npm, and how to configure database, email sending, and demo data.
|
|
52
34
|
|
|
53
35
|
---
|
|
54
36
|
|
|
55
|
-
##
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
mysql --version
|
|
70
|
-
git --version
|
|
71
|
-
```
|
|
37
|
+
## Table of Contents
|
|
38
|
+
1. [Required Project File Structure](#1-required-project-file-structure)
|
|
39
|
+
2. [Why Each File and Folder Exists & Its Contents](#2-why-each-file-and-folder-exists--its-contents)
|
|
40
|
+
- [2.1 `.env`](#21-env)
|
|
41
|
+
- [2.2 `main.js`](#22-mainjs)
|
|
42
|
+
- [2.3 `package.json`](#23-packagejson)
|
|
43
|
+
- [2.4 `webHookConfig.json`](#24-webhookconfigjson)
|
|
44
|
+
- [2.5 `views/` Directory](#25-views-directory)
|
|
45
|
+
- [2.6 `demoData/` Directory](#26-demodata-directory)
|
|
46
|
+
- [2.7 `spurtcommerce.sql` (Database Baseline Dump)](#27-spurtcommercesql-database-baseline-dump)
|
|
47
|
+
3. [Step-by-Step Installation Procedure (From Scratch)](#3-step-by-step-installation-procedure-from-scratch)
|
|
48
|
+
4. [Upstream Package Patch (`src/app.js`) & Why It Is Needed](#4-upstream-package-patch-srcappjs--why-it-is-needed)
|
|
49
|
+
5. [Automated Patching via `postinstall` (Recommended)](#5-automated-patching-via-postinstall-recommended)
|
|
50
|
+
6. [How to Run & Verify the Server](#6-how-to-run--verify-the-server)
|
|
72
51
|
|
|
73
52
|
---
|
|
74
53
|
|
|
75
|
-
##
|
|
54
|
+
## 1. Required Project File Structure
|
|
76
55
|
|
|
77
|
-
|
|
56
|
+
To run Spurtcommerce in Node.js with working email dispatch and demo data, your project directory must contain the following files and folders:
|
|
78
57
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
58
|
+
```text
|
|
59
|
+
my-spurtcommerce-project/
|
|
60
|
+
├── .env <-- Environment configuration (Database credentials, Port, Mail SMTP)
|
|
61
|
+
├── main.js <-- Application entry point (boots Spurtcommerce)
|
|
62
|
+
├── package.json <-- Project dependencies, scripts & auto-patching
|
|
63
|
+
├── webHookConfig.json <-- Webhook routing configuration (routes send_email to mailer)
|
|
64
|
+
├── views/ <-- Email HTML/EJS templates (invoice-order.ejs, storeTemplate.ejs, etc.)
|
|
65
|
+
├── demoData/ <-- Seed catalogs, demo images, and industry product datasets
|
|
66
|
+
└── node_modules/ <-- Installed packages (contains Spurtcommerce)
|
|
83
67
|
```
|
|
84
68
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
Install all required Node.js dependencies.
|
|
88
|
-
|
|
89
|
-
```bash
|
|
90
|
-
npm install
|
|
91
|
-
```
|
|
69
|
+
---
|
|
92
70
|
|
|
93
|
-
|
|
71
|
+
## 2. Why Each File and Folder Exists & Its Contents
|
|
94
72
|
|
|
95
|
-
|
|
73
|
+
### 2.1 `.env`
|
|
74
|
+
#### Why is `.env` needed?
|
|
75
|
+
Spurtcommerce reads environment variables upon startup to connect to MySQL, bind the server port, configure loggers, set API route prefixes, and configure SMTP mail credentials.
|
|
96
76
|
|
|
77
|
+
#### Key Variables Required:
|
|
97
78
|
```env
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
79
|
+
# Application Settings
|
|
80
|
+
APP_NAME=spurtcommerce
|
|
81
|
+
APP_SCHEMA=http
|
|
82
|
+
APP_HOST=localhost
|
|
83
|
+
APP_PORT=8000
|
|
84
|
+
APP_ROUTE_PREFIX=/api
|
|
85
|
+
APP_BANNER=true
|
|
86
|
+
|
|
87
|
+
# Database (MySQL) Connection
|
|
88
|
+
TYPEORM_CONNECTION=mysql
|
|
89
|
+
TYPEORM_HOST=localhost
|
|
90
|
+
TYPEORM_PORT=3306
|
|
91
|
+
TYPEORM_USERNAME=root
|
|
92
|
+
TYPEORM_PASSWORD=your_mysql_password
|
|
93
|
+
TYPEORM_DATABASE=your_database_name
|
|
94
|
+
TYPEORM_SYNCHRONIZE=false
|
|
95
|
+
TYPEORM_LOGGING=["query", "error"]
|
|
96
|
+
TYPEORM_LOGGER=advanced-console
|
|
97
|
+
|
|
98
|
+
# Path Structures for TypeORM
|
|
99
|
+
TYPEORM_MIGRATIONS=src/database/migrations/**/*.ts
|
|
100
|
+
TYPEORM_MIGRATIONS_DIR=src/database/migrations
|
|
101
|
+
TYPEORM_ENTITIES=src/api/models/**/*.ts,src/plugin-manager/models/**/*.ts
|
|
102
|
+
TYPEORM_ENTITIES_DIR=src/api/models
|
|
103
|
+
|
|
104
|
+
# Mail (SMTP / Gmail) Configuration
|
|
105
|
+
MAIL_DRIVER=smtp
|
|
106
|
+
MAIL_HOST=smtp.gmail.com
|
|
107
|
+
MAIL_PORT=587
|
|
108
|
+
MAIL_USERNAME=your_email@gmail.com
|
|
109
|
+
MAIL_PASSWORD=your_16_digit_app_password
|
|
110
|
+
MAIL_SECURE=false
|
|
111
|
+
MAIL_ENCRYPTION=tls
|
|
112
|
+
MAIL_FROM=your_email@gmail.com
|
|
110
113
|
```
|
|
111
114
|
|
|
112
|
-
> [!NOTE]
|
|
113
|
-
> Replace all placeholder values with the configuration values from your own environment.
|
|
114
|
-
|
|
115
115
|
---
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
### 2.2 `main.js`
|
|
118
|
+
#### Why is `main.js` needed?
|
|
119
|
+
`main.js` is the executable entry file for Node.js. Spurtcommerce's `src/app.js` is **self-bootstrapping** — it automatically executes `bootstrapMicroframework` and starts all loaders as soon as it is imported. Therefore, you do not need to call any separate `.start()` function.
|
|
120
120
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
CREATE DATABASE <YOUR_DB_NAME>;
|
|
121
|
+
#### Exact Contents of `main.js`:
|
|
122
|
+
```javascript
|
|
123
|
+
import 'spurtcommerce';
|
|
125
124
|
```
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
If a SQL backup is provided, import it using:
|
|
130
|
-
|
|
131
|
-
```bash
|
|
132
|
-
mysql -u <YOUR_DB_USERNAME> -p <YOUR_DB_NAME> < <YOUR_SQL_BACKUP_FILE>
|
|
125
|
+
*(Or in CommonJS)*:
|
|
126
|
+
```javascript
|
|
127
|
+
require('spurtcommerce');
|
|
133
128
|
```
|
|
134
129
|
|
|
135
|
-
### 3. Run Migrations
|
|
136
|
-
|
|
137
|
-
If the project uses TypeORM migrations, run the migration command configured in the backend `package.json`.
|
|
138
|
-
|
|
139
|
-
```bash
|
|
140
|
-
<TYPEORM_MIGRATION_COMMAND>
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
> [!NOTE]
|
|
144
|
-
> Use the migration command configured in the SpurtCommerce 6.0 project. The exact command may vary depending on the project configuration.
|
|
145
|
-
|
|
146
130
|
---
|
|
147
131
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
132
|
+
### 2.3 `package.json`
|
|
133
|
+
#### Why is `package.json` needed?
|
|
134
|
+
It manages your project's npm packages (`spurtcommerce`), defines run commands (`npm start`), and automates required patches using npm's lifecycle hooks (`postinstall`).
|
|
135
|
+
|
|
136
|
+
#### Exact Contents of `package.json`:
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"name": "my-spurtcommerce-project",
|
|
140
|
+
"version": "1.0.0",
|
|
141
|
+
"main": "main.js",
|
|
142
|
+
"scripts": {
|
|
143
|
+
"start": "node main.js",
|
|
144
|
+
"postinstall": "node -e \"const fs=require('fs'); const p='./node_modules/spurtcommerce/package.json'; if(fs.existsSync(p)){ const j=JSON.parse(fs.readFileSync(p)); if(j.main!=='src/app.js'){ j.main='src/app.js'; fs.writeFileSync(p, JSON.stringify(j,null,4)); console.log('✅ Spurtcommerce entry point set to src/app.js'); } }\""
|
|
145
|
+
},
|
|
146
|
+
"dependencies": {
|
|
147
|
+
"spurtcommerce": "^6.0.0"
|
|
148
|
+
}
|
|
149
|
+
}
|
|
160
150
|
```
|
|
161
151
|
|
|
162
|
-
|
|
152
|
+
---
|
|
163
153
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
154
|
+
### 2.4 `webHookConfig.json`
|
|
155
|
+
#### Why is `webHookConfig.json` needed?
|
|
156
|
+
In Spurtcommerce V6, email notifications (order invoices, customer registration, password reset) are decoupled from controllers. When an order is placed, Spurtcommerce triggers a `send_email` event. Spurtcommerce looks for `webHookConfig.json` in the root folder to route this event to its internal mail client (`/api/webhook-client`), which sends the actual email using Nodemailer and your `.env` SMTP credentials.
|
|
167
157
|
|
|
168
|
-
|
|
158
|
+
If this file is missing or empty, orders will succeed in the API, but **no emails will be delivered**.
|
|
169
159
|
|
|
170
|
-
|
|
171
|
-
|
|
160
|
+
#### Exact Contents of `webHookConfig.json`:
|
|
161
|
+
```json
|
|
162
|
+
{
|
|
163
|
+
"send_email": {
|
|
164
|
+
"api": "http://localhost:{{PORT}}/api/webhook-client"
|
|
165
|
+
}
|
|
166
|
+
}
|
|
172
167
|
```
|
|
173
168
|
|
|
174
169
|
---
|
|
175
170
|
|
|
176
|
-
|
|
171
|
+
### 2.5 `views/` Directory
|
|
172
|
+
#### Why is `views/` needed?
|
|
173
|
+
The `views/` folder contains the EJS email templates and static assets used during email generation:
|
|
174
|
+
* `invoice-order.ejs`: Template rendered when an order confirmation email is sent to the customer.
|
|
175
|
+
* `storeTemplate.ejs`: General store email layout template.
|
|
176
|
+
* `emailTemplates.ejs`: Customer registration and notifications template.
|
|
177
|
+
* `abandonedCartTemplate.ejs`: Abandoned cart reminder email template.
|
|
178
|
+
* `views/assets/`: Static image assets and logos included in email headers.
|
|
177
179
|
|
|
178
|
-
|
|
180
|
+
> **Action**: Copy the `views/` directory from `node_modules/spurtcommerce/views` directly into your project root. Without this folder, email dispatch fails with `ENOENT: no such file or directory, open '.../views/invoice-order.ejs'`.
|
|
179
181
|
|
|
180
|
-
|
|
181
|
-
B2C API Request
|
|
182
|
-
│
|
|
183
|
-
▼
|
|
184
|
-
TenantValidationMiddleware
|
|
185
|
-
│
|
|
186
|
-
▼
|
|
187
|
-
Static APP_ID / Application ID
|
|
188
|
-
│
|
|
189
|
-
▼
|
|
190
|
-
Vendor Lookup
|
|
191
|
-
│
|
|
192
|
-
▼
|
|
193
|
-
Tenant ID
|
|
194
|
-
│
|
|
195
|
-
▼
|
|
196
|
-
Controller
|
|
197
|
-
│
|
|
198
|
-
▼
|
|
199
|
-
Service
|
|
200
|
-
│
|
|
201
|
-
▼
|
|
202
|
-
TypeORM
|
|
203
|
-
│
|
|
204
|
-
▼
|
|
205
|
-
MySQL Database
|
|
206
|
-
```
|
|
182
|
+
---
|
|
207
183
|
|
|
208
|
-
###
|
|
184
|
+
### 2.6 `demoData/` Directory
|
|
185
|
+
#### Why is `demoData/` needed?
|
|
186
|
+
The `demoData/` folder contains initial catalog datasets and images:
|
|
187
|
+
* `demoData/images/`: Default sample images.
|
|
188
|
+
* `demoData/IndustryData/`: Industry-specific product datasets (Electronics, Fashion, Grocery, etc.) and category trees.
|
|
189
|
+
* `demoData/CommonData.json`: Common seed payload used by `VendorDemoDataMigrateHook` when initializing demo vendor stores.
|
|
209
190
|
|
|
210
|
-
|
|
211
|
-
Client
|
|
212
|
-
↓
|
|
213
|
-
B2C API
|
|
214
|
-
↓
|
|
215
|
-
TenantValidationMiddleware
|
|
216
|
-
↓
|
|
217
|
-
APP_ID
|
|
218
|
-
↓
|
|
219
|
-
Vendor
|
|
220
|
-
↓
|
|
221
|
-
Tenant ID
|
|
222
|
-
↓
|
|
223
|
-
Controller
|
|
224
|
-
↓
|
|
225
|
-
Service
|
|
226
|
-
↓
|
|
227
|
-
TypeORM
|
|
228
|
-
↓
|
|
229
|
-
MySQL
|
|
230
|
-
```
|
|
191
|
+
> **Action**: Copy the `demoData/` directory from `node_modules/spurtcommerce/demoData` directly into your project root so vendor store setup and demo migration features function properly.
|
|
231
192
|
|
|
232
193
|
---
|
|
233
194
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
195
|
+
### 2.7 `spurtcommerce.sql` (Database Baseline Dump)
|
|
196
|
+
#### Why is `spurtcommerce.sql` provided?
|
|
197
|
+
`spurtcommerce.sql` is bundled directly inside `node_modules/spurtcommerce/spurtcommerce.sql`. It contains the complete baseline database schema, essential system settings, core plugin entries, default admin roles, user permissions, and email templates required to boot Spurtcommerce without having to construct tables manually.
|
|
237
198
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
| `TYPEORM_HOST` | MySQL database host |
|
|
244
|
-
| `TYPEORM_PORT` | MySQL database port |
|
|
245
|
-
| `TYPEORM_USERNAME` | MySQL database username |
|
|
246
|
-
| `TYPEORM_PASSWORD` | MySQL database password |
|
|
247
|
-
| `TYPEORM_DATABASE` | MySQL database name |
|
|
248
|
-
| `APP_PORT` | Port on which the backend API runs |
|
|
199
|
+
#### How to import:
|
|
200
|
+
You can directly import this SQL file into your target MySQL database:
|
|
201
|
+
```bash
|
|
202
|
+
mysql -u <username> -p <database_name> < node_modules/spurtcommerce/spurtcommerce.sql
|
|
203
|
+
```
|
|
249
204
|
|
|
250
205
|
---
|
|
251
206
|
|
|
252
|
-
##
|
|
207
|
+
## 3. Step-by-Step Installation Procedure (From Scratch)
|
|
253
208
|
|
|
254
|
-
|
|
209
|
+
Follow these exact steps to create and run a fresh Spurtcommerce project:
|
|
255
210
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
```text
|
|
261
|
-
app-id
|
|
211
|
+
### Step 1: Create Project Directory
|
|
212
|
+
```bash
|
|
213
|
+
mkdir my-spurtcommerce-project
|
|
214
|
+
cd my-spurtcommerce-project
|
|
262
215
|
```
|
|
263
216
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
APP_ID
|
|
217
|
+
### Step 2: Initialize `package.json`
|
|
218
|
+
```bash
|
|
219
|
+
npm init -y
|
|
268
220
|
```
|
|
269
221
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
```typescript
|
|
275
|
-
req.tenantId
|
|
222
|
+
### Step 3: Install Spurtcommerce
|
|
223
|
+
```bash
|
|
224
|
+
npm install spurtcommerce
|
|
276
225
|
```
|
|
277
226
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
> [!IMPORTANT]
|
|
281
|
-
> For a single-vendor deployment, keep the `APP_ID`, `TENANT_ID`, and corresponding vendor/application database records consistent.
|
|
282
|
-
|
|
283
|
-
---
|
|
284
|
-
|
|
285
|
-
## ❯ 🌐 Referer Header
|
|
227
|
+
### Step 4: Create `.env`
|
|
228
|
+
Create a `.env` file in your project root with your MySQL database credentials, server port, and SMTP settings.
|
|
286
229
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
`getVendorDomainOrDefault()` can use:
|
|
230
|
+
### Step 5: Import Database Dump (`spurtcommerce.sql`)
|
|
231
|
+
Import the bundled `spurtcommerce.sql` from `node_modules/spurtcommerce/` into your MySQL database:
|
|
232
|
+
```bash
|
|
233
|
+
# Create the database in MySQL (if it doesn't already exist)
|
|
234
|
+
mysql -u root -p -e "CREATE DATABASE IF NOT EXISTS your_database_name;"
|
|
294
235
|
|
|
295
|
-
|
|
296
|
-
|
|
236
|
+
# Import the initial database tables and seed data
|
|
237
|
+
mysql -u root -p your_database_name < node_modules/spurtcommerce/spurtcommerce.sql
|
|
297
238
|
```
|
|
298
239
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
Use the following credentials to test the login flow.
|
|
305
|
-
|
|
306
|
-
Field Value
|
|
307
|
-
Email ID community@spurtcart.com
|
|
308
|
-
password Demo1234
|
|
309
|
-
|
|
310
|
-
[!NOTE]
|
|
311
|
-
|
|
312
|
-
The password Demo1234 is provided for local/development testing.
|
|
313
|
-
|
|
314
|
-
Login Flow
|
|
315
|
-
Open the B2C application.
|
|
316
|
-
Enter the registered email address:
|
|
317
|
-
community@spurtcart.com
|
|
318
|
-
Enter the password:
|
|
319
|
-
Demo1234
|
|
320
|
-
Complete the login process.
|
|
321
|
-
Continue with the authenticated API requests.
|
|
322
|
-
|
|
323
|
-
---
|
|
324
|
-
## ❯ 🔌 API Access
|
|
325
|
-
|
|
326
|
-
Once the SpurtCommerce 6.0 backend is running, the API can be accessed using the configured backend URL.
|
|
327
|
-
|
|
328
|
-
```text
|
|
329
|
-
http://localhost:<YOUR_API_PORT>
|
|
240
|
+
### Step 6: Create `main.js`
|
|
241
|
+
Create a `main.js` file in your project root:
|
|
242
|
+
```javascript
|
|
243
|
+
import 'spurtcommerce';
|
|
330
244
|
```
|
|
331
245
|
|
|
332
|
-
###
|
|
333
|
-
|
|
334
|
-
```
|
|
335
|
-
|
|
246
|
+
### Step 7: Create `webHookConfig.json`
|
|
247
|
+
Create a `webHookConfig.json` file in your project root with the following configuration:
|
|
248
|
+
```json
|
|
249
|
+
{
|
|
250
|
+
"send_email": {
|
|
251
|
+
"api": "http://localhost:{{PORT}}/api/webhook-client"
|
|
252
|
+
}
|
|
253
|
+
}
|
|
336
254
|
```
|
|
337
255
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
```text
|
|
345
|
-
http://localhost:<YOUR_API_PORT>/apidoc/
|
|
256
|
+
### Step 8: Copy `views/` and `demoData/` Folders
|
|
257
|
+
Copy the `views/` and `demoData/` directories from `node_modules/spurtcommerce/` into your project root:
|
|
258
|
+
```bash
|
|
259
|
+
cp -r node_modules/spurtcommerce/views ./
|
|
260
|
+
cp -r node_modules/spurtcommerce/demoData ./
|
|
346
261
|
```
|
|
347
|
-
|
|
348
|
-
### Example
|
|
349
|
-
|
|
350
262
|
```text
|
|
351
|
-
|
|
263
|
+
my-spurtcommerce-project/
|
|
264
|
+
├── views/
|
|
265
|
+
└── demoData/
|
|
352
266
|
```
|
|
353
267
|
|
|
354
268
|
---
|
|
355
269
|
|
|
356
|
-
##
|
|
270
|
+
## 4. Upstream Package Patch (`src/app.js`) & Why It Is Needed
|
|
357
271
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
272
|
+
* **The Problem**: In the published `spurtcommerce` npm package, line 5 of `package.json` defines `"main": "src/app.ts"`. Node.js runtime cannot execute `.ts` files natively. Running `node main.js` causes:
|
|
273
|
+
`Error: Cannot find package '.../node_modules/spurtcommerce/src/app.ts' imported from main.js`
|
|
274
|
+
* **The Clean Fix**: Update line 5 in `node_modules/spurtcommerce/package.json` to point to the compiled JavaScript entry file:
|
|
275
|
+
```json
|
|
276
|
+
"main": "src/app.js"
|
|
277
|
+
```
|
|
278
|
+
* **Why `src/app.js` is ideal**:
|
|
279
|
+
`src/app.js` automatically bootstraps the microframework and boots all loaders. When your `main.js` contains `import 'spurtcommerce'`, Node.js loads `src/app.js` and immediately starts the application. No separate bridge files (`index.js`) or `.start()` method calls are required.
|
|
366
280
|
|
|
367
281
|
---
|
|
368
282
|
|
|
369
|
-
##
|
|
370
|
-
|
|
371
|
-
For a quick local setup:
|
|
372
|
-
|
|
373
|
-
### 1. Navigate to Backend
|
|
374
|
-
|
|
375
|
-
```bash
|
|
376
|
-
cd <BACKEND_DIRECTORY>
|
|
377
|
-
```
|
|
283
|
+
## 5. Automated Patching via `postinstall` (Recommended)
|
|
378
284
|
|
|
379
|
-
|
|
285
|
+
To avoid manually editing `node_modules/spurtcommerce/package.json` every time `npm install` is executed, configure the `postinstall` script in your project's root `package.json`:
|
|
380
286
|
|
|
381
|
-
```
|
|
382
|
-
|
|
287
|
+
```json
|
|
288
|
+
"scripts": {
|
|
289
|
+
"start": "node main.js",
|
|
290
|
+
"postinstall": "node -e \"const fs=require('fs'); const p='./node_modules/spurtcommerce/package.json'; if(fs.existsSync(p)){ const j=JSON.parse(fs.readFileSync(p)); if(j.main!=='src/app.js'){ j.main='src/app.js'; fs.writeFileSync(p, JSON.stringify(j,null,4)); console.log('✅ Spurtcommerce entry point set to src/app.js'); } }\""
|
|
291
|
+
}
|
|
383
292
|
```
|
|
384
293
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
Configure the following values:
|
|
388
|
-
|
|
389
|
-
```env
|
|
390
|
-
APP_TYPE=local
|
|
391
|
-
|
|
392
|
-
APP_ID=<YOUR_APP_ID>
|
|
393
|
-
TENANT_ID=<YOUR_TENANT_ID>
|
|
294
|
+
Now, every time `npm install` or `npm update` runs, npm automatically ensures the entry point points to `src/app.js`.
|
|
394
295
|
|
|
395
|
-
|
|
396
|
-
TYPEORM_PORT=<YOUR_DB_PORT>
|
|
397
|
-
TYPEORM_USERNAME=<YOUR_DB_USERNAME>
|
|
398
|
-
TYPEORM_PASSWORD=<YOUR_DB_PASSWORD>
|
|
399
|
-
TYPEORM_DATABASE=<YOUR_DB_NAME>
|
|
400
|
-
|
|
401
|
-
APP_PORT=<YOUR_API_PORT>
|
|
402
|
-
```
|
|
296
|
+
---
|
|
403
297
|
|
|
404
|
-
|
|
298
|
+
## 6. How to Run & Verify the Server
|
|
405
299
|
|
|
300
|
+
### Start the Server:
|
|
406
301
|
```bash
|
|
407
|
-
npm start
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
### 5. Open API
|
|
411
|
-
|
|
412
|
-
```text
|
|
413
|
-
http://localhost:<YOUR_API_PORT>
|
|
414
|
-
```
|
|
415
|
-
|
|
416
|
-
### 6. Open API Documentation
|
|
417
|
-
|
|
418
|
-
```text
|
|
419
|
-
http://localhost:<YOUR_API_PORT>/apidoc/
|
|
302
|
+
npm start
|
|
303
|
+
# or
|
|
304
|
+
node main.js
|
|
420
305
|
```
|
|
421
|
-
|
|
422
|
-
---
|
|
423
|
-
|
|
424
306
|
## ❯ 📋 Project Information
|
|
425
307
|
|
|
426
308
|
| Property | Value |
|
|
@@ -475,8 +357,6 @@ If you encounter an issue while installing or running the SpurtCommerce 6.0 B2C
|
|
|
475
357
|
|
|
476
358
|
**SpurtCommerce 6.0**
|
|
477
359
|
|
|
478
|
-
**Application:** B2C & B2B APIs
|
|
479
|
-
|
|
480
360
|
**Backend:** Node.js + TypeScript + TypeORM + MySQL
|
|
481
361
|
|
|
482
362
|
---
|
|
@@ -485,4 +365,4 @@ If you encounter an issue while installing or running the SpurtCommerce 6.0 B2C
|
|
|
485
365
|
<strong>SpurtCommerce 6.0 — B2C & B2B APIs</strong>
|
|
486
366
|
<br>
|
|
487
367
|
Backend Run & Deploy Guide
|
|
488
|
-
</p>
|
|
368
|
+
</p>
|
package/package.json
CHANGED
package/spurtcommerce-6.0.0.tgz
DELETED
|
Binary file
|