{"id":25171779,"url":"https://github.com/basemax/blogsitegraphqlapi","last_synced_at":"2026-04-13T06:07:01.600Z","repository":{"id":171767889,"uuid":"642285149","full_name":"BaseMax/BlogSiteGraphQLAPI","owner":"BaseMax","description":"This project is a GraphQL API built with NestJS and TypeScript. It provides a backend for a blog site, allowing users to register, create and manage blog posts, manage categories, and create pages. It also supports authentication using JWT tokens.","archived":false,"fork":false,"pushed_at":"2024-04-11T08:47:21.000Z","size":1056,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T17:08:04.220Z","etag":null,"topics":["backend","gql","graphql","javascript","js","ts","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"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":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-05-18T08:20:20.000Z","updated_at":"2024-03-28T22:48:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"98111db3-180e-45c3-9fa2-6c5dde9a3c28","html_url":"https://github.com/BaseMax/BlogSiteGraphQLAPI","commit_stats":null,"previous_names":["basemax/blogsitegraphqlapi"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FBlogSiteGraphQLAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FBlogSiteGraphQLAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FBlogSiteGraphQLAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FBlogSiteGraphQLAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BaseMax","download_url":"https://codeload.github.com/BaseMax/BlogSiteGraphQLAPI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247080375,"owners_count":20880254,"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":["backend","gql","graphql","javascript","js","ts","typescript"],"created_at":"2025-02-09T09:22:04.278Z","updated_at":"2026-04-13T06:07:01.565Z","avatar_url":"https://github.com/BaseMax.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BlogSiteGraphQLAPI\r\n\r\nThis project is a GraphQL API that implements a blog system. Each blog has its own dedicated username and id and has its own posts, categories, and pages. Blogs are completely separated from each other.\r\n\r\nThe login and registration phases are done using a REST API. The whole authentication mechanism in the GraphQL system is implemented using an Authorization header (with a JWT Bearer token). For the user to use the GraphQL API, they must use a Blogid header, which indicates the blog that is currently in use. If the authentication header's user matches with the blog owner or the user is an admin, they are allowed to run mutations. Register and login parts require two fields as post data: username, password.\r\n\r\n## Demo\r\n\r\n![BlogSite GraphQL API](https://github.com/BaseMax/BlogSiteGraphQLAPI/assets/2658040/98421bd2-6744-4655-8b8b-daafb35af3ff)\r\n![BlogSite GraphQL API](https://github.com/BaseMax/BlogSiteGraphQLAPI/assets/2658040/31ed8b78-fb3e-40bd-95af-572a6329ef6c)\r\n\r\n\u003c!--\r\n![BlogSite GraphQL API](https://github.com/BaseMax/BlogSiteGraphQLAPI/assets/51885828/fd4f8f93-0df4-4b69-8588-1b9eb53114ed)\r\n![BlogSite GraphQL API](https://github.com/BaseMax/BlogSiteGraphQLAPI/assets/51885828/e1c17a19-81a4-4223-9c0d-3c2ad4ac4be4)\r\n![BlogSite GraphQL API](https://github.com/BaseMax/BlogSiteGraphQLAPI/assets/51885828/8508a435-1d65-47a3-ad86-41f47cf33f49)\r\n--\u003e\r\n\r\n------------\r\n\r\nThe REST API's endpoints for authentication are:\r\n\r\n- POST /auth/login\r\n- POST /auth/register\r\n- GET /auth/me\r\n\r\nFor the register response, the same structure as login response is used. For /auth/me, we only have a response.\r\n\r\n## Authentication\r\n\r\nHere are some sample requests with curl:\r\n\r\n### Login\r\n```bash\r\ncurl -X POST -H \"Content-Type: application/json\" -d '{\"username\":\"ehsan2\",\"password\":\"Test123!\"}' http://localhost:3000/auth/login \r\n```\r\n\r\nResponse:\r\n```json\r\n{\"user\":{\"id\":\"cli1e06i70000ng7ebhvisec8\",\"username\":\"ehsan2\",\"isAdmin\":false},\"token\":\"\u003ctoken\u003e\"}\r\n```\r\n\r\n### Register\r\n\r\n```bash\r\ncurl -X POST -H \"Content-Type: application/json\" -d '{\"username\":\"newuser\",\"password\":\"Test123!\"}' http://localhost:3000/auth/register\r\n```\r\n\r\nResponse:\r\n```json\r\n{\"user\":{\"id\":\"cli1e06i70000ng7ebhvisec9\",\"username\":\"newuser\",\"isAdmin\":false},\"token\":\"\u003ctoken\u003e\"}\r\n```\r\n\r\n### Get User Information\r\n\r\n```bash\r\ncurl -X GET -H \"Authorization: Bearer \u003ctoken\u003e\" http://localhost:3000/auth/me\r\n```\r\n\r\nResponse:\r\n```json\r\n{\"id\":\"cli1e06i70000ng7ebhvisec8\",\"username\":\"ehsan2\",\"isAdmin\":false}\r\n```\r\n\r\n## GraphQL Queries\r\n\r\nHere are some sample GraphQL queries for the system:\r\n\r\n### Get all posts\r\n\r\n```graphql\r\nquery {\r\n  posts(input: { limit: 10, skip: 0 }) {\r\n    total\r\n    data {\r\n      id\r\n      title\r\n      content\r\n      category {\r\n        id\r\n        title\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n### Get all pages\r\n\r\n```graphql\r\nquery {\r\n  pages(input: { limit: 10, skip: 0 }) {\r\n    total\r\n    data {\r\n      id\r\n      title\r\n      content\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n### Get all categories\r\n\r\n```graphql\r\nquery {\r\n  categories(input: { limit: 10, skip:0 }) {\r\n    total\r\n    data {\r\n      id\r\n      title\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n### Get all posts in a category\r\n\r\n```graphql\r\nquery {\r\n  category(id: \"\u003ccategory_id\u003e\") {\r\n    id\r\n    title\r\n    posts(input: { limit: 10, skip: 0 }) {\r\n      total\r\n      data {\r\n        id\r\n        title\r\n        content\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n### Create a new post\r\n\r\n```graphql\r\nmutation {\r\n  createPost(input: { title: \"New post\", content: \"This is a new post\", categoryId: \"\u003ccategory_id\u003e\" }) {\r\n    id\r\n    title\r\n    content\r\n    category {\r\n      id\r\n      title\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n## API Documentation\r\n\r\n| Query/Mutation | Description |\r\n| -------------- | ----------- |\r\n| `blog` | Returns the blog data for the current user |\r\n| `category(id: String!)` | Returns a category by ID |\r\n| `categories(input: SearchCategoryInput!)` | Returns a list of categories with pagination and search filters |\r\n| `post(id: String!)` | Returns a post by ID |\r\n| `posts(input: SearchPostInput!)` | Returns a list of posts with pagination and search filters |\r\n| `page(id: String!)` | Returns a page by ID |\r\n| `pages(input: SearchPageInput!)` | Returns a list of pages with pagination and search filters |\r\n| `createCategory(input: CreateCategoryInput!)` | Creates a new category |\r\n| `deleteCategory(id: String!)` | Deletes a category by ID |\r\n| `updateCategory(input: UpdateCategoryInput!)` | Updates a category by ID |\r\n| `createPost(input: CreatePostInput!)` | Creates a new post |\r\n| `deletePost(id: String!)` | Deletes a post by ID |\r\n| `updatePost(input: UpdatePostInput!)` | Updates a post by ID |\r\n| `createPage(input: CreatePageInput!)` | Creates a new page |\r\n| `deletePage(id: String!)` | Deletes a page by ID |\r\n| `updatePage(input: UpdatePageInput!)` | Updates a page by ID |\r\n\r\n### Query/Mutation arguments\r\n\r\n#### SearchCategoryInput\r\n| Argument | Type | Description |\r\n| -------- | ---- | ----------- |\r\n| limit | Int! | The maximum number of categories to return |\r\n| skip | Int! | The number of categories to skip |\r\n| text | String | The text to search for in category titles |\r\n\r\n#### SearchPostInput\r\n| Argument | Type | Description |\r\n| -------- | ---- | ----------- |\r\n| limit | Int! | The maximum number of posts to return |\r\n| skip | Int! | The number of posts to skip |\r\n| text | String | The text to search for in post titles |\r\n| categoryId | ID | The ID of the category to filter by |\r\n\r\n#### SearchPageInput\r\n| Argument | Type |Description |\r\n| -------- | ---- | ----------- |\r\n| limit | Int! | The maximum number of pages to return |\r\n| skip | Int! | The number of pages to skip |\r\n| text | String | The text to search for in page titles |\r\n\r\n#### CreateCategoryInput\r\n| Argument | Type | Description |\r\n| -------- | ---- | ----------- |\r\n| title | String! | The title of the category |\r\n\r\n#### UpdateCategoryInput\r\n| Argument | Type | Description |\r\n| -------- | ---- | ----------- |\r\n| title | String | The title of the category |\r\n| id | String! | The ID of the category to update |\r\n\r\n#### CreatePostInput\r\n| Argument | Type | Description |\r\n| -------- | ---- | ----------- |\r\n| title | String! | The title of the post |\r\n| content | String! | The content of the post |\r\n| categoryId | ID! | The ID of the category to assign the post to |\r\n\r\n#### UpdatePostInput\r\n| Argument | Type | Description |\r\n| -------- | ---- | ----------- |\r\n| title | String | The updated title of the post |\r\n| content | String | The updated content of the post |\r\n| categoryId | ID | The updated ID of the category to assign the post to |\r\n| id | String! | The ID of the post to update |\r\n\r\n#### CreatePageInput\r\n| Argument | Type | Description |\r\n| -------- | ---- | ----------- |\r\n| title | String! | The title of the page |\r\n| content | String! | The content of thepage |\r\n\r\n#### UpdatePageInput\r\n| Argument | Type | Description |\r\n| -------- | ---- | ----------- |\r\n| title | String | The updated title of the page |\r\n| content | String | The updated content of the page |\r\n| id | String! | The ID of the page to update |\r\n\r\n## Technologies\r\nThis project is built using NestJS, TypeScript, MySQL, and Prisma.\r\n\r\n## Features\r\n- Register and create a new blog\r\n- Login\r\n- Get all posts + pagination + filter/search\r\n- Get all pages + pagination + filter/search\r\n- Get all categories + pagination + filter/search\r\n- Get all posts in a category + pagination + filter/search\r\n- Create a new post\r\n- Create a new page\r\n- Create a new category\r\n- Edit a post\r\n- Edit a page\r\n- Edit a category\r\n\r\n## Usage\r\nTo use this project, follow these steps:\r\n\r\n1. Clone this repository:\r\n   ```\r\n   git clone https://github.com/basemax/RestaurantGraphqlApi\r\n   ```\r\n2. Install dependencies:\r\n   ```\r\n   npm install\r\n   ```\r\n3. Create an admin account:\r\n   ```\r\n   npx nest start --entryFile create-admin.js\r\n   ```\r\n   It will prompt you for an email, password, and name to create the superuser account.\r\n4. Run the app using Docker Compose:\r\n   ```\r\n   sudo docker-compose -f docker-compose.dev.yml up\r\n   ```\r\n   This will start the app in development mode, with hotreloading enabled. The GraphQL playground will be available at `http://localhost:3000/graphql`.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Fblogsitegraphqlapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasemax%2Fblogsitegraphqlapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Fblogsitegraphqlapi/lists"}