Compare commits
16
Commits
ded7407090
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c2933734ee | ||
|
|
1d512bf582 | ||
|
|
9e33aab9f9 | ||
|
|
32b3a83cd6 | ||
|
|
1e7edda6f2 | ||
|
|
8b56a9a5a9 | ||
|
|
e0e06eefa4 | ||
|
|
cccc8596e6 | ||
|
|
35feda1278 | ||
|
|
a6e60408d6 | ||
|
|
6ebb8161b9 | ||
|
|
ba0af1afd9 | ||
|
|
3577c9dc16 | ||
|
|
bf422b8529 | ||
|
|
ff5fbb649f | ||
|
|
633099371d |
+1
-1
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Generated
+1053
-1053
File diff suppressed because it is too large
Load Diff
@@ -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();
|
||||
});
|
||||
});
|
||||
@@ -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
@@ -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',
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import { BOOLEAN_STRING_VALUES } from '../consts/booleanStringValues';
|
||||
|
||||
export type BooleanStringValue = (typeof BOOLEAN_STRING_VALUES)[number];
|
||||
+1
-1
@@ -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>
|
||||
|
||||
Generated
+474
-443
File diff suppressed because it is too large
Load Diff
+4
-4
@@ -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 |
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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[];
|
||||
}
|
||||
|
||||
@@ -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
|
||||
});
|
||||
|
||||
|
||||
@@ -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) }}
|
||||
|
||||
@@ -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` |
|
||||
|
||||
|
||||
@@ -149,6 +149,8 @@ if ! compose exec -T postgres pg_isready -U "$POSTGRES_USER" -d "$POSTGRES_DB" >
|
||||
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
|
||||
|
||||
@@ -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
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user