Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Store Routes #13

Open
12 tasks
nani-samireddy opened this issue Jul 10, 2024 · 0 comments
Open
12 tasks

Add Store Routes #13

nani-samireddy opened this issue Jul 10, 2024 · 0 comments
Assignees
Labels

Comments

@nani-samireddy
Copy link
Member

nani-samireddy commented Jul 10, 2024

Description:

We need to add routes for managing store data in our existing Express API. The store object will have the following properties, and the routes will have specific access permissions as outlined below.

Store Object Properties:

  1. name

    • Type: String
    • Description: Name of the store
    • Example: "The Great Bakery"
  2. description

    • Type: String
    • Description: Description of the store
    • Example: "A cozy bakery specializing in artisan bread and pastries."
  3. logo

  4. banner

  5. region_id

    • Type: ObjectId
    • Description: Reference to the region where the store is located
    • Example: ObjectId("60d21b4667d0d8992e610c85")
  6. status

    • Type: String
    • Description: Current status of the store
    • Values: "active", "inactive", "deleted", "pending", "suspended"
    • Example: "pending"
  7. address

    • Type: Object
    • Description: Address details of the store
      • street
        • Type: String
        • Description: Street address
        • Example: "123 Main St"
      • city
        • Type: String
        • Description: City
        • Example: "San Francisco"
      • state
        • Type: String
        • Description: State
        • Example: "CA"
      • postal_code
        • Type: String
        • Description: Postal code
        • Example: "94103"
      • location
        • Type: Object
        • Description: Geographical location
          • type
            • Type: String
            • Description: Type of the geographical data, should be "Point"
            • Example: "Point"
          • coordinates
            • Type: Array
            • Description: Coordinates of the location [longitude, latitude]
            • Example: [-122.4194, 37.7749]
  8. contact

    • Type: Object
    • Description: Contact information of the store
      • phone
        • Type: String
        • Description: Phone number
        • Example: "+1-555-555-5555"
      • email
      • website
  9. working_hours

    • Type: Object
    • Description: Working hours of the store for each day of the week
      • monday
        • Type: Object
        • Description: Opening and closing times
        • Example: {"open": "08:00", "close": "20:00"}
      • tuesday
        • Type: Object
        • Description: Opening and closing times
        • Example: {"open": "08:00", "close": "20:00"}
      • wednesday
        • Type: Object
        • Description: Opening and closing times
        • Example: {"open": "08:00", "close": "20:00"}
      • thursday
        • Type: Object
        • Description: Opening and closing times
        • Example: {"open": "08:00", "close": "20:00"}
      • friday
        • Type: Object
        • Description: Opening and closing times
        • Example: {"open": "08:00", "close": "22:00"}
      • saturday
        • Type: Object
        • Description: Opening and closing times
        • Example: {"open": "08:00", "close": "22:00"}
      • sunday
        • Type: Object
        • Description: Opening and closing times
        • Example: {"open": "10:00", "close": "18:00"}
  10. createdBy

  • Type: ObjectId
  • Description: Reference to the sudouser who created this store
  • Example: ObjectId("60d21b4667d0d8992e610c85")

API Routes and Access Permissions:

HTTP Method Endpoint Description Access
GET /api/store/ Returns all stores Superadmin (1)
GET /api/store/:id Returns a single store Superadmin and Store Owner (1, 3)
GET /api/store/region/:region_id Returns all stores in a region Superadmin (1)
GET /api/store/store/:creator_id Returns all stores created by a user Superadmin and Store Owner (1, 3)
POST /api/store/ Creates a new store Superadmin and Creator (1, 3)
PUT /api/store/:id Updates a store Superadmin and Creator (1, 3)
PUT /api/store/:id/status Updates the status of a store Superadmin (1)
DELETE /api/store/:id Deletes a store Superadmin and Creator (1, 3)

Access Notes:

  • The store owner can only access the stores they have created.
  • When a store is created, the status should be pending and the superadmin should change the status to active or inactive.
  • When a store is deleted, the status should be deleted.
  • When a store is suspended, the status should be suspended.
  • When a store is pending, the status should be pending.
  • When a store is active, the status should be active.
  • When a store is inactive, the status should be inactive.

Tasks:

  1. Define the store schema in the model.
  2. Implement the API routes with the specified access permissions.
  3. Add middleware for access control based on user roles.
  4. Implement status change logic according to the specified rules.
  5. Write tests to verify the functionality of each route and status change.

Checklist:

  • Define the store schema in the model
  • Implement GET /api/store/ route
  • Implement GET /api/store/:id route
  • Implement GET /api/store/region/:region_id route
  • Implement GET /api/store/store/:creator_id route
  • Implement POST /api/store/ route
  • Implement PUT /api/store/:id route
  • Implement PUT /api/store/:id/status route
  • Implement DELETE /api/store/:id route
  • Add middleware for access control based on user roles
  • Implement status change logic according to the specified rules
  • Write tests to verify the functionality of each route and status change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants