Compare commits

..
3 Commits
Author SHA1 Message Date
nobswebdev 55630e33b4 Allow application/x-zip-compressed for digital stock attachments.
Browsers often report ZIP files with this MIME type instead of application/zip.
2026-09-25 20:57:28 +02:00
nobswebdev e057b29cc7 Reject cart and discount mutations while checkout session is active.
Prevent cart cookie changes during payment so nav counts and checkout snapshots stay aligned until cancel or completion.
2026-09-18 13:31:10 +02:00
nobswebdev 226a31b937 Merge pull request 'Slave/blog' (#9) from slave/blog into master
Reviewed-on: http://4f5t7o2vgo4sdaliwax3isyxzfuxvbvkuwk4smfowutrvx2uneu4egyd.onion/nobswebdev/nullcart/pulls/9
2026-09-16 20:15:07 +00:00
3 changed files with 24 additions and 3 deletions
+2 -2
View File
@@ -46,7 +46,7 @@ MULTER_SHOP_LOGO_MAX_FILE_BYTES=1048576 # 1MB
MULTER_SHOP_FAVICON_ALLOWED_MIMES=image/png,image/x-icon,image/vnd.microsoft.icon
MULTER_SHOP_FAVICON_MAX_FILE_BYTES=262144 # 256KB
MULTER_DIGITAL_STOCK_ATTACHMENT_ALLOWED_MIMES=application/pdf,application/zip,image/jpeg,image/png
MULTER_DIGITAL_STOCK_ATTACHMENT_ALLOWED_MIMES=application/pdf,application/zip,application/x-zip-compressed,image/jpeg,image/png
MULTER_DIGITAL_STOCK_ATTACHMENT_MAX_FILE_BYTES=5242880 # 5MB
VALIDATION_PRODUCT_TITLE_MAX_LENGTH=100
@@ -144,7 +144,7 @@ VITE_SHOP_LOGO_ALLOWED_MIMES=image/jpeg,image/png
VITE_SHOP_LOGO_MAX_FILE_BYTES=1048576 # 1MB
VITE_SHOP_FAVICON_ALLOWED_MIMES=image/png,image/x-icon,image/vnd.microsoft.icon
VITE_SHOP_FAVICON_MAX_FILE_BYTES=262144 # 256KB
VITE_DIGITAL_STOCK_ATTACHMENT_ALLOWED_MIMES=application/pdf,application/zip,image/jpeg,image/png
VITE_DIGITAL_STOCK_ATTACHMENT_ALLOWED_MIMES=application/pdf,application/zip,application/x-zip-compressed,image/jpeg,image/png
VITE_DIGITAL_STOCK_ATTACHMENT_MAX_FILE_BYTES=5242880 # 5MB
VITE_VALIDATION_PRODUCT_TITLE_MAX_LENGTH=100
VITE_VALIDATION_BLOG_POST_TITLE_MAX_LENGTH=200
@@ -1,4 +1,4 @@
import { Body, Controller, Get, HttpStatus, Post, Req, Res, UseFilters } from '@nestjs/common';
import { BadRequestException, Body, Controller, Get, HttpStatus, Post, Req, Res, UseFilters } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { Throttle } from '@nestjs/throttler';
import type { Request, Response } from 'express';
@@ -89,6 +89,10 @@ export class StorefrontCartController {
@Res() res: Response,
@Body() { variantId, qty }: AddToCartDto
): Promise<void> {
if (this.checkoutSessionCookieService.getSessionId(req, res)) {
throw new BadRequestException('Finish or cancel checkout before changing your cart.');
}
const cart = this.cartCookieService.getCart(req, res);
const cartMutation = await this.cartService.addToCart(cart, variantId, qty);
@@ -109,6 +113,10 @@ export class StorefrontCartController {
@Res() res: Response,
@Body() { variantId, qty }: UpdateCartQtyDto
): Promise<void> {
if (this.checkoutSessionCookieService.getSessionId(req, res)) {
throw new BadRequestException('Finish or cancel checkout before changing your cart.');
}
const cart = this.cartCookieService.getCart(req, res);
const cartMutation = await this.cartService.updateCartQty(cart, variantId, qty);
@@ -125,6 +133,10 @@ export class StorefrontCartController {
@Post('shop/cart/product/remove')
removeFromCart(@Req() req: Request, @Res() res: Response, @Body() { variantId }: RemoveFromCartDto): void {
if (this.checkoutSessionCookieService.getSessionId(req, res)) {
throw new BadRequestException('Finish or cancel checkout before changing your cart.');
}
const cart = this.cartCookieService.getCart(req, res);
const cartMutation = this.cartService.removeFromCart(cart, variantId);
@@ -143,6 +155,10 @@ export class StorefrontCartController {
@Res() res: Response,
@Body() { code }: ApplyDiscountCodeDto
): Promise<void> {
if (this.checkoutSessionCookieService.getSessionId(req, res)) {
throw new BadRequestException('Finish or cancel checkout before changing your cart.');
}
const cart = this.cartCookieService.getCart(req, res);
const discountCodes = this.discountCookieService.getDiscountCodes(req, res);
@@ -160,6 +176,10 @@ export class StorefrontCartController {
@Post('shop/cart/discount/remove')
removeDiscount(@Req() req: Request, @Res() res: Response, @Body() { code }: RemoveDiscountCodeDto): void {
if (this.checkoutSessionCookieService.getSessionId(req, res)) {
throw new BadRequestException('Finish or cancel checkout before changing your cart.');
}
const discountCodes = this.discountCookieService.getDiscountCodes(req, res);
const discountMutation = this.discountService.removeDiscountCode(discountCodes, code);
+1
View File
@@ -5,6 +5,7 @@ const MIME_LABEL: Record<string, string> = {
'application/json': 'JSON',
'application/pdf': 'PDF',
'application/zip': 'ZIP',
'application/x-zip-compressed': 'ZIP',
'image/gif': 'GIF',
'image/jpeg': 'JPEG',
'image/jpg': 'JPEG',