{"id":20254067,"url":"https://github.com/frectonz/nest-todos-api","last_synced_at":"2026-05-12T09:31:28.798Z","repository":{"id":65712420,"uuid":"596773945","full_name":"frectonz/nest-todos-api","owner":"frectonz","description":"Todos API","archived":false,"fork":false,"pushed_at":"2023-02-08T06:58:40.000Z","size":214,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-03T17:13:48.466Z","etag":null,"topics":["nestjs"],"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/frectonz.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":"2023-02-02T22:31:29.000Z","updated_at":"2023-03-08T21:59:23.000Z","dependencies_parsed_at":"2023-02-19T04:31:17.399Z","dependency_job_id":null,"html_url":"https://github.com/frectonz/nest-todos-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/frectonz/nest-todos-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frectonz%2Fnest-todos-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frectonz%2Fnest-todos-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frectonz%2Fnest-todos-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frectonz%2Fnest-todos-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/frectonz","download_url":"https://codeload.github.com/frectonz/nest-todos-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frectonz%2Fnest-todos-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32932313,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-12T09:19:52.626Z","status":"ssl_error","status_checked_at":"2026-05-12T09:17:33.438Z","response_time":102,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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"],"created_at":"2024-11-14T10:29:40.361Z","updated_at":"2026-05-12T09:31:28.778Z","avatar_url":"https://github.com/frectonz.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nest Todos API\n\nA sample API built with NestJS and Prisma.\n\n## Testing the API\n\n### With [HTTPie](https://httpie.io/)\n\n- Register\n\n```bash\nhttp POST http://localhost:3000/auth/register username=frectonz password=password\n```\n\n- Login\n\n```bash\nhttp POST http://localhost:3000/auth/login username=frectonz password=password\n```\n\n- Create a todo\n\n```bash\nhttp -A bearer -a \u003ctoken\u003e POST http://localhost:3000/todos title=\"My first todo\"\n```\n\n- Get all todos\n\n```bash\nhttp -A bearer -a \u003ctoken\u003e GET http://localhost:3000/todos\n```\n\n- Toggle completed status\n\n```bash\nhttp -A bearer -a \u003ctoken\u003e PATCH http://localhost:3000/todos/\u003cid\u003e/toggle\n```\n\n### With [Hurl](https://hurl.dev/)\n\n- Register\n\n```bash\nhurl hurl/register.hurl | jq\n```\n\n- Login\n\n```bash\nhurl hurl/login.hurl | jq\n```\n\n- Todos CRUD\n\n```bash\nhurl hurl/todos.hurl | jq\n```\n\n## What is this?\n\nThis project was meant to help me learn NestJS. It is a simple API for managing todos. It supports the following actions\n\n- Register a new user\n- Login a user\n- Create a todo\n- Get all todos\n\nThe Login and Register routes return a JWT token that can be used to access the todos routes.\n\n```json\n{\n  \"access_token\": \"\u003ctoken\u003e\"\n}\n```\n\nThe Todo Schema is as follows\n\n```json\n{\n  \"id\": 1,\n  \"title\": \"My first todo\",\n  \"completed\": false,\n  \"userId\": 1\n}\n```\n\n## Notes on [NestJS](https://nestjs.com/)\n\nFirst of all checkout this [talk](https://youtu.be/f0qzBkAQ3mk).\n\nThe app's entry point is `main.ts`. It is responsible for creating the app and starting the server.\n\n```typescript\nimport { NestFactory } from '@nestjs/core';\nimport { AppModule } from './app.module';\n\nasync function bootstrap() {\n  const app = await NestFactory.create(AppModule);\n  app.enableCors();\n  await app.listen(3000);\n}\nbootstrap();\n```\n\nNestJS is server independent. It can be used with Express, Fastify, etc. The default is Express. It does this by relying on the `@nestjs/platform-express` package. If you want to use Fastify, you can install `@nestjs/platform-fastify` and configure it in `main.ts`.\n\n```typescript\nimport { NestFactory } from '@nestjs/core';\nimport { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';\nimport { AppModule } from './app.module';\n\nasync function bootstrap() {\n  const app = await NestFactory.create\u003cNestFastifyApplication\u003e(AppModule, new FastifyAdapter());\n  app.enableCors();\n  await app.listen(3000);\n}\n```\n\nCheckout the `fastify` branch for an example of using Fastify.\n\n---\n\nThe next piece of code you should look at is in the file `app.module.ts`.\n\n```typescript\n@Module({\n  imports: [AuthModule, UsersModule, TodosModule, PrismaModule],\n})\nexport class AppModule implements OnModuleInit {\n  constructor(private prisma: PrismaService) {}\n\n  async onModuleInit() {\n    await this.prisma.todo.deleteMany();\n    await this.prisma.user.deleteMany();\n  }\n}\n```\n\nHere we see our first NestJS decorator, the `Module` decorator. Before getting into what this decorator does check the documentation on [decorators](https://www.typescriptlang.org/docs/handbook/decorators.html). The important thing to note is that decorators are a used to compose functionality and that they can be applied to classes, methods, properties, and parameters.\n\nNow that we understand the use of decorators. We can get back to the `Module` decorator, It is used to create a NestJS Module. A module in NestJs is the main tool we have to organize our code and structure it be reused at an other place. A module can import functionality from other modules and it can also provide functionality to other modules.\n\nEvery NestJS project has at least one module the `AppModule` because the `NestFactory.create` method we saw above needs a module to serve as an entrypoint to our application.\n\nYou can also see that that we are implementing the interface `OnModuleInit`. This interface allows us to define the `onModuleInit` function, which is run once when a module is instantiated. We use this method to remove all of the data that has been stored in our DB. This is very helpful when we are testing our api but could potentially be dangerous if used in production.\n\nAs you can see from the above code sample interacting with NestJS is mostly implementing interfaces and adding decorators to our code.\n\nOur Codebase has the following modules\n\n- `AuthModule`\n- `UsersModule`\n- `TodosModule`\n- `PrismaModule`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrectonz%2Fnest-todos-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrectonz%2Fnest-todos-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrectonz%2Fnest-todos-api/lists"}