اذهب إلى المحتوى

السؤال

نشر

هل يمكنكم مساعدتي ب تحسين README بشكل احترافي https://github.com/ZenZN99/Movies-api

# 🎬 Movies API

## 📝 About

Movies API is a backend project developed using Node.js and Express.js to provide a professional system for managing and displaying movies. The project allows users to create accounts, log in, watch movies, and like or unlike them. It also provides admin-specific interfaces for managing movies, including creating new movies, updating, deleting, and uploading images via Cloudinary.

The project uses MongoDB for data storage and JWT for user authentication and securing sensitive operations. It follows best programming practices to create a robust, secure, and user-friendly API.

---

##  How does the project work?

### 1. Register a new user:

#### POST/api/auth/register

This is a process that allows the user to create an account. You must enter all the required fields (username, email, password, confirmPassword). Make sure to add valid information such as a valid email address and a password that is at least 8 characters long and must match the confirmed password.

### Headers:

Content-Type : application/json

### body:

{
"username": "your_name",
"email": "youremail@gmail.com",
"password": "12345678",
"confirmPassword": "12345678"
}

### response:

{
"success": "Account created successfully",
"user": {
"\_id": "user.\_id",
"username": "yourname",
"email": "youremail@gmail.com"
},
"token": "<token>"
}

### 2. Login:

#### POST/api/auth/login

After creating an account, you only need to enter an email address and password, and these must match the email address and password you used to create the account.

### Headers :

Content-Type : application/json

### body :

{
"email": "youremail@gmail.com",
"password": "12345678",
}

### response:

{
"success": "Logged in successfully",
"user": {
"\_id": "user.\_id",
"username": "yourname",
"email": "youremail@gmail.com"
},
"token": "<token>"
}

### 3. Fetch user data :

#### GET/api/auth/me

Now you can see your data here, such as (username, email)

### Headers :

Authorization : Bearer <your token>

## Movies Routes :

### 4. Get all the movies :

#### GET/api/movie

This route allows you to view all movies uploaded by the admin. If no movies exist, it will show 'No movies found yet'

### 5. Get movie by id :

#### GET/api/movie/id

This route allows you to view a single movie by its ID. If the movie does not exist, it will show 'Movie not found'.

### Headers :

Authorization : Bearer <your token>

### 6. create movie :

#### POST/api/movie

This path allows you to upload a new movie, but only administrators can do so after registering with the administrator email address admin@admin.com and the password provided in the .env file ADMIN_PASSWORD. Placing the token inside the Header Authorization Bearer token will then allow you to create a movie.

### Headers :

Authorization : Bearer <your token>

### body => form-data :

title => TEXT MOVIE Name required
content => TEXT MOVIE Content required
image => FILE MOVIE Image required
director => TEXT Director's Name required
date => TEXT MOVIE Date required
genre => TEXT MOVIE Genre required

### responsive :

{
"success": "Movie created successfully",
"movie": {
"title": "your title",
"content": "your content",
"image": "url cloudinary image",
"director": "your director",
"date": "your date",
"genre": "your genre",
"userId": "user.id",
"likes": 0,
"likedBy": [],
"\_id": "movie id",
"createdAt": "Creation time",
"updatedAt": "Update time",
"\_\_v": 0
}
}

### 7. update movie :

#### PUT/api/movie/id

Here you will edit, and you must be an administrator to edit. You will enter all fields except for the image.

### Headers :

Authorization : Bearer <your token>

### body :

title , content, director, date , genre

### 8. delete movie :

#### DELETE/api/movie/id

Here you can delete, but you must be an administrator.

### Headers :

Authorization : Bearer <your token>

### 9. GET movie admin :

#### GET/api/movie/admin/movies

### Headers :

Authorization : Bearer <your token>

Here you will find all the movies uploaded by the administrator.

### 10. Like Movie :

#### POST/api/movie/like/id

Here you can like the app; if you don't like it, it will increase by one, otherwise it will decrease by one. It doesn't matter if you are a user or an administrator.

### Headers :

Authorization : Bearer <your token>

---

## How to Run the Project

### 1. Clone the repository

```bash
git clone https://github.com/ZenZN99/Movies-api.git

cd backend
npm install
npm run start
```

 

Recommended Posts

  • 0
نشر

السلام عليكم ورحمة الله تعالى وبركاته،

على العموم هو مقبول، جيد جدا، لكن ما لاحظته هو غياب الهيكلية والتنظيم فمثلا العناوين غير موحدة في تنسيقها فأنت قمت باستخدامها بشكل  غير متناسق ك ### و#### وهناك تكرار في شرح ال Headers وAuthorization يمكن اختصاره بملاحظة عامة في الأعلى.

كما أن بعض الجمل مكتوبة بأسلوب وصفي طويل وغير رسمي مثل:

  • Here you will edit...

وهنا يفضل استبدالها بتعابير وثائقية مختصرة فليس شرطا أن تشرح كل شيء بالتفصيل وهناك أخطاء خفيفة بسيطة ككتابة "responsive" بدلا من "response"، وأعتقد أنك نسيت إضافة قسم خاص للمتغيرات البيئية .env يمكنك إضافته إن كنت تحتاجه وكان موجودا في مشروعك.

  • 0
نشر

قسم How does the project work هو توثيق للـ API من الأفضل تسميته API Documentation أو Endpoints Reference.

وإضافة قسم Features أي الميزات في البداية لتلخيص ما يمكن للمشروع عمله في نقاط سريعة، وقسم للـ Tech Stack أي التقنيات المستخدمة بشكل منفصل وواضح.

و ذكرت ADMIN_PASSWORD في ملف .env، ولكنك لم توضح للمطور كيفية إعداده، أي مشروع يجب أن يحتوي على ملف env.example. وتوضح في الـ README أنه يجب نسخه إلى .env وكتابة المتغيرات اللازمة مثل:

MONGO_URI
JWT_SECRET
PORT
CLOUDINARY_CLOUD_NAME 
ADMIN_PASSWORD

ولا يوجد ذكر لكيفية استجابة الـ API في حالة حدوث خطأ مثل إدخال خاطئ 400، عدم العثور على عنصر 404، أو عدم وجود صلاحية 401/403، فالتوثيق الاحترافي يشمل أمثلة على استجابات النجاح والفشل.

والنصوص البرمجية مثل POST /api/auth/register، وأجسام JSON، والـ Headers يجب وضعها دائمًا داخل Code Blocks أي بوضعها بين ``` لتحسين القراءة وسهولة النسخ.

 

  • 0
نشر

أولا إليك النقاط الإيجابية في ملف README الحالي:

  • شامل فهو يحتوي على كل الوظائف الرئيسية لل API مثل التسجيل وتسجيل الدخول وإدارة الأفلام وإعجابوعدم إعجاب.
  • مقسّم بطريقة واضحة فكل جزء له عنوان واضح مثل Register و Login و Movies Routes وغيرها.
  • توضيح Headers و Body و Response فهوممتاز للمطور الذي يريد اختبار الـ API مباشرة.
  • ذكر التقنيات المستخدمة مثل Node.js و Express.js و  MongoDB  و JWT و Cloudinary.
  • توضيح صلاحيات المسؤول (Admin).

وإليك المشاكل أو الأشياء التي يمكن تحسينها :

  • طول محتوى بعض الأقسام
    • فبعض الأقسام مثل Register أو Create Movie طويلة جدا بالتفاصيل داخل README.
    • يمكن تبسيطها وإحالة المطور إلى Postman collection أو API doc لتجنب الحشو.
  • التنسيق غير متسق بالكامل
    • فبعض العناوين تستخدم #### وبعضها لا.
    • JSON Responses أحيانًا تستخدم _id وأحيانًا \_id. الأفضل توحيد الصياغة.
  • نقص Badges
    • لا يوجد Build Status, Node version, أو Coverage badges، مما يعطي انطباع أقل احترافية.
  • نقص مثال للبيئة .env
    • لم توضح متغيرات البيئة المطلوبة مثل MONGO_URI و JWT_SECRET و CLOUDINARY_API_KEY وهي مهمة لأي مطور يريد تشغيل المشروع.
  • طريقة التشغيل غير واضحة بالكامل
    • فلا يوجد توضيح للفرق بين npm run start و npm run dev .
    • يمكن إضافة خطوات تشغيل MongoDB محليًا أو استخدام Atlas.
  • بعض الأخطاء اللغوية والصياغية
    • مثل: "Here you can like the app; if you don't like it, it will increase by one…" هذه الجملة مربكة.
    • ينصح بتبسيط اللغة وجعلها مباشرة وواضحة.
  • Missing Contribution / License Section
    • README الحالي لا يحتوي على قسم عن المساهمة أو الترخيص، وهذا مهم للمشاريع المفتوحة المصدر.

وإليك نصائح للتحسين :

  • تبسيط شرح كل Route
    • حيث ضع الأمثلة الأساسية فقط، وأضف رابطًا لتوثيق Postman أو Swagger للمزيد من التفاصيل.
  • أضف Badges
    • مثل Node version و build status و license و npm downloads.
  • أضف جدول متغيرات البيئة (.env)
  • تحسين لغة الردود
    • مثال فبدلا من "Here you can like the app; if you don't like it, it will increase by one", اجعلها "Toggle like/unlike for a movie."
  • استخدم تنسيق موحد للـ Headers/Body/Response
  • ضف Contribution & License

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...