2025-09-28 18:34:24 +01:00
2025-09-28 18:33:16 +01:00
2025-09-28 18:33:16 +01:00
2025-09-28 18:33:16 +01:00
2025-09-28 18:33:16 +01:00
2025-09-28 18:33:16 +01:00
2025-09-28 18:33:16 +01:00
2025-09-28 18:34:24 +01:00

Data Server

A Node.js server to handle file I/O operations for the ASSCO admin panel.

Setup

  1. Install dependencies:
cd data-server
npm install
  1. Copy environment variables:
cp .env.example .env
  1. Update the .env file with your settings:
  • ADMIN_PASSWORD: Same password used in your main app
  • PORT: Port to run the server on (default: 3001)
  • ALLOWED_ORIGINS: Comma-separated list of allowed origins for CORS

Running

Development

npm run dev

Production

npm start

API Endpoints

All endpoints except /health and GET requests require authentication via Authorization: Bearer <admin_password> header.

Health Check

  • GET /health - Server health status

Discount Codes

  • GET /api/discount-codes - Get all discount codes
  • POST /api/discount-codes - Add new discount code
  • DELETE /api/discount-codes/:code - Delete discount code

Products

  • GET /api/products - Get all products
  • PUT /api/products/:productId - Update product price

Cache Management

  • GET /api/cache-status - View cache status
  • POST /api/clear-cache - Clear all cache (requires auth)

Caching

The server implements in-memory caching:

  • GET requests serve from cache if available
  • Non-GET requests clear the cache to ensure fresh data
  • Cache includes timestamps for debugging

File Structure

data-server/
├── data/
│   ├── discountCodes.json
│   └── products.js
├── server.js
├── package.json
├── .env.example
└── README.md
Description
No description provided
Readme 46 KiB
Languages
JavaScript 94.8%
TypeScript 5.2%