{"id":25171481,"url":"https://github.com/basemax/musictsgraphql","last_synced_at":"2025-04-03T21:21:49.281Z","repository":{"id":186599737,"uuid":"649518762","full_name":"BaseMax/MusicTSGraphQL","owner":"BaseMax","description":"This project is a GraphQL API built with TypeScript and Fastify, using the Mercurius plugin. It provides a backend server for a music site, allowing you to perform various operations such as managing songs and albums, retrieving information, adding comments, rating songs/albums, and more.","archived":false,"fork":false,"pushed_at":"2025-03-11T23:00:31.000Z","size":731,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T17:08:07.740Z","etag":null,"topics":["graphql","graphql-music","graphql-ts","graphql-typescript","music","music-api","music-graphql","song","songs","ts","ts-graphql","typescript","typescript-graphql"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BaseMax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-06-05T03:51:57.000Z","updated_at":"2025-03-11T23:00:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"48b4a57e-9f87-4970-a677-3395ec052891","html_url":"https://github.com/BaseMax/MusicTSGraphQL","commit_stats":null,"previous_names":["basemax/musictsgraphql"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FMusicTSGraphQL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FMusicTSGraphQL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FMusicTSGraphQL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FMusicTSGraphQL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BaseMax","download_url":"https://codeload.github.com/BaseMax/MusicTSGraphQL/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247079308,"owners_count":20880030,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphql","graphql-music","graphql-ts","graphql-typescript","music","music-api","music-graphql","song","songs","ts","ts-graphql","typescript","typescript-graphql"],"created_at":"2025-02-09T09:20:37.047Z","updated_at":"2025-04-03T21:21:49.253Z","avatar_url":"https://github.com/BaseMax.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Music TS GraphQL\n\nThis project is a GraphQL API built with TypeScript and Fastify, using the Mercurius plugin. It provides a backend server for a music site, allowing you to perform various operations such as managing songs and albums, retrieving information, adding comments, rating songs/albums, and more.\n\n## Features\n\n-   Song and album management\n-   Comment addition and rating\n-   Information retrieval\n\n## Stack\n\nThis project is built using the following technologies:\n\n-   **Language**: TypeScript (Type-safe superset of JavaScript)\n-   **Database**: Prisma (ORM for database access)\n-   **Web Framework**: Fastify (High-performance web framework)\n-   **GraphQL Library**: Apollo Server (GraphQL implementation)\n-   **Testing**: Jest (Testing framework)\n-   **Code Quality**: ESLint (Linting), Prettier (Code formatting)\n\n## Authentication\n\nAuthentication is done through an Authorization Header using a token. The token can be obtained by calling the login and register mutations.\n\nOnce the token is obtained, it needs to be included in the Authorization Header of all subsequent GraphQL requests. The app validates the token and restricts access to certain mutations and queries based on the token's permissions.\n\nSome mutations and queries require higher privileges, such as a specific role, to be executed. These operations can only be performed by users with the required privileges.\n\nExample Header:\n\n```\nAuthorization: \u003ctoken\u003e\n```\n\n## File upload\n\nThis app supports file upload through a dedicated endpoint at `/upload/\u003ctype\u003e/\u003cname-prefix\u003e.extension`. If the uploaded file is an image it will be resized to a specific size based on the chosen type. Currently, the supported types and sizes are:\n\n-   `cover`: { width: 600, height: 600 }\n-   `avatar`: { width: 600, height: 600 }\n\nTo upload a file, you should make a POST request to the `/upload/\u003ctype\u003e/\u003cname-prefix\u003e` endpoint with the file contents as the request body. The request body should be a binary file, not multipart form data.\n\nThe `\u003ctype\u003e` parameter specifies the type of the uploaded file, while the `\u003cname-prefix\u003e` parameter is used to generate a unique filename for the uploaded file. The uploaded file will be resized and saved to the server, and the response will contain a JSON object with the URL of the uploaded file. For example:\nadditionally there is a route to upload Musics\nsomething like : `/upload/music/\u003cname-prefix\u003e.mp3`\n\nExample curl request:\n\n```\ncurl http://localhost:3000/upload/music/something.mp3 -F \"file=@y.mp3\" -H 'Authorization: \u003ctoken\u003e'\n```\n\n```\n{\"url\":\"/poster/testtt-cliiy9tkb000015ln9byqftw4.jpeg\"}\n```\n\nYou can use the returned URL wherever a file is required in your application.\n\n# Usage\n\nTo use this project, follow these steps:\n\n1. Clone this repository:\n\n    ```bash\n    git clone https://github.com/basemax/MusicTSGraphQL\n    ```\n\n\n2. Install dependencies:\n\n    ```bash\n    npm install\n    ```\n\n3. Run the app using Docker Compose:\n\n   ```bash\n   sudo docker compose -p ci -f docker-compose.base-dev.yml -f docker-compose.dev.yml up --build\n   ```\n\n    This will start the app in development mode, with hotreloading enabled. The GraphQL playground will be available at [http://localhost:3000/graphql](http://localhost:3000/graphql). ↗\n\n4. Attach to the container:\n\n    ```bash\n    sudo docker exec -it ci-app-1 bash\n    ```\n\n5. Create an admin account:\n\n   ```bash\n   node dist/create-admin.js\n   ```\n\n    It will prompt you for an email, password, and name to create the superuser account.\n\n## Testing\n\nRun the following command:\n\n```bash\nsudo ./test.sh\n```\n\nIt will automatically do everything and exit with 0 status if everything work well\n\n## Examples\n\nHere are some example GraphQL queries:\n\n1. Query all genres:\n\n    ```graphql\n    query {\n        genres {\n            id\n            name\n        }\n    }\n    ```\n\n2. Query a specific album:\n\n    ```graphql\n    query {\n        album(id: \"\u003calbum_id\u003e\") {\n            id\n            title\n            releaseDate\n            cover\n            musics {\n                id\n                name\n                duration\n            }\n        }\n    }\n    ```\n\n3. Query all unapproved comments:\n\n    ```graphql\n    query {\n        unapprovedComments(pagination: { limit: 10 }) {\n            id\n            text\n            isApproved\n            user {\n                id\n                name\n            }\n            music {\n                id\n                name\n            }\n        }\n    }\n    ```\n\n4. Create a new album:\n\n    ```graphql\n    mutation {\n        createAlbum(input: {\n            title: \"New Album\",\n            cover: \"...\",\n            releaseDate: \"2021-07-12\",\n            musics: [\"\u003cmusic_id_1\u003e\", \"\u003cmusic_id_2\u003e\"]\n        }) {\n            id\n            title\n            releaseDate\n            cover\n            musics {\n                id\n                name\n                duration\n            }\n        }\n    }\n    ```\n\n5. Update an existing album:\n\n    ```graphql\n    mutation {\n        updateAlbum(input: {\n            id: \"\u003calbum_id\u003e\",\n            title: \"Updated Album\",\n            cover: \"...\",\n            releaseDate: \"2021-07-15\",\n            musics: [\"\u003cmusic_id_1\u003e\", \"\u003cmusic_id_2\u003e\", \"\u003cmusic_id_3\u003e\"]\n        }) {\n            id\n            title\n            releaseDate\n            cover\n            musics {\n                id\n                name\n                duration\n            }\n        }\n    }\n    ```\n\n6. Delete a comment:\n\n\n   ```graphql\n   mutation {\n       deleteComment(id: \"\u003ccomment_id\u003e\")\n   }\n   ```\n\n## API Documentation\n\nThe following table describes all the mutations and queries available in the API:\n\n| Query/Mutation                                   | Description                                   |\n| ------------------------------------------------ | --------------------------------------------- |\n| `album(id: String!)`                               | Query a specific album by its ID              |\n| `genres`                                           | Query all genres                              |\n| `genre(id: String!)`                               | Query a specific genre by its ID              |\n| `music(id: String!)`                               | Query a specific song by its ID               |\n| `searchAlbums(input: SearchAlbumInput!)`           | Search for albums based on specific criteria  |\n| `searchMusic(input: SearchMusicInput!)`            | Search for songs based on specific criteria   |\n| `searchSingers(input: SearchSingerInput!)`         | Search for singers based on specific criteria |\n| `singer(id: String!)`                              | Query a specific singer by its ID             |\n| `unapprovedComments(pagination: PaginationInput!)` | Query all unapproved comments                 |\n| `user`                                             | Query the current user                        |\n| `approveComment(id: String!)`                      | Approve a specific comment                    |\n| `changeRole(role: UserRole!, userId: String!)`     | Change the role of a specific user            |\n| `createAlbum(input: CreateAlbumInput!)`            | Create a new album                            |\n| `createComment(input: CreateCommentInput!)`        | Create a new comment                          |\n| `createGenre(input: CreateGenreInput!)`            | Create a new genre                            |\n| `createMusic(input: CreateMusicInput!)`            | Create a new song                             |\n| `createSinger(input: CreateSingerInput!)`          | Create a new singer                           |\n| `deleteComment(id: String!)`                       | Delete a specific comment                     |\n| `deleteMusic(id: String!)`                         | Delete a specific song                        |\n| `deleteSinger(id: String!)`                        | Delete a specific singer                      |\n| `login(input: LoginUserInput!)`                    | Log in a user                                 |\n| `register(input: RegisterUserInput!)`              | Register a new user                           |\n| `updateAlbum(input: UpdateAlbumInput!)`            | Update an existing album                      |\n| `updateComment(input: UpdateCommentInput!)`        | Update an existing comment                    |\n| `updateGenre(input: UpdateGenreInput!)`            | Update an existing genre                      |\n| `updateMusic(input: UpdateMusicInput!)`            | Update an existing song                       |\n| `updateSinger(input: UpdateSingerInput!)`          | Update an existing singer                     |\n\n## License\n\nThis project is licensed under the GPL-3 license. Contributions are welcome, please follow the guidelines in the CONTRIBUTING.md file.\n\nCopyright 2023, Max Base\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Fmusictsgraphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasemax%2Fmusictsgraphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Fmusictsgraphql/lists"}