Loading repository data…
Loading repository data…
kyyril / repository
Blog API Backend A RESTful API backend for a blog application built with TypeScript, Express.js, Postgresql and Prisma ORM.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
A RESTful API backend for a blog application built with TypeScript, Express.js, Supabase, and Prisma ORM.
User Authentication & Profiles
Blog Management
Social Features
Analytics
/api/auth/googlePOST{
"token": "google-id-token"
}
This section details the Google authentication flow, allowing users to sign in using their Google accounts.
URL: /api/auth/google
Method: POST
Body:
{
"token": "google-id-token"
}
The token field should contain the ID token obtained from the Google Sign-In client.
Response:
{
"message": "Google authentication successful",
"user": {
"id": "user-id",
"name": "User Name",
"email": "user@example.com",
"bio": "User bio (if available)",
"avatar": "URL to user's avatar"
}
}
Upon successful authentication, the server sets access_token and refresh_token as HTTP-only cookies and returns the authenticated user object.
This endpoint allows a client to retrieve information about the currently authenticated user.
URL: /api/auth/me
Method: GET
Authentication: Requires a valid access_token cookie.
Response:
{
"user": {
"id": "user-id",
"name": "User Name",
"email": "user@example.com",
"bio": "User bio (if available)",
"avatar": "URL to user's avatar"
}
}
Returns the user object if authenticated, otherwise a 401 Unauthorized error.
This endpoint allows clients to obtain a new access token using a valid refresh token when the current access token expires.
URL: /api/auth/refresh-token
Method: POST
Authentication: Requires a valid refresh_token cookie.
Response:
{
"message": "Token refreshed successfully",
"user": {
"id": "user-id",
"name": "User Name",
"email": "user@example.com",
"bio": "User bio (if available)",
"avatar": "URL to user's avatar"
}
}
Upon successful token refresh, a new access_token cookie is set, and the user object is returned. If the refresh token is invalid or expired, both access_token and refresh_token cookies are cleared, and a 401 Unauthorized error is returned.
This endpoint logs out the user by clearing the authentication cookies.
URL: /api/auth/logout
Method: POST
Response:
{
"message": "Logout successful"
}
Clears both access_token and refresh_token HTTP-only cookies.
/api/blogsPOST{
"title": "Getting Started with Next.js 15 and App Router",
"description": "Learn how to build modern web applications with Next.js 15 and its revolutionary App Router architecture.",
"content": "# Getting Started with Next.js 15 and App Router\n\nNext.js has revolutionized...",
"categories": ["Web Development", "React"],
"tags": ["nextjs", "react", "typescript", "app-router"],
"readingTime": 5,
"featured": true,
"image": "[File Upload]"
}
/api/blogs/blog/:idPUT/api/blogs/blog/:idDELETE/api/blogs?page=1&limit=10GET/api/blogs/blog/:idGET{
"id": "blog-uuid",
"title": "Getting Started with Next.js 15",
"slug": "getting-started-with-nextjs-15",
"description": "Learn how to build modern web applications...",
"content": "# Getting Started with Next.js 15...",
"image": "https://example.com/blog-image.jpg",
"date": "2024-01-20T12:00:00Z",
"readingTime": 5,
"featured": true,
"viewCount": 1250,
"likeCount": 42,
"bookmarkCount": 15,
"author": {
"id": "user-uuid",
"name": "Jane Smith",
"bio": "Frontend Developer",
"avatar": "https://example.com/avatar.jpg"
},
"categories": ["Web Development", "React"],
"tags": ["nextjs", "react", "typescript"],
"liked": false,
"bookmarked": false
}
/api/blogs/:slugGET/api/blogs/search?query=next.js&page=1&limit=10GET/api/blogs/category/:category?page=1&limit=10GET/api/blogs/tags/:tags?page=1&limit=10GET/api/blogs/blog/:id/viewPOSTToggles the like status of a blog for the authenticated user.
/api/blogs/blog/:id/likePOST{
"message": "Blog liked successfully",
"liked": true,
"likeCount": 42
}
Or when unliking:
{
"message": "Blog unliked successfully",
"liked": false,
"likeCount": 41
}
Toggles the bookmark status of a blog for the authenticated user.
/api/blogs/blog/:id/bookmarkPOST{
"message": "Blog bookmarked successfully",
"bookmarked": true,
"bookmarkCount": 15
}
Or when removing bookmark:
{
"message": "Blog bookmark removed successfully",
"bookmarked": false,
"bookmarkCount": 14
}
Returns the current user's interaction status with a blog (likes and bookmarks).
/api/blogs/blog/:id/interactionGET{
"liked": true,
"bookmarked": false,
"likeCount": 42,
"bookmarkCount": 15
}
/api/users/:userIdGET{
"id": "user-uuid",
"name": "Jane Smith",
"email": "jane@example.com",
"bio": "Frontend Developer and Next.js enthusiast",
"avatar": "https://example.com/avatar.jpg",
"country": "United States",
"twitterAcc": "https://twitter.com/janesmith",
"githubAcc": "https://github.com/janesmith",
"linkedinAcc": "https://linkedin.com/in/janesmith",
"anotherAcc": "",
"createdAt": "2024-01-20T12:00:00Z",
"updatedAt": "2024-01-20T13:00:00Z",
"_count": {
"followers": 150,
"following": 89,
"blogs": 25
},
"blogs": [],
"followers": [],
"following": []
}
#### Get User Followers
- **URL**: `/api/users/:userId/followers`
- **Method**: `GET`
- **Auth**: Optional
- **Response**:
```json
[
{
"id": "user-uuid",
"name": "John Doe",
"email": "john@example.com",
"avatar": "https://example.com/avatar.jpg"
},
{
"id": "user-uuid2",
"name": "Jane Smith",
"email": "jane@example.com",
"avatar": "https://example.com/avatar2.jpg"
}
]
/api/users/:userId/followingGET[
{
"id": "user-uuid",
"name": "John Doe",
"email": "john@example.com",
"avatar": "https://example.com/avatar.jpg"
},
{
"id": "user-uuid2",
"name": "Jane Smith",
"email": "jane@example.com",
"avatar": "https://example.com/avatar2.jpg"
}
]
Updates the authenticated user's profile information.
/api/users/profilePUT{
"name": "Jane Smith",
"bio": "Frontend Developer and Next.js enthusiast",
"country": "United States",
"twitterAcc": "https://twitter.com/janesmith",
"githubAcc": "https://github.com/janesmith",
"linkedinAcc": "https://linkedin.com/in/janesmith",
"anotherAcc": "",
"avatar": "[File Upload]" // Optional profile image
}
{
"id": "user-uuid",
"name": "Jane Smith",
"email": "jane@example.com",
"bio": "Frontend Developer and Next.js enthusiast",
"avatar": "https://example.com/new-avatar.jpg",
"country": "United States",
"twitterAcc": "https://twitter.com/janesmith",
"githubAcc": "https://github.com/janesmith",
"linkedinAcc": "https://linkedin.com/in/janesmith",
"anotherAcc": "",
"createdAt": "2024-01-20T12:00:00Z",
"updatedAt": "2024-01-20T13:00:00Z"
}
/api/users/:userId/followPOST/api/users/:userId/followDELETE/api/users/:userId/follow-statusGET/api/blogs/:blogId/commentsPOST{
"content": "Great article! Very informative.",
"parentId": "optional-parent-comment-id" // Include for replies
}
/api/blogs/:blogId/comments?page=1&limit=10GET{
"comments": [
{
"id": "comment-uuid",
"content": "Great article! Very informative.",
"createdAt": "2024-01-20T12:00:00Z",
"authorId": "user-uuid",
"parentId": null,
"author": {
"id": "user-uuid",
"name": "John Doe",
"avatar": "https://example.com/avatar.jpg"
},
"replies": [
{
"id": "reply-uuid",
"content": "Thanks for your feedback!",
"createdAt": "2024-01-20T12:30:00Z",
"authorId": "author-uuid",
"parentId": "comment-uuid",
"author": {
"id": "author-uuid",
"name": "Jane Smith",
"avatar": "https://example.com/jane-avatar.jpg"
}
}
]
}
],
"pagination": {
"total": 25,
"pages": 3,
"current": 1
}
}
/api/comments/:idPATCH{
"content": "Updated comment content"
}
/api/comments/:idDELETE
#### Create/Delete like Blog
- **URL**: `/api/blogs/:id/like`
- **Method**: `POST`
- **Auth**: Required
- **Body**: json
#### Create/Delete like Bookmark
- **URL**: `/api/blogs/:id/bookmark`
- **Method**: `POST`
- **Auth**: Required
- **Body**: json
#### Get Interaction Status
- **URL**: `/api/blogs/:id/interaction`
- **Method**: `GET`
- **Auth**: Required
#### Get Blogs by Tags
- **URL**: `/api/blogs/tags/:tags?page=1&limit=10`
- **Method**: `GET`
#### Get Bookmarks
- **URL**: `/api/blogs/bookmarks`
- **Method**: `GET`
- **Auth**: Required
#### Get Blog by own
- **URL**: `/api/blogs/bookma