Compare commits

..
18 Commits
Author SHA1 Message Date
nobswebdev c2933734ee Show empty lines in product and blog descriptions. 2026-11-25 21:57:19 +00:00
nobswebdev 1d512bf582 List Electrum passwords in the deployment guide in sample env order. 2026-11-25 21:18:43 +00:00
nobswebdev 9e33aab9f9 Use the promo shield as the CMS favicon. 2026-11-25 21:16:16 +00:00
nobswebdev 32b3a83cd6 Accept only true and false for migration env flag.
Boolean conversion treated every non-empty string as enabled, so a typo could pass validation.
2026-11-25 20:56:54 +00:00
nobswebdev 1e7edda6f2 Disable nginx access and error request logs.
Request lines were keeping client addresses and paths for as long as the container existed.
2026-11-25 20:42:19 +00:00
nobswebdev 8b56a9a5a9 Serve /cms without a slash redirect.
Nginx was turning that redirect into an onion URL on port 8080, which Tor does not publish.
2026-11-25 20:15:39 +00:00
nobswebdev e0e06eefa4 Enable CORS only in development.
Production serves the CMS and API on one origin, so the allowlist is only needed while they run on separate ports.
2026-11-25 19:20:02 +00:00
nobswebdev cccc8596e6 Pin nginx, Postgres, and pgAdmin image versions.
Stops floating tags from changing the runtime on the next pull.
2026-11-25 19:01:55 +00:00
nobswebdev 35feda1278 Wrap long unbroken text in chat and delivery content.
overflow-wrap: anywhere lets addresses and similar strings break inside the bubble instead of stretching the layout.
2026-11-24 23:26:15 +00:00
nobswebdev a6e60408d6 change default electrum testnet server 2026-11-24 21:28:08 +00:00
nobswebdev 6ebb8161b9 Add product sortOrder for admin-controlled storefront list order.
Storefront and CMS lists sort by sortOrder ascending with createdAt descending as tie-break; existing rows default to 0.
2026-11-22 02:26:41 +00:00
nobswebdev ba0af1afd9 Preserve product-list scroll when switching variants.
Append #product-card-{variantId} to index selection links so the browser restores the card after the full-page reload, matching add-to-cart.
2026-11-21 23:34:44 +00:00
nobswebdev 3577c9dc16 npm audit fix 2026-11-21 23:13:03 +00:00
nobswebdev bf422b8529 add Whonix development instruction 2026-11-20 15:50:20 +00:00
nobswebdevandCursor ff5fbb649f Pin Electrum daemon to the configured server only.
Prevents auto-connect from hopping onto random public peers that can leave the wallet stuck at server height 0.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-17 21:57:57 +00:00
nobswebdev 633099371d add missing log about postgres running in backup.sh 2026-11-15 00:53:51 +01:00
nobswebdev ded7407090 Merge pull request 'Add interactive prod backup script for disaster-recovery archives.' (#10) from slave/backups into master
Reviewed-on: #10
2026-11-14 23:41:44 +00:00
nobswebdev f60fb7bbaf Add interactive prod backup script for disaster-recovery archives.
Document the workflow in the deployment guide and ignore secret-bearing backups under deploy/backups/.
2026-11-15 00:39:30 +01:00
40 changed files with 2215 additions and 1534 deletions
+1 -1
View File
@@ -114,7 +114,7 @@ BITCOIN_MIN_INCOMING_ATOMIC=7 # 0.00000007 BTC (~half a USD cent at that moment)
ELECTRUM_VERSION=4.8.1
ELECTRUM_NETWORK=testnet4
ELECTRUM_SERVER=testnet4-electrumx.wakiyamap.dev:51002:s
ELECTRUM_SERVER=blackie.c3-soft.com:57010:s
ELECTRUM_DAEMON_HOST=electrum-daemon
ELECTRUM_DAEMON_PORT=7777
ELECTRUM_DAEMON_RPC_USER=electrum
+1
View File
@@ -3,6 +3,7 @@
/deploy/certs
/deploy/certbot/www
/deploy/backups
/monero-wallet-rpc/wallet
/electrum-daemon/wallet
+37
View File
@@ -53,6 +53,43 @@ npm run typeorm:revert-migration
npm run typeorm:create-migration --name=<migration_name>
```
### Development on Whonix
Bridge networking needs a one-time Workstation firewall allow for `nullcart0` + `docker0` (sudo required).
`/usr/bin/user-firewall-script`:
```bash
#!/bin/bash
# nullcart0: running compose stack
nft insert rule inet filter forward iifname "nullcart0" counter accept
nft insert rule inet filter forward oifname "nullcart0" counter accept
# docker0: image builds (apk/apt/npm)
nft insert rule inet filter forward iifname "docker0" counter accept
nft insert rule inet filter forward oifname "docker0" counter accept
```
`/lib/systemd/system/whonix-firewall.service.d/50_user.conf`:
```
[Service]
ExecStartPost=/usr/bin/user-firewall-script
```
```bash
sudo chmod +x /usr/bin/user-firewall-script
sudo systemctl daemon-reload
sudo whonix_firewall
```
```bash
# Build and start docker containers
docker compose --env-file .env.dev -f docker-compose.dev.yml -f docker-compose.dev.whonix.yml build --no-cache
docker compose --env-file .env.dev -f docker-compose.dev.yml -f docker-compose.dev.whonix.yml up --force-recreate
```
## Tests
### Backend unit tests
+1053 -1053
View File
File diff suppressed because it is too large Load Diff
+105
View File
@@ -0,0 +1,105 @@
import 'reflect-metadata';
import { validate } from './validate';
const validConfig = (overrides: Record<string, unknown> = {}): Record<string, unknown> => ({
NODE_ENV: 'development',
BACKEND_PORT: 3000,
POSTGRES_USER: 'postgres',
POSTGRES_PASSWORD: 'postgres',
POSTGRES_DB: 'nullcart',
POSTGRES_HOST: 'postgres',
POSTGRES_PORT: 5432,
POSTGRES_MIGRATIONS_RUN: 'false',
CORS_ORIGINS: 'http://localhost:5173',
JWT_SECRET: 'secret',
JWT_EXPIRES_IN_MS: 604800000,
CMS_PASSWORD: 'change-me',
SHOP_NAME: 'NullCart',
SHOP_FIAT_CURRENCY: 'USD',
MULTER_PRODUCT_THUMB_ALLOWED_MIMES: 'image/jpeg',
MULTER_PRODUCT_THUMB_MAX_FILE_BYTES: 1048576,
MULTER_BLOG_IMAGE_ALLOWED_MIMES: 'image/jpeg',
MULTER_BLOG_IMAGE_MAX_FILE_BYTES: 1048576,
MULTER_SHOP_LOGO_ALLOWED_MIMES: 'image/jpeg',
MULTER_SHOP_LOGO_MAX_FILE_BYTES: 1048576,
MULTER_SHOP_FAVICON_ALLOWED_MIMES: 'image/png',
MULTER_SHOP_FAVICON_MAX_FILE_BYTES: 262144,
VALIDATION_PRODUCT_TITLE_MAX_LENGTH: 100,
VALIDATION_BLOG_POST_TITLE_MAX_LENGTH: 200,
VALIDATION_CATEGORY_NAME_MAX_LENGTH: 50,
VALIDATION_DISCOUNT_CODE_MAX_LENGTH: 32,
VALIDATION_VARIANT_IMAGES_MAX: 10,
MULTER_DIGITAL_STOCK_ATTACHMENT_ALLOWED_MIMES: 'application/pdf',
MULTER_DIGITAL_STOCK_ATTACHMENT_MAX_FILE_BYTES: 5242880,
VALIDATION_DIGITAL_STOCK_ATTACHMENTS_MAX: 5,
VALIDATION_SHIPPING_NOTE_MIN_LENGTH: 20,
VALIDATION_SHIPPING_NOTE_MAX_LENGTH: 4000,
VALIDATION_ORDER_MESSAGE_MAX_LENGTH: 2000,
VALIDATION_BITCOIN_WITHDRAW_MAX_FEE_RATE_SAT_VBYTE: 500,
CAPTCHA_LENGTH: 5,
THROTTLE_TTL_MS: 60000,
THROTTLE_LIMIT: 120,
SIGNED_COOKIE_JWT_SECRET: 'secret',
SIGNED_COOKIE_FEEDBACK_NAME: 'storefront_feedback',
SIGNED_COOKIE_FEEDBACK_EXPIRES_IN_MS: 120000,
SIGNED_COOKIE_CART_NAME: 'storefront_cart',
SIGNED_COOKIE_CART_EXPIRES_IN_MS: 2592000000,
SIGNED_COOKIE_CAPTCHA_NAME: 'storefront_captcha',
SIGNED_COOKIE_CAPTCHA_EXPIRES_IN_MS: 300000,
SIGNED_COOKIE_DISCOUNT_NAME: 'storefront_discount',
SIGNED_COOKIE_DISCOUNT_EXPIRES_IN_MS: 2592000000,
SIGNED_COOKIE_ERROR_NAME: 'storefront_error',
SIGNED_COOKIE_ERROR_EXPIRES_IN_MS: 120000,
SIGNED_COOKIE_CHECKOUT_SESSION_NAME: 'storefront_checkout_session',
SIGNED_COOKIE_ORDER_AUTH_NAME: 'storefront_order_auth',
SIGNED_COOKIE_ORDER_AUTH_EXPIRES_IN_MS: 604800000,
SIGNED_COOKIE_THEME_NAME: 'storefront_theme',
SIGNED_COOKIE_THEME_EXPIRES_IN_MS: 31536000000,
COINGECKO_API_BASE_URL: 'https://api.coingecko.com/api/v3',
COINPAPRIKA_API_BASE_URL: 'https://api.coinpaprika.com/v1',
COINPAPRIKA_RATE_FETCH_TIMEOUT_MS: 5000,
COINGECKO_RATE_FETCH_TIMEOUT_MS: 5000,
BASE64_ENCRYPTION_KEY: 'nyRya1KpYSQ+drpO132mkOEMUR+uq6K7tWvpMfppIME=',
MONERO_CONFIRMATION_TIERS:
'[{"upToTotalFiat":"30","minConfirmations":1},{"upToTotalFiat":"100","minConfirmations":3},{"minConfirmations":10}]',
BITCOIN_CONFIRMATION_TIERS:
'[{"upToTotalFiat":"200","minConfirmations":1},{"upToTotalFiat":"1000","minConfirmations":2},{"minConfirmations":6}]',
PAYMENT_METHODS_ENABLED: 'xmr,btc',
ORDER_CHECKOUT_VALIDITY_MS: 3600000,
ORDER_CHECKOUT_STATUS_REFRESH_SEC: 15,
ORDER_SHIPPING_PAYMENT_VALIDITY_MS: 259200000,
ORDER_DATA_RETENTION_DAYS: 30,
MONERO_MIN_INCOMING_ATOMIC: 10000000,
BITCOIN_MIN_INCOMING_ATOMIC: 7,
MONERO_DAEMON_ADDRESS: 'xmr-lux.boldsuck.org:38081',
MONERO_NETWORK: 'stagenet',
MONERO_WALLET_RPC_HOST: 'monero-wallet-rpc',
MONERO_WALLET_RPC_PORT: 18083,
MONERO_WALLET_RPC_USERNAME: 'monero',
MONERO_WALLET_RPC_PASSWORD: 'monero',
MONERO_WALLET_RPC_TIMEOUT_MS: 10000,
ELECTRUM_NETWORK: 'testnet4',
ELECTRUM_SERVER: 'blackie.c3-soft.com:57010:s',
ELECTRUM_DAEMON_HOST: 'electrum-daemon',
ELECTRUM_DAEMON_PORT: 7777,
ELECTRUM_DAEMON_RPC_USER: 'electrum',
ELECTRUM_DAEMON_RPC_PASSWORD: 'change-me',
ELECTRUM_DAEMON_RPC_TIMEOUT_MS: 10000,
ELECTRUM_WALLET_PASSWORD: 'change-me',
SIMPLEX_WS_URL: 'ws://simplex-cli:5225',
SIMPLEX_BOT_DISPLAY_NAME: 'NullCartBot',
...overrides
});
describe('validate', () => {
it('accepts true and false for POSTGRES_MIGRATIONS_RUN', () => {
expect(() => validate(validConfig({ POSTGRES_MIGRATIONS_RUN: 'true' }))).not.toThrow();
expect(() => validate(validConfig({ POSTGRES_MIGRATIONS_RUN: 'false' }))).not.toThrow();
});
it('rejects non-literal boolean env values', () => {
expect(() => validate(validConfig({ POSTGRES_MIGRATIONS_RUN: 'yes' }))).toThrow();
expect(() => validate(validConfig({ POSTGRES_MIGRATIONS_RUN: '1' }))).toThrow();
expect(() => validate(validConfig({ POSTGRES_MIGRATIONS_RUN: '' }))).toThrow();
});
});
+16 -3
View File
@@ -1,6 +1,18 @@
import { plainToClass } from 'class-transformer';
import { IsBoolean, IsEnum, IsNotEmpty, IsNumber, IsString, Max, Min, validateSync } from 'class-validator';
import {
IsEnum,
IsIn,
IsNotEmpty,
IsNumber,
IsString,
Max,
Min,
ValidateIf,
validateSync
} from 'class-validator';
import { BOOLEAN_STRING_VALUES } from '../consts/booleanStringValues';
import { NodeEnv } from '../types/NodeEnv';
import type { BooleanStringValue } from '../types/BooleanStringValue';
import { ShopFiatCurrency } from '../types/ShopFiatCurrency';
import { IsBase64 } from '../validation/decorators/isBase64';
import { IsConfirmationTiers } from '../validation/decorators/isConfirmationTiers';
@@ -38,9 +50,10 @@ class EnvironmentVariables {
POSTGRES_PORT: number;
@IsNotEmpty()
@IsBoolean()
POSTGRES_MIGRATIONS_RUN: boolean;
@IsIn(BOOLEAN_STRING_VALUES)
POSTGRES_MIGRATIONS_RUN: BooleanStringValue;
@ValidateIf((config: EnvironmentVariables) => config.NODE_ENV === NodeEnv.Development)
@IsNotEmpty()
@IsString()
CORS_ORIGINS: string;
@@ -0,0 +1 @@
export const BOOLEAN_STRING_VALUES = ['true', 'false'] as const;
@@ -0,0 +1,13 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
export class AddProductSortOrder1785000000000 implements MigrationInterface {
name = 'AddProductSortOrder1785000000000';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "products" ADD "sortOrder" integer NOT NULL DEFAULT '0'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "products" DROP COLUMN "sortOrder"`);
}
}
+6 -4
View File
@@ -106,10 +106,12 @@ async function bootstrap() {
]
});
app.enableCors({
origin: corsOrigins,
credentials: true
});
if (nodeEnv === NodeEnv.Development) {
app.enableCors({
origin: corsOrigins,
credentials: true
});
}
await app.listen(port);
}
@@ -1,4 +1,4 @@
import { IsArray, IsBoolean, IsNotEmpty, IsString, IsUUID, MaxLength } from 'class-validator';
import { IsArray, IsBoolean, IsInt, IsNotEmpty, IsString, IsUUID, MaxLength, Min } from 'class-validator';
import { getAppConfig } from '../../../config';
@@ -22,4 +22,9 @@ export class UpdateProductDto {
@IsArray()
@IsUUID('4', { each: true })
categoryIds: string[];
@IsNotEmpty()
@IsInt()
@Min(0)
sortOrder: number;
}
@@ -29,6 +29,9 @@ export class Product {
@Column({ type: 'text', default: '' })
descriptionHtml: string;
@Column({ type: 'integer', default: 0 })
sortOrder: number;
@OneToMany(() => ProductVariant, variant => variant.product)
variants: ProductVariant[];
@@ -41,7 +41,7 @@ export class ProductsService {
const [products, total] = await this.productRepo.findAndCount({
where: trimmedSearch ? { title: ILike(`%${trimmedSearch}%`) } : {},
order: { createdAt: 'DESC' },
order: { sortOrder: 'ASC', createdAt: 'DESC' },
skip: (page - 1) * limit,
take: limit
});
@@ -56,6 +56,7 @@ export class ProductsService {
where: { id: In(productIds) },
relations: ['categories', 'variants'],
order: {
sortOrder: 'ASC',
createdAt: 'DESC',
variants: { sortOrder: 'ASC', createdAt: 'ASC' }
}
@@ -125,6 +126,7 @@ export class ProductsService {
where: { id: In(uniqueIds) },
relations: ['variants'],
order: {
sortOrder: 'ASC',
createdAt: 'DESC',
variants: { sortOrder: 'ASC', createdAt: 'ASC' }
}
@@ -164,7 +166,7 @@ export class ProductsService {
async update(
id: string,
{ title, descriptionHtml, isDraft, categoryIds }: UpdateProductDto
{ title, descriptionHtml, isDraft, categoryIds, sortOrder }: UpdateProductDto
): Promise<ProductWithVariantsExtended> {
const existing = await this.productRepo.findOne({
where: { id }
@@ -177,6 +179,7 @@ export class ProductsService {
existing.title = title.trim();
existing.isDraft = isDraft;
existing.descriptionHtml = descriptionHtml;
existing.sortOrder = sortOrder;
existing.categories = await this.categoriesService.findByIds(categoryIds);
await this.productRepo.save(existing);
@@ -531,6 +531,14 @@ a:hover {
margin: 0;
}
.sf-user-text {
max-width: 100%;
min-width: 0;
white-space: pre-wrap;
overflow-wrap: anywhere;
word-break: break-word;
}
.sf-info-box p + p,
.sf-info-box p + .sf-info-box__title {
margin-top: var(--sf-space-3);
@@ -1237,6 +1245,11 @@ a:hover {
margin: 0 0 var(--sf-space-3);
}
.sf-prose p:empty {
min-height: 1lh;
margin: 0;
}
.sf-payment-status {
margin: 0 0 var(--sf-space-3);
font-size: 1.1rem;
@@ -1448,8 +1461,11 @@ a:hover {
.sf-delivery-item__content {
margin: 0;
max-width: 100%;
min-width: 0;
font-size: 0.85rem;
white-space: pre-wrap;
overflow-wrap: anywhere;
word-break: break-word;
line-height: 1.45;
}
@@ -1510,6 +1526,8 @@ a:hover {
.sf-chat-bubble {
position: relative;
max-width: 100%;
min-width: 0;
border-radius: 0.875rem;
padding: var(--sf-space-3);
line-height: 1.45;
@@ -1525,7 +1543,11 @@ a:hover {
.sf-chat-bubble p {
margin: 0;
max-width: 100%;
min-width: 0;
white-space: pre-wrap;
overflow-wrap: anywhere;
word-break: break-word;
}
.sf-chat-meta {
@@ -9,7 +9,7 @@
</p>
{{#if shippingNote}}
<p class='sf-info-box__title'>Typical shipping costs</p>
<p>{{shippingNote}}</p>
<p class='sf-user-text'>{{shippingNote}}</p>
{{/if}}
</div>
{{/if}}
@@ -1,4 +1,6 @@
import { DeliveryMode } from '../../product/types/DeliveryMode';
import type { CategoriesService } from '../../product/services/CategoriesService';
import type { StorefrontProduct } from '../types/StorefrontProduct';
import { StorefrontProductViewService } from './StorefrontProductViewService';
describe('StorefrontProductViewService', () => {
@@ -19,4 +21,46 @@ describe('StorefrontProductViewService', () => {
{ id: 'category-2', name: 'Physical', href: '/shop/categories/category-2' }
]);
});
it('appends product-card anchors to index variant selection hrefs', () => {
const product: StorefrontProduct = {
id: 'product-1',
title: 'Widget',
deliveryMode: DeliveryMode.Auto,
descriptionHtml: null,
variants: [
{
id: 'variant-1',
productId: 'product-1',
productTitle: 'Widget',
title: 'Default',
price: 10,
deliveryMode: DeliveryMode.Auto,
stockAvailable: 1,
stockForSession: 1,
thumbnailUrl: null,
images: []
},
{
id: 'variant-2',
productId: 'product-1',
productTitle: 'Widget',
title: 'Alt',
price: 12,
deliveryMode: DeliveryMode.Auto,
stockAvailable: 1,
stockForSession: 1,
thumbnailUrl: null,
images: []
}
]
};
const [view] = service.toProductsIndexView([product], {});
expect(view.variants.map(variant => variant.selectionHref)).toEqual([
'/#product-card-variant-1',
'/?sel=product-1%3Avariant-2#product-card-variant-2'
]);
});
});
@@ -220,11 +220,15 @@ export class StorefrontProductViewService {
}
private buildIndexUrl(basePath: string, product: StorefrontProduct, variantId: string): string {
const anchor = `#product-card-${variantId}`;
if (variantId === product.variants[0].id) {
return basePath;
return `${basePath}${anchor}`;
}
return `${basePath}?${new URLSearchParams({ sel: `${product.id}:${variantId}` }).toString()}`;
const params = new URLSearchParams({ sel: `${product.id}:${variantId}` });
return `${basePath}?${params.toString()}${anchor}`;
}
async resolveProductBackLink(categoryId?: string): Promise<{ backHref: string; backLabel: string }> {
@@ -42,6 +42,19 @@ describe('StorefrontProductsService', () => {
);
});
it('orders storefront products by sortOrder then createdAt desc', async () => {
await service.listStorefrontProducts(new Map(), undefined);
expect(productRepo.find).toHaveBeenCalledWith(
expect.objectContaining({
order: expect.objectContaining({
sortOrder: 'ASC',
createdAt: 'DESC'
})
})
);
});
it('returns an empty map when no variant ids are requested', async () => {
await expect(service.getStorefrontVariantsByIds([], new Map())).resolves.toEqual(new Map());
expect(variantRepo.find).not.toHaveBeenCalled();
@@ -63,6 +63,7 @@ export class StorefrontProductsService {
where: categoryId ? { isDraft: false, categories: { id: categoryId } } : { isDraft: false },
relations: ['variants', 'variants.images'],
order: {
sortOrder: 'ASC',
createdAt: 'DESC',
variants: {
sortOrder: 'ASC',
@@ -87,7 +88,6 @@ export class StorefrontProductsService {
where: { id, isDraft: false },
relations: ['variants', 'variants.images'],
order: {
createdAt: 'DESC',
variants: {
sortOrder: 'ASC',
createdAt: 'ASC',
+3
View File
@@ -0,0 +1,3 @@
import { BOOLEAN_STRING_VALUES } from '../consts/booleanStringValues';
export type BooleanStringValue = (typeof BOOLEAN_STRING_VALUES)[number];
+1 -1
View File
@@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<link rel="icon" type="image/png" href="/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>cms</title>
</head>
+474 -443
View File
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -11,10 +11,10 @@
},
"dependencies": {
"@element-plus/icons-vue": "^2.3.2",
"@tiptap/extension-link": "^3.22.5",
"@tiptap/extension-placeholder": "^3.22.5",
"@tiptap/starter-kit": "^3.22.5",
"@tiptap/vue-3": "^3.22.5",
"@tiptap/extension-link": "^3.35.0",
"@tiptap/extension-placeholder": "^3.35.0",
"@tiptap/starter-kit": "^3.35.0",
"@tiptap/vue-3": "^3.35.0",
"axios": "^1.15.1",
"dayjs": "^1.11.19",
"decimal.js": "^10.6.0",
Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 9.3 KiB

+5
View File
@@ -224,6 +224,7 @@ const scrollToBottom = async (): Promise<void> => {
border-radius: 14px;
line-height: 1.45;
max-width: min(100%, 560px);
min-width: 0;
}
.order-chat-message--buyer .order-chat-bubble {
@@ -237,7 +238,11 @@ const scrollToBottom = async (): Promise<void> => {
}
.order-chat-body {
max-width: 100%;
min-width: 0;
white-space: pre-wrap;
overflow-wrap: anywhere;
word-break: break-word;
}
.order-chat-delete {
@@ -145,9 +145,11 @@ const downloadAttachment = async (
}
.auto-delivery-item__content {
max-width: 100%;
min-width: 0;
font-size: var(--el-font-size-small);
white-space: pre-wrap;
overflow-wrap: break-word;
overflow-wrap: anywhere;
word-break: break-word;
}
+1
View File
@@ -211,6 +211,7 @@ onBeforeUnmount(() => {
.rich-text-editor-body :deep(.ProseMirror p) {
margin: 0.35em 0;
min-height: 1lh;
}
.rich-text-editor-body :deep(.ProseMirror h2) {
+1
View File
@@ -7,6 +7,7 @@ export interface Product {
title: string;
deliveryMode: DeliveryMode;
isDraft: boolean;
sortOrder: number;
descriptionHtml: string;
variants?: ProductVariantExtended[];
categories?: Category[];
@@ -1,6 +1,7 @@
export interface UpdateProductPayload {
title: string;
isDraft: boolean;
sortOrder: number;
descriptionHtml: string;
categoryIds: string[];
}
+17 -1
View File
@@ -42,6 +42,15 @@
/>
</el-form-item>
<el-form-item label="Sort order" prop="sortOrder">
<el-input-number
v-model="productForm.sortOrder"
:min="0"
:step="1"
@update:model-value="productFormRef?.clearValidate('sortOrder')"
/>
</el-form-item>
<el-form-item label="Categories">
<el-select
v-model="selectedCategoryIds"
@@ -161,7 +170,8 @@ const productFormRef = ref<FormInstance>();
const productForm = reactive({
title: '',
descriptionHtml: '',
isDraft: true
isDraft: true,
sortOrder: 0
});
const productSaving = ref(false);
@@ -175,6 +185,10 @@ const productRules: FormRules = {
message: `At most ${validationProductTitleMaxLength} characters`,
trigger: 'blur'
}
],
sortOrder: [
{ required: true, message: 'Sort order is required', trigger: 'change' },
{ type: 'integer', message: 'Sort order must be a whole number', trigger: 'change' }
]
};
@@ -200,6 +214,7 @@ onBeforeMount(async () => {
productForm.title = currentProduct.value.title;
productForm.descriptionHtml = currentProduct.value.descriptionHtml;
productForm.isDraft = currentProduct.value.isDraft;
productForm.sortOrder = currentProduct.value.sortOrder;
selectedCategoryIds.value = (currentProduct.value.categories ?? []).map(c => c.id);
}
} catch {
@@ -236,6 +251,7 @@ const submitProduct = async (): Promise<void> => {
title: productForm.title.trim(),
descriptionHtml: productForm.descriptionHtml,
isDraft: productForm.isDraft,
sortOrder: productForm.sortOrder,
categoryIds: selectedCategoryIds.value
});
+2
View File
@@ -35,6 +35,8 @@
</template>
</el-table-column>
<el-table-column prop="sortOrder" label="Order" width="80" />
<el-table-column label="Categories" min-width="160" show-overflow-tooltip>
<template #default="{ row }">
{{ formatProductCategories(row.categories) }}
+11 -4
View File
@@ -40,7 +40,6 @@ Edit `.env.prod`. Mandatory configuration:
| `POSTGRES_MIGRATIONS_RUN` | `true` |
| `PGADMIN_DEFAULT_PASSWORD` | strong random password |
| `NODE_ENV` | `production` |
| `CORS_ORIGINS` | `https://your-domain.com` |
| `CLEARNET_DOMAIN` | `your-domain.com` |
| `JWT_SECRET` | strong random secret |
| `CMS_PASSWORD` | strong admin password |
@@ -56,8 +55,8 @@ Edit `.env.prod`. Mandatory configuration:
| `MONERO_WALLET_PASSWORD` | strong wallet password |
| `ELECTRUM_NETWORK` | `mainnet` |
| `ELECTRUM_SERVER` | Electrum peer as `host:port:s` (SSL) or `host:port:t` (TCP), e.g. `electrum.blockstream.info:50002:s` |
| `ELECTRUM_WALLET_PASSWORD` | strong wallet password |
| `ELECTRUM_DAEMON_RPC_PASSWORD` | strong random password |
| `ELECTRUM_WALLET_PASSWORD` | strong wallet password |
| `VITE_API_BASE_URL` | `/api` |
| `VITE_SHOP_FIAT_CURRENCY` | same as `SHOP_FIAT_CURRENCY` |
@@ -159,10 +158,18 @@ Tor Browser will then show ".onion available" when visitors open the clearnet si
3. Finish the setup checklist in settings.
4. Connect SimpleX notifications in shop settings.
## 10. Updates
## Updates
This pulls the latest code and rebuilds the stack (`deploy.sh`).
```bash
./deploy/scripts/update.sh
```
This pulls the latest code and rebuilds the stack (`deploy.sh`).
## Backups
This creates a full disaster-recovery archive.
```bash
./deploy/scripts/backup.sh
```
+337
View File
@@ -0,0 +1,337 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
ENV_FILE="${ROOT_DIR}/.env.prod"
COMPOSE_FILE="${ROOT_DIR}/docker-compose.prod.yml"
BACKUP_DIR="${ROOT_DIR}/deploy/backups"
cd "$ROOT_DIR"
if [[ ! -f "$ENV_FILE" ]]; then
echo "Missing ${ENV_FILE}. Copy .env.example to .env.prod and configure it." >&2
exit 1
fi
# shellcheck disable=SC1090
set -a
source "$ENV_FILE"
set +a
if [[ -z "${COMPOSE_PROJECT_NAME:-}" ]]; then
echo "COMPOSE_PROJECT_NAME is not set in .env.prod" >&2
exit 1
fi
if [[ -z "${POSTGRES_USER:-}" || -z "${POSTGRES_DB:-}" ]]; then
echo "POSTGRES_USER and POSTGRES_DB must be set in .env.prod" >&2
exit 1
fi
if [[ -z "${MONERO_WALLET_DIR:-}" ]]; then
echo "MONERO_WALLET_DIR is not set in .env.prod" >&2
exit 1
fi
if [[ -z "${ELECTRUM_WALLET_DIR:-}" ]]; then
echo "ELECTRUM_WALLET_DIR is not set in .env.prod" >&2
exit 1
fi
compose() {
docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" "$@"
}
resolve_host_path() {
local rel="${1:-}"
local label="$2"
if [[ -z "$rel" ]]; then
echo "Cannot resolve empty path for ${label}" >&2
exit 1
fi
if [[ "$rel" == /* ]]; then
echo "$rel"
else
echo "${ROOT_DIR}/${rel#./}"
fi
}
build_compose_volume_name() {
local vol_key="$1"
echo "${COMPOSE_PROJECT_NAME}_${vol_key}"
}
require_min_bytes() {
local file="$1"
local min_bytes="$2"
local label="$3"
if [[ ! -f "$file" ]] || (( $(stat -c%s "$file") < min_bytes )); then
echo "Backup failed: ${label} is missing or empty." >&2
exit 1
fi
}
require_tar_entries() {
local file="$1"
local label="$2"
local entry_count
if [[ ! -f "$file" ]]; then
echo "Backup failed: ${label} is missing or has no archive entries." >&2
exit 1
fi
entry_count="$(tar tf "$file" 2>/dev/null | wc -l)"
if (( entry_count < 1 )); then
echo "Backup failed: ${label} is missing or has no archive entries." >&2
exit 1
fi
}
tar_volume() {
local vol_key="$1"
local archive_name="$2"
local vol_name
vol_name="$(build_compose_volume_name "$vol_key")"
if ! docker volume inspect "$vol_name" >/dev/null 2>&1; then
echo "Backup failed: Docker volume ${vol_name} not found. Is the stack deployed?" >&2
exit 1
fi
docker run --rm \
-v "${vol_name}:/data:ro" \
-v "${STAGING_TMP}:/backup" \
alpine tar -cf "/backup/${archive_name}" -C /data .
}
SHOULD_STOP=false
STOPPED=false
STAGING_TMP=""
ARCHIVE_TMP=""
on_exit() {
if [[ -n "$STAGING_TMP" && -d "$STAGING_TMP" ]]; then
rm -rf "$STAGING_TMP"
fi
if [[ -n "$ARCHIVE_TMP" && -f "$ARCHIVE_TMP" ]]; then
rm -f "$ARCHIVE_TMP"
fi
if [[ "$STOPPED" == true ]]; then
echo "Restarting NullCart..."
compose start
fi
}
trap on_exit EXIT
trap 'exit 130' INT
trap 'exit 143' TERM
echo "Checking if PostgreSQL is running and accepting connections..."
cid="$(compose ps --status running -q postgres 2>/dev/null | head -n1)"
if [[ -z "$cid" ]]; then
echo "Backup failed: PostgreSQL is not running. Start the stack (for example: docker compose --env-file \"${ENV_FILE}\" -f \"${COMPOSE_FILE}\" up -d postgres)." >&2
exit 1
fi
if ! compose exec -T postgres pg_isready -U "$POSTGRES_USER" -d "$POSTGRES_DB" >/dev/null 2>&1; then
echo "Backup failed: PostgreSQL is not accepting connections. Check container logs or wait until the database is healthy." >&2
exit 1
fi
echo "PostgreSQL is running and accepting connections."
# Check if the script is running from an interactive terminal
if [[ ! -r /dev/tty ]]; then
echo "Run this script from an interactive terminal (for example: ssh -t)." >&2
exit 1
fi
printf 'Would you like to stop NullCart before doing backup? Doing backup while NullCart is running may lead to backup data corruption [y/n] (recommended y): '
read -n 1 -r STOP_ANSWER </dev/tty || {
echo "Backup failed: could not read answer from the terminal." >&2
exit 1
}
printf '\n'
case "$STOP_ANSWER" in
y)
SHOULD_STOP=true
;;
n)
echo "Continuing backup with NullCart running..."
;;
*)
echo "Invalid answer. Use y or n." >&2
exit 1
;;
esac
STAGING_TMP="$(mktemp -d)"
mkdir -p "$BACKUP_DIR"
TIMESTAMP="$(date -u +%Y%m%d-%H%M%S)"
ARCHIVE_PATH="${BACKUP_DIR}/nullcart-backup-${TIMESTAMP}.tar.gz"
ARCHIVE_TMP="${ARCHIVE_PATH}.tmp"
if [[ "$SHOULD_STOP" == true ]]; then
stop_services=()
compose_services="$(compose config --services)"
while IFS= read -r svc; do
if [[ -z "$svc" || "$svc" == "postgres" ]]; then
continue
fi
stop_services+=("$svc")
done <<<"$compose_services"
if ((${#stop_services[@]} == 0)); then
echo "Backup failed: no application services found to stop in ${COMPOSE_FILE}." >&2
exit 1
fi
echo "Stopping NullCart application services (PostgreSQL stays up for dump)..."
compose stop "${stop_services[@]}"
STOPPED=true
fi
echo "Backing up PostgreSQL..."
compose exec -T postgres pg_dump -U "$POSTGRES_USER" -d "$POSTGRES_DB" -Fc > "${STAGING_TMP}/postgres.dump"
require_min_bytes "${STAGING_TMP}/postgres.dump" 64 "postgres.dump"
echo "Backing up environment file..."
cp "$ENV_FILE" "${STAGING_TMP}/env.prod"
require_min_bytes "${STAGING_TMP}/env.prod" 1 "env.prod"
echo "Backing up uploads..."
UPLOADS_DIR="${ROOT_DIR}/backend/uploads"
if [[ ! -d "$UPLOADS_DIR" ]]; then
echo "Backup failed: uploads directory not found at ${UPLOADS_DIR}" >&2
exit 1
fi
tar -cf "${STAGING_TMP}/uploads.tar" -C "${ROOT_DIR}/backend" uploads
require_tar_entries "${STAGING_TMP}/uploads.tar" "uploads.tar"
echo "Backing up Monero wallet..."
MONERO_WALLET_PATH="$(resolve_host_path "$MONERO_WALLET_DIR" "Monero wallet")"
if [[ ! -d "$MONERO_WALLET_PATH" ]]; then
echo "Backup failed: Monero wallet directory not found at ${MONERO_WALLET_PATH}" >&2
exit 1
fi
if [[ -z "$(ls -A "$MONERO_WALLET_PATH" 2>/dev/null || true)" ]]; then
echo "Backup failed: Monero wallet directory is empty at ${MONERO_WALLET_PATH}" >&2
exit 1
fi
tar -cf "${STAGING_TMP}/monero-wallet.tar" -C "$(dirname "$MONERO_WALLET_PATH")" "$(basename "$MONERO_WALLET_PATH")"
require_tar_entries "${STAGING_TMP}/monero-wallet.tar" "monero-wallet.tar"
echo "Backing up Electrum wallet..."
ELECTRUM_WALLET_PATH="$(resolve_host_path "$ELECTRUM_WALLET_DIR" "Electrum wallet")"
if [[ ! -d "$ELECTRUM_WALLET_PATH" ]]; then
echo "Backup failed: Electrum wallet directory not found at ${ELECTRUM_WALLET_PATH}" >&2
exit 1
fi
if [[ -z "$(ls -A "$ELECTRUM_WALLET_PATH" 2>/dev/null || true)" ]]; then
echo "Backup failed: Electrum wallet directory is empty at ${ELECTRUM_WALLET_PATH}" >&2
exit 1
fi
tar -cf "${STAGING_TMP}/electrum-wallet.tar" -C "$(dirname "$ELECTRUM_WALLET_PATH")" "$(basename "$ELECTRUM_WALLET_PATH")"
require_tar_entries "${STAGING_TMP}/electrum-wallet.tar" "electrum-wallet.tar"
echo "Backing up Docker volumes..."
echo "Backing up Tor hidden service volume..."
tar_volume "nullcart.tor.prod.data" "volume-tor.tar"
require_tar_entries "${STAGING_TMP}/volume-tor.tar" "volume-tor.tar"
echo "Backing up SimpleX volume..."
tar_volume "nullcart.simplex.prod.data" "volume-simplex.tar"
require_tar_entries "${STAGING_TMP}/volume-simplex.tar" "volume-simplex.tar"
echo "Backing up pgAdmin volume..."
tar_volume "nullcart.pgadmin.prod.data" "volume-pgadmin.tar"
require_tar_entries "${STAGING_TMP}/volume-pgadmin.tar" "volume-pgadmin.tar"
echo "Backing up TLS certs directory..."
CERTS_DIR="${ROOT_DIR}/deploy/certs"
if [[ ! -d "$CERTS_DIR" ]]; then
echo "Backup failed: TLS certs directory not found at ${CERTS_DIR}" >&2
exit 1
fi
tar -cf "${STAGING_TMP}/certs.tar" -C "${ROOT_DIR}/deploy" certs
require_tar_entries "${STAGING_TMP}/certs.tar" "certs.tar"
echo "Backing up Git commit..."
GIT_REV=""
if git -C "$ROOT_DIR" rev-parse HEAD >/dev/null 2>&1; then
GIT_REV="$(git -C "$ROOT_DIR" rev-parse HEAD)"
fi
{
echo "NullCart backup"
echo "Created (UTC): $(date -u +"%Y-%m-%dT%H:%M:%SZ")"
echo "Compose project: ${COMPOSE_PROJECT_NAME}"
echo "Stopped application services before pg_dump: $([[ "$STOPPED" == true ]] && echo yes || echo no)"
if [[ -n "$GIT_REV" ]]; then
echo "Git commit: ${GIT_REV}"
fi
echo ""
echo "Contents:"
echo " postgres.dump PostgreSQL custom-format dump (pg_restore)"
echo " env.prod Production environment file"
echo " uploads.tar backend/uploads"
echo " monero-wallet.tar Monero wallet directory"
echo " electrum-wallet.tar Electrum wallet directory"
echo " volume-tor.tar Tor hidden service keys"
echo " volume-simplex.tar SimpleX CLI data"
echo " volume-pgadmin.tar pgAdmin data"
echo " certs.tar deploy/certs (TLS)"
} > "${STAGING_TMP}/MANIFEST.txt"
require_min_bytes "${STAGING_TMP}/MANIFEST.txt" 1 "MANIFEST.txt"
rm -f "$ARCHIVE_TMP"
tar czf "$ARCHIVE_TMP" -C "$STAGING_TMP" .
tar tzf "$ARCHIVE_TMP" >/dev/null
chmod 600 "$ARCHIVE_TMP"
mv -f "$ARCHIVE_TMP" "$ARCHIVE_PATH"
echo "Backup complete: ${ARCHIVE_PATH}"
echo "This archive contains secrets. It is recommended to store it encrypted on an external storage."
+9
View File
@@ -0,0 +1,9 @@
networks:
default:
driver: bridge
ipam:
config:
- subnet: 172.30.0.0/16
gateway: 172.30.0.1
driver_opts:
com.docker.network.bridge.name: nullcart0
+2 -2
View File
@@ -1,6 +1,6 @@
services:
postgres:
image: postgres:16
image: postgres:16.16
container_name: ${COMPOSE_PROJECT_NAME}_postgres
restart: unless-stopped
environment:
@@ -16,7 +16,7 @@ services:
retries: 10
pgadmin:
image: dpage/pgadmin4
image: dpage/pgadmin4:9.19.0
container_name: ${COMPOSE_PROJECT_NAME}_pgadmin
restart: unless-stopped
environment:
+2 -2
View File
@@ -1,6 +1,6 @@
services:
postgres:
image: postgres:16
image: postgres:16.16
container_name: ${COMPOSE_PROJECT_NAME}_postgres
restart: unless-stopped
environment:
@@ -16,7 +16,7 @@ services:
retries: 10
pgadmin:
image: dpage/pgadmin4
image: dpage/pgadmin4:9.19.0
container_name: ${COMPOSE_PROJECT_NAME}_pgadmin
restart: unless-stopped
environment:
+2
View File
@@ -34,6 +34,8 @@ run_electrum_offline setconfig rpcpassword "${ELECTRUM_DAEMON_RPC_PASSWORD}"
run_electrum_offline setconfig rpchost 0.0.0.0
run_electrum_offline setconfig rpcport "${ELECTRUM_DAEMON_PORT}"
run_electrum_offline setconfig server "${ELECTRUM_SERVER}"
run_electrum_offline setconfig oneserver true
run_electrum_offline setconfig auto_connect false
trap 'run_electrum stop || true' SIGTERM SIGINT
+2 -1
View File
@@ -57,12 +57,13 @@ ENV VITE_API_BASE_URL=$VITE_API_BASE_URL \
RUN npm run build
FROM nginx:alpine
FROM nginx:1.30.8-alpine3.24
RUN apk add --no-cache gettext
COPY --from=cms-builder /cms/dist /usr/share/nginx/html/cms
COPY nginx/logging.conf /etc/nginx/conf.d/logging.conf
COPY nginx/conf.d/ /etc/nginx/templates/conf.d/
COPY nginx/snippets/ /etc/nginx/templates/snippets/
COPY nginx/docker-entrypoint.sh /docker-entrypoint.sh
+2
View File
@@ -0,0 +1,2 @@
access_log off;
error_log /dev/null;
@@ -31,13 +31,9 @@ location /api {
proxy_pass http://backend:${BACKEND_PORT};
}
location = /cms {
return 301 /cms/;
}
location /cms/ {
location /cms {
root /usr/share/nginx/html;
try_files $uri $uri/ /cms/index.html;
try_files $uri /cms/index.html;
}
location /pgadmin {