import { Request, Response } from 'express';
import validator from 'joi'; // DOCS: https://joi.dev/api

// MARK: GET image
const schema_get = validator.object({
	id: validator.number().positive().precision(0).default(0).note('product id'), // id 0 should never exist, since id autoincrement starts at 1
	check: validator.boolean().default(false)
});

// MARK: CREATE / UPDATE image
const schema_post = validator.object({
	id: validator.number().positive().precision(0).required().note('product id')
	//image: validator.string().required().note('product image as multipart/form-data')
});

// MARK: DELETE products
const schema_del = validator.object({
	id: validator.number().positive().precision(0).required().note('product id')
});

// Describe all schemas
const schema_get_desc = schema_get.describe();
const schema_post_desc = schema_post.describe();
const schema_patch_desc = schema_post.describe(); // Just for show (POST = PATCH)
const schema_del_desc = schema_del.describe();

// GET route
export default async function get(req: Request, res: Response) {
	res.status(200).json({
		GET: schema_get_desc,
		POST: schema_post_desc,
		PATCH: schema_patch_desc,
		DELETE: schema_del_desc
	});
}

export { schema_get, schema_post, schema_del };
