{"id":24999858,"url":"https://github.com/bagork/nestjs-blog-app-api","last_synced_at":"2025-03-29T18:23:49.675Z","repository":{"id":273934005,"uuid":"899836267","full_name":"BaGorK/nestjs-blog-app-api","owner":"BaGorK","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-17T09:34:51.000Z","size":892,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-17T10:30:28.803Z","etag":null,"topics":["nestjs","nodejs","postgresql","swagger","typescript"],"latest_commit_sha":null,"homepage":"https://nestjs-blog-app-api.onrender.com/api","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/BaGorK.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-07T06:20:47.000Z","updated_at":"2025-02-17T09:34:54.000Z","dependencies_parsed_at":"2025-01-23T21:29:04.930Z","dependency_job_id":null,"html_url":"https://github.com/BaGorK/nestjs-blog-app-api","commit_stats":null,"previous_names":["bagork/nestjs-blog-app-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaGorK%2Fnestjs-blog-app-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaGorK%2Fnestjs-blog-app-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaGorK%2Fnestjs-blog-app-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaGorK%2Fnestjs-blog-app-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BaGorK","download_url":"https://codeload.github.com/BaGorK/nestjs-blog-app-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246224825,"owners_count":20743453,"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":["nestjs","nodejs","postgresql","swagger","typescript"],"created_at":"2025-02-04T19:19:50.094Z","updated_at":"2025-03-29T18:23:49.656Z","avatar_url":"https://github.com/BaGorK.png","language":"TypeScript","funding_links":["https://opencollective.com/nest","https://paypal.me/kamilmysliwiec"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://wakatime.com/badge/github/BaGorK/nestjs-blog-app-api\" target=\"blank\"\u003e\u003cimg src=\"https://wakatime.com/badge/github/BaGorK/nestjs-blog-app-api.svg\" alt=\"\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"http://nestjs.com/\" target=\"blank\"\u003e\u003cimg src=\"https://nestjs.com/img/logo-small.svg\" width=\"120\" alt=\"Nest Logo\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456\n[circleci-url]: https://circleci.com/gh/nestjs/nest\n\n  \u003cp align=\"center\"\u003eA progressive \u003ca href=\"http://nodejs.org\" target=\"_blank\"\u003eNode.js\u003c/a\u003e framework for building efficient and scalable server-side applications.\u003c/p\u003e\n    \u003cp align=\"center\"\u003e\n\u003ca href=\"https://www.npmjs.com/~nestjscore\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@nestjs/core.svg\" alt=\"NPM Version\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/~nestjscore\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/@nestjs/core.svg\" alt=\"Package License\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/~nestjscore\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/@nestjs/common.svg\" alt=\"NPM Downloads\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://circleci.com/gh/nestjs/nest\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/circleci/build/github/nestjs/nest/master\" alt=\"CircleCI\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://coveralls.io/github/nestjs/nest?branch=master\" target=\"_blank\"\u003e\u003cimg src=\"https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9\" alt=\"Coverage\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://discord.gg/G7Qnnhy\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/discord-online-brightgreen.svg\" alt=\"Discord\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/nest#backer\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/nest/backers/badge.svg\" alt=\"Backers on Open Collective\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/nest#sponsor\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/nest/sponsors/badge.svg\" alt=\"Sponsors on Open Collective\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://paypal.me/kamilmysliwiec\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/Donate-PayPal-ff3f59.svg\" alt=\"Donate us\"/\u003e\u003c/a\u003e\n    \u003ca href=\"https://opencollective.com/nest#sponsor\"  target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg\" alt=\"Support us\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://twitter.com/nestframework\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/twitter/follow/nestframework.svg?style=social\u0026label=Follow\" alt=\"Follow us on Twitter\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/user-attachments/assets/54e3ce9e-f867-4383-b361-4eb8ee6e1665\" /\u003e\n\u003c/p\u003e\n\n# NestJS Blog API\n\nThis project is a robust **NestJS Blog API** designed to handle user authentication, Google OAuth login, JWT-based access control, and various other features for a blog application. It uses PostgreSQL with TypeORM and integrates several essential technologies, including JWT for authentication and bcrypt for password hashing.\n\n---\n\n## Features\n\n- **User Authentication**: Sign-in and JWT token-based authentication.\n- **Google Authentication**: Supports Google login using OAuth2 tokens.\n- **JWT Tokens**: Secure access and refresh tokens for user sessions.\n- **Role-based Access**: Protect routes based on the user's authentication state.\n- **PostgreSQL Database**: All data is stored in a PostgreSQL database using TypeORM.\n- **Environment Configuration**: Dynamic configuration for different environments using `@nestjs/config`.\n\n---\n\n## Technologies\n\n- **NestJS**: A powerful Node.js framework for building efficient and scalable server-side applications.\n- **PostgreSQL**: A relational database management system.\n- **TypeORM**: An ORM that works with SQL-based databases and integrates seamlessly with NestJS.\n- **JWT**: JSON Web Tokens for securing endpoints and handling user sessions.\n- **BcryptJS**: For secure password hashing.\n- **Google OAuth**: For authenticating users via Google.\n- **Joi**: For validating environment variables.\n\n---\n\n## Getting Started\n\nFollow the steps below to get your NestJS blog API up and running locally.\n\n### Prerequisites\n\n- Node.js v18 or higher\n- PostgreSQL\n- NestJS CLI (Optional, but recommended)\n\n### Installation\n\n1. Clone this repository:\n\n   ```bash\n    git clone https://github.com/BaGorK/nestjs-blog-app-api.git\n    cd nestjs-blog-app-api\n   ```\n\n2. Install the dependencies:\n\n   ```bash\n   yarn install\n   ```\n\n3. Compile and run the project\n\n   ```bash\n   # development\n   yarn run start\n\n   # watch mode\n   yarn run start:dev\n\n   # production mode\n   yarn run start:prod\n   ```\n\n4. Create a .env file in the root directory and set the required environment variables. You can reference the example below:\n\n   ```bash\n   NODE_ENV=development\n   DATABASE_PORT=5432\n   DATABASE_USER=your_db_user\n   DATABASE_PASSWORD=your_db_password\n   DATABASE_HOST=localhost\n   DATABASE_NAME=your_db_name\n   JWT_SECRET=your_jwt_secret\n   JWT_TOKEN_AUDIENCE=your_jwt_audience\n   JWT_TOKEN_ISSUER=your_jwt_issuer\n   JWT_ACCESS_TOKEN_TTL=3600\n   JWT_REFRESH_TOKEN_TTL=25920\n   GOOGLE_CLIENT_ID=your_google_client_id\n   GOOGLE_CLIENT_SECRET=your_google_client_secret\n   API_VERSION=v1\n   ```\n\n---\n\n### Available Scripts\n\n`start:dev` : Run the application in development mode with live reload (`NODE_ENV=development`).\n\n`start:prod` : Run the application in production mode.\n\n`build` : Build the project.\n\n`format` : Format the code using Prettier.\n\n`lint` : Lint the codebase using ESLint.\n\n`test` : Run unit tests using Jest.\n\n`test:watch` : Watch for file changes and rerun tests.\n\n`test:cov` : Generate code coverage for tests.\n\n`test:e2e` : Run end-to-end tests.\n\n`doc` : Generate and view API documentation with Compodoc.\n\n### API Endpoints\n\n#### Authentication\n\nPOST `/auth/sign-in`: Sign in with email and password.\n\nPOST `/auth/refresh-tokens`: Refresh your JWT access and refresh tokens.\n\nPOST `/auth/google-authentication`: Authenticate a user using a Google OAuth token.\n\n### Swagger Documentation\n\nAPI documentation is available at `https://nestjs-blog-app-api.onrender.com/api`. You can interact with the API endpoints directly from the Swagger UI.\n\n### Database\n\nThis project uses PostgreSQL as the database engine. The connection details are configured using environment variables. The application relies on TypeORM for database interaction, which supports migrations and synchronization.\n\n#### Database Configuration Example\n\n```typescript\nexport default registerAs('database', () =\u003e ({\n  port: Number(process.env.DATABASE_PORT || 5432),\n  username: process.env.DATABASE_USER,\n  password: process.env.DATABASE_PASSWORD,\n  host: process.env.DATABASE_HOST || 'localhost',\n  database_name: process.env.DATABASE_NAME,\n  autoLoadEntities: Boolean(process.env.NODE_ENV === 'development'),\n  synchronize: Boolean(process.env.NODE_ENV === 'development'),\n  ssl: Boolean(process.env.NODE_ENV === 'production'),\n}));\n```\n\n### Security\n\n- Passwords are securely hashed using bcryptjs.\n- Tokens are signed using JWT and include secure HTTP-only cookies.\n- All sensitive configuration, including the JWT secret and database credentials, should be stored securely in environment variables.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbagork%2Fnestjs-blog-app-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbagork%2Fnestjs-blog-app-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbagork%2Fnestjs-blog-app-api/lists"}