Skip to content

Commit 4f5239a

Browse files
authored
Merge pull request #26 from ifsp-projects/feat/organization-campaigns
Feat/organization campaigns
2 parents f0cff86 + 2a32aef commit 4f5239a

78 files changed

Lines changed: 693 additions & 1014 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.coderabbit.yaml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
2+
language: 'en-US'
3+
early_access: true
4+
reviews:
5+
profile: 'chill'
6+
request_changes_workflow: false
7+
high_level_summary: true
8+
poem: false
9+
review_status: true
10+
collapse_walkthrough: false
11+
auto_review:
12+
enabled: true
13+
base_branches:
14+
- main
15+
- master
16+
17+
path_filters:
18+
- '!**/.xml'
19+
- '!**/__generated__/**'
20+
- '!**/generated/**'
21+
- '!**/*.json'
22+
- '!**/*.svg'
23+
- '!**/*.png'
24+
- '!**/*.jpg'
25+
- '!**/*.gif'
26+
- '!**/*.mp4'
27+
- '!**/*.webp'
28+
- '!**/*.lock'
29+
30+
path_instructions:
31+
- path: '*'
32+
instructions: |
33+
Do not aim for code style, this is already handled by the linter. Unless the code style suggestion is objectively better, do not suggest changes.
34+
Ensure Self-Documenting Code: Aim to make your code self-explanatory through clear naming and structure.
35+
The less time a developer has to spend understanding the code, the better but without being overly verbose on the namings.
36+
Follow the YAGNI Principle: 'You aren't gonna need it' is a principle that prevents developers from
37+
adding functionality until it is necessary. This can help keep your codebase lean and simple.
38+
Externalizing User-visible Strings: Ensuring all user-facing texts (such as error messages, API responses, and
39+
notification content) are sourced from external resource files or constants where reasonable. This makes it
40+
easier to update or translate them without having to modify business logic.
41+
Avoiding Concatenation of Translated Strings: Concatenation might change the meaning of a sentence
42+
when it is translated to another language due to differences in grammar or sentence structure. Instead,
43+
use templates or positional parameters.
44+
45+
- path: '**/src/**'
46+
instructions: |
47+
Review the following code written using Fastify and TypeScript for a backend API, ensuring:
48+
- The code adheres to best practices associated with Fastify (plugins, decorators, hooks, schema validation) and idiomatic Node.js.
49+
- Input validation and serialization use schemas (e.g. Zod or JSON Schema) rather than manual checks scattered through handlers.
50+
- The code is well-structured and easy to read. The reader must be able to understand the code without having to refer to other parts of the codebase.
51+
- The code is modular and reusable. Services, repositories, and utilities should be designed to be reusable across routes.
52+
- The dev-facing API (exported functions, plugin options, service methods) is flexible while offering a good developer experience.
53+
- Exported functions, types, and plugin contracts should be documented with JSDoc comments where non-obvious.
54+
- Existing JSDocs should be descriptive, direct but clear, and concise.
55+
- The internal API should be consistent, predictable, easy to use and resilient to changes.
56+
- The code must be performant on Node.js: avoid blocking the event loop (e.g. synchronous I/O, heavy CPU work in the request path), and avoid unnecessary await chaining or sequential awaits that could run concurrently.
57+
- The code should be memory efficient and avoid memory leaks, especially in long-running processes (unclosed connections, growing caches, dangling event listeners, unbounded queues).
58+
- Async errors are handled explicitly: async route handlers, Prisma calls, and external API calls should have proper try/catch or be wrapped so failures produce a controlled error response instead of an unhandled rejection.
59+
- Sensitive data (passwords, tokens, secrets, PII) is never logged or returned in API responses.
60+
- Database access (Prisma) is not duplicated ad hoc in multiple places; prefer a shared data-access layer.
61+
- Prefer composition over inheritance. Composition provides better flexibility over inheritance. Avoid deep inheritance trees.
62+
- Create reusable type definitions: If the same type structure is used in multiple places, create a type definition for it.
63+
- If you observe overly repeated code (more than 2~3 times), create a new function. If a function becomes too complex, decompose it into smaller ones.
64+
- Don't be too critical about the code architecture itself, like whether the indentation is right or wrong, or the order of things. That doesn't really make sense to flag.
65+
- Don't judge integration code with external tools/SDKs (e.g. Supabase, OpenTelemetry, Resend, OpenAI) against their internal implementation - assume their documented usage patterns are correct.
66+
67+
- path: '**/prisma/**'
68+
instructions: |
69+
Review Prisma schema and migration-related code ensuring:
70+
- Schema changes are backward compatible where possible, or clearly flagged as breaking (e.g. dropping/renaming columns with existing data).
71+
- New required fields either have a default value or the migration accounts for existing rows.
72+
- Indexes are added for columns used in frequent lookups or foreign keys.
73+
- Do not flag migration SQL files themselves for style; they are generated and should not be hand-edited except for documented hotfixes.
74+
chat:
75+
auto_reply: true

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"format:check": "prettier --check \"src/**/*.{ts,tsx}\"",
1111
"dev": "ts-node-dev --respawn -r tsconfig-paths/register --compiler-options {\\\"module\\\":\\\"CommonJS\\\",\\\"moduleResolution\\\":\\\"node\\\"} src/server.ts",
1212
"start": "node -r tsconfig-paths/register dist/server.js",
13-
"prisma:migrate": "prisma migrate dev --schema ./prisma/schema --create-only",
13+
"prisma:migrate": "prisma migrate dev --schema ./prisma/schema",
1414
"prisma:push": "prisma db push --schema ./prisma/schema"
1515
},
1616
"keywords": [],
@@ -39,6 +39,7 @@
3939
"@supabase/supabase-js": "^2.75.1",
4040
"@swc/core": "^1.15.2",
4141
"bcrypt": "^6.0.0",
42+
"capivara-solidaria-ts-sdk": "1.0.7",
4243
"dotenv": "^17.2.3",
4344
"express": "^5.1.0",
4445
"fastify": "^5.6.1",

pnpm-lock.yaml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

prisma.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ export default defineConfig({
1010
datasource: {
1111
url: process.env.DATABASE_URL
1212
}
13-
})
13+
})

prisma/schema/content.prisma

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ model Campaign {
5656
5757
goal_type CampaignGoalTypeEnum @default(other)
5858
goal_value Decimal @db.Decimal(15, 2)
59-
current_value Decimal @db.Decimal(15, 2)
59+
current_value Decimal @db.Decimal(15, 2) @default(0)
6060
6161
start_date DateTime
6262
end_date DateTime
6363
64-
location String
64+
location String?
6565
6666
updated_at DateTime @updatedAt
6767
created_at DateTime @default(now())
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- AlterTable
2+
ALTER TABLE "campaigns" ALTER COLUMN "current_value" SET DEFAULT 0,
3+
ALTER COLUMN "location" DROP NOT NULL;

src/adapters/inbound/http/controllers/admin/cancel-pending-invite/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { FastifyReply, FastifyRequest } from 'fastify'
22

3-
import { AdminRepository } from '@/adapters/outbound/prisma/repositories/admin-repositories'
3+
import { AdminRepository } from '@/adapters/outbound/prisma/repositories/admin-repository'
44
import { CancelPendingInviteUseCase } from '@/core/use-cases/admin/cancel-pending-invite'
55

66
import { Route } from '../../../decorators/route-decorator'

src/adapters/inbound/http/controllers/admin/create-and-send-invite/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { FastifyReply, FastifyRequest } from 'fastify'
22

3-
import { AdminRepository } from '@/adapters/outbound/prisma/repositories/admin-repositories'
3+
import { AdminRepository } from '@/adapters/outbound/prisma/repositories/admin-repository'
44
import { CreateInviteTokenUseCase } from '@/core/use-cases/admin/create-and-send-invite'
55
import { SendInviteUseCase } from '@/core/use-cases/email/send-invite'
66
import { ResendRepository } from '@/shared/infra/email/resend'

src/adapters/inbound/http/controllers/admin/get-invite-by-token/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { FastifyReply, FastifyRequest } from 'fastify'
22

3-
import { AdminRepository } from '@/adapters/outbound/prisma/repositories/admin-repositories'
3+
import { AdminRepository } from '@/adapters/outbound/prisma/repositories/admin-repository'
44
import { GetInviteByTokenUseCase } from '@/core/use-cases/admin/get-invite-by-token'
55

66
import { Route } from '../../../decorators/route-decorator'

src/adapters/inbound/http/controllers/admin/list-all-invites/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { FastifyReply, FastifyRequest } from 'fastify'
22

33
import { Route } from '@/adapters/inbound/http/decorators/route-decorator'
4-
import { AdminRepository } from '@/adapters/outbound/prisma/repositories/admin-repositories'
4+
import { AdminRepository } from '@/adapters/outbound/prisma/repositories/admin-repository'
55
import { ListAllInvitesUseCase } from '@/core/use-cases/admin/list-all-invites'
66

77
import { Trace } from '../../../decorators/trace-decorator'

0 commit comments

Comments
 (0)