This project is a GraphQL-based API for a YouTube clone. It allows users to perform various operations related to videos, channels, and user interactions. The API is implemented using TypeScript and leverages the power and flexibility of GraphQL for efficient data retrieval and manipulation.
GPL-3.0 License
This project is a GraphQL-based API for a YouTube clone. It allows users to perform various operations related to videos, channels, and user interactions. The API is implemented using TypeScript and leverages the power and flexibility of GraphQL for efficient data retrieval and manipulation.
The following technologies and tools are used in this project:
Clone the repository:
git clone https://github.com/BaseMax/YoutubeGraphQL.git
Navigate to the project directory:
cd YoutubeGraphQL
Install the dependencies:
npm install
Set up the environment variables:
Create a .env
file in the project root.
Define the required environment variables in the .env file. For example:
PORT=3000
MONGODB_URL=mongodb://localhost:27017/youtube-clone
AWS_ACCESS_KEY_ID=your-access-key-id
AWS_SECRET_ACCESS_KEY=your-secret-access-key
AWS_BUCKET_NAME=your-bucket-name
JWT_SECRET=your-jwt-secret
Start the development server:
npm run dev
This will start the server at http://localhost:3000.
getUser(id: ID!): User
: Retrieves a user's information by their ID.getVideo(id: ID!): Video
: Retrieves a video's information by its ID.getChannel(id: ID!): Channel
: Retrieves a channel's information by its ID.getTrendingVideos(limit: Int!): [Video]
: Retrieves a list of trending videos, limited by the specified number.getPopularChannels(limit: Int!): [Channel]
: Retrieves a list of popular channels, limited by the specified number.searchVideos(query: String!): [Video]
:Searches for videos based on the provided query string.searchChannels(query: String!): [Channel]
: Searches for channels based on the provided query string.getSubscribedChannels(userId: ID!): [Channel]
: Retrieves a list of channels subscribed to by a user.getCommentsByVideo(videoId: ID!): [Comment]
: Retrieves a list of comments for a specific video.getRecommendedVideos(userId: ID!): [Video]
: Retrieves a list of recommended videos based on a user's preferences.getLikedVideos(userId: ID!): [Video]
: Retrieves a list of videos liked by a user.getVideoComments(videoId: ID!): [Comment]
: Retrieves a list of comments for a specific video.getLikedVideosByUser(userId: ID!): [Video]
: Retrieves a list of videos liked by a specific user.getSubscribedChannelsByUser(userId: ID!): [Channel]
: Retrieves a list of channels subscribed to by a specific user.getChannelVideos(channelId: ID!): [Video]
: Retrieves a list of videos uploaded by a specific channel.getRecommendedChannels(userId: ID!): [Channel]
: Retrieves a list of recommended channels based on a user's preferences.registerUser(input: RegisterUserInput!): AuthPayload
: Registers a new user with the provided user information.loginUser(input: LoginUserInput!): AuthPayload
: Authenticates a user with the provided login credentials.createVideo(input: UploadVideoInput!): Video
: Uploads a new video with the provided video information.likeVideo(videoId: ID!): Video
: Likes a video specified by its ID.dislikeVideo(videoId: ID!): Video
: Dislikes a video specified by its ID.addComment(videoId: ID!, input: AddCommentInput!): Comment
: Adds a comment to a video specified by its ID.subscribeToChannel(channelId: ID!): Channel
: Subscribes to a channel specified by its ID.updateUserProfile(input: UpdateUserProfileInput!): User
: Updates the user's profile information with the provided input.deleteComment(commentId: ID!): Boolean
: Deletes a specific comment specified by its ID.createChannel(input: CreateChannelInput!): Channel
: Creates a new channel with the provided channel information.updateChannel(channelId: ID!, input: UpdateChannelInput!): Channel
: Updates the information of a specific channel specified by its ID.deleteChannel(channelId: ID!): Boolean
: Deletes a specific channel specified by its ID.subscribeToPlaylist(playlistId: ID!): Playlist
: Subscribes to a playlist specified by its ID.createPlaylist(input: CreatePlaylistInput!): Playlist
: Creates a new playlist with the provided playlist information.type User {
id: ID!
name: String!
email: String!
password: String!
avatarUrl: String
createdAt: String!
updatedAt: String!
}
type Video {
id: ID!
title: String!
description: String
url: String!
thumbnailUrl: String
views: Int!
likes: Int!
dislikes: Int!
duration: Float!
uploader: User!
uploadedAt: String!
}
type Channel {
id: ID!
name: String!
description: String
avatarUrl: String
subscribers: Int!
owner: User!
createdAt: String!
updatedAt: String!
}
type Comment {
id: ID!
text: String!
author: User!
video: Video!
createdAt: String!
updatedAt: String!
}
type AuthPayload {
token: String!
name: String!
}
input RegisterUserInput {
name: String!
email: String!
password: String!
confirmPassword : String
}
input LoginUserInput {
email: String!
password: String!
}
input UploadVideoInput {
title: String!
description: String
url: String!
thumbnailUrl: String
duration: Float!
}
input AddCommentInput {
text: String!
videoId: ID!
}
input UpdateUserProfileInput {
name: String
avatarUrl: String
}
input CreateChannelInput {
name: String!
description: String
}
input UpdateChannelInput {
name: String
description: String
}
.. TODO
You can use tools like Postman or Insomnia to interact with the API.
Access the GraphQL Playground by navigating to http://localhost:3000/graphql in your browser.
The API documentation and usage examples can be found in the API Reference file.
Contributions to this project are welcome. To contribute, please follow these steps:
This project is licensed under the GPL-3.0 License.
Copyright 2023, Max Base