A backend service for managing categories, options, user authentication, and other core functionalities for a marketplace-like application.
- Authentication:
- Login with OTP, check OTP, and logout functionalities.
- Category Management:
- Create, fetch, and delete categories.
- Option Management:
- Add, update, fetch, and delete options for categories.
- User Profile:
- Fetch user profile information.
- API Documentation:
- Swagger documentation for all endpoints.
- Node.js: Runtime environment.
- Express.js: Web framework.
- MongoDB: NoSQL database (via Mongoose).
- JWT: Authentication tokens.
- Swagger UI: API documentation.
- Multer: File uploads.
- dotenv: Environment variable management.
-
Clone the repository:
git clone https://github.com/mohsen104/divar-backend.git cd divar-backend
-
Install dependencies:
npm install
-
Create a
.env
file in the root directory with the following variables:PORT NODE_ENV MONGODB_URL JWT_SECRET_KEY COOKIE_SECRET_KEY MAP_IR_URL MAP_API_KEY
-
Run the development server:
npm run dev
-
Access the Swagger documentation at:
http://localhost:3000/api-docs
API documentation is available through Swagger at /api-docs
.
- POST
/auth/send-otp
: Login with OTP. - POST
/auth/check-otp
: Verify OTP for login. - GET
/auth/logout
: Logout user.
- POST
/category
: Create a new category. - GET
/category
: Fetch all categories. - DELETE
/category/{id}
: Delete a category by ID.
- POST
/option
: Create a new option for a category. - GET
/option
: Fetch all options. - PUT
/option/{id}
: Update an option by ID. - DELETE
/option/{id}
: Delete an option by ID. - GET
/option/by-category/{categoryId}
: Fetch options for a category by ID. - GET
/option/by-category-slug/{slug}
: Fetch options for a category by slug.
- GET
/user/whoami
: Fetch current user profile.