Snai3i-MarketPlace / backend / src / services / order / order.logs.ts
order.logs.ts
Raw
// Orders Table:
// order_id (Primary Key),
// course_id  (Foreign Key referencing Courses table),
// pack_id  (Foreign Key referencing Packs table),
// school_id (Foreign Key referencing Schools table),
// teacher_id (Foreign Key referencing Teachers table),
// price
// status
// note

import Logger from '../../utils/Logger';
export type IOrderLogs =
  | 'CREATE_ORDER_SUCCESS'
  | 'CREATE_ORDER_ERROR'
  | 'UPDATE_ORDER_SUCCESS'
  | 'UPDATE_ORDER_ERROR'
  | 'DELETE_ORDER_SUCCESS'
  | 'DELETE_ORDER_ERROR'
  | 'ORDER_ERROR_GENERIC'
  | 'ORDER_ERROR_INVALID_INPUT'
  | 'ORDER_ERROR_NOT_FOUND'
  | 'GET_ORDER_SUCCESS'
  | 'GET_ORDERS_SUCCESS'
  | 'GET_ORDERS_ERROR'
  | 'GET_ORDER_ERROR'
  | 'GET_ORDERS_BY_STATUS_SUCCESS'
  | 'GET_ORDERS_BY_STATUS_ERROR'
  | 'GET_ORDERS_BY_STATUS_ERROR'
  | 'UPDATE_ORDER_STATUS_SUCCESS'
  | 'UPDATE_ORDER_STATUS_ERROR';

export const orderLogs: IErrors<IOrderLogs> = {
    CREATE_ORDER_SUCCESS: {
        code: 0,
        message: 'Order "{orderId}" has been created successfully.',
        type: 'CREATE_ORDER_SUCCESS',
    },
    CREATE_ORDER_ERROR: {
        code: 1,
        message: 'Error occurred while creating order: {error}',
        type: 'CREATE_ORDER_ERROR',
    },
    UPDATE_ORDER_SUCCESS: {
        code: 2,
        message: 'Order "{orderId}" has been updated successfully.',
        type: 'UPDATE_ORDER_SUCCESS',
    },
    UPDATE_ORDER_ERROR: {
        code: 3,
        message: 'Error occurred while updating order: {error}',
        type: 'UPDATE_ORDER_ERROR',
    },
    DELETE_ORDER_SUCCESS: {
        code: 4,
        message: 'Order "{orderId}" has been deleted successfully.',
        type: 'DELETE_ORDER_SUCCESS',
    },
    DELETE_ORDER_ERROR: {
        code: 5,
        message: 'Error occurred while deleting order: {error}',
        type: 'DELETE_ORDER_ERROR',
    },
    ORDER_ERROR_GENERIC: {
        code: 6,
        message: 'Generic error happened while loading orders.',
        type: 'ORDER_ERROR_GENERIC',
    },
    ORDER_ERROR_INVALID_INPUT: {
        code: 7,
        message: 'Invalid input for Order : {input}',
        type: 'ORDER_ERROR_INVALID_INPUT',
    },
    ORDER_ERROR_NOT_FOUND: {
        code: 8,
        message: 'Order {orderId} not found',
        type: 'ORDER_ERROR_NOT_FOUND',
    },
    GET_ORDER_SUCCESS: {
        code: 9,
        message: 'Order "{orderId}" has been fetched successfully.',
        type: 'GET_ORDER_SUCCESS',
    },
    GET_ORDERS_SUCCESS: {
        code: 10,
        message: 'Orders has been fetched successfully.',
        type: 'GET_ORDERS_SUCCESS',
    },
    GET_ORDERS_ERROR: {
        code: 11,
        message: 'Error occurred while fetching orders: {error}',
        type: 'GET_ORDERS_ERROR',
    },
    GET_ORDER_ERROR: {
        code: 12,
        message: 'Error occurred while fetching order: {error}',
        type: 'GET_ORDER_ERROR',
    },
    GET_ORDERS_BY_STATUS_SUCCESS: {
        code: 13,
        message: 'Orders has been fetched successfully by status.',
        type: 'GET_ORDERS_BY_STATUS_SUCCESS',
    },
    GET_ORDERS_BY_STATUS_ERROR: {
        code: 14,
        message: 'Error occurred while fetching orders by status: {error}',
        type: 'GET_ORDERS_BY_STATUS_ERROR',
    },
    UPDATE_ORDER_STATUS_SUCCESS: {
        code: 15,
        message: 'Order "{orderId}" status has been updated successfully.',
        type: 'UPDATE_ORDER_STATUS_SUCCESS',
    },
    UPDATE_ORDER_STATUS_ERROR: {
        code: 16,
        message: 'Error occurred while updating order status: {error}',
        type: 'UPDATE_ORDER_STATUS_ERROR',
    },
} as const;

export default orderLogs;
export const orderLogger = new Logger('order');