Simple full-stack note app that uses standalone tRPC server in the backend, providing end-to-end type safety across the project.
- Docker
-
Clone the respository
git clone https://github.com/RCOM363/notes-app-trpc cd notes-app-trpc -
Environment variable setup Create a
.envfile in/serverdirectory with following variablesPORT=5000 CORS_ORIGIN="http://localhost:5173" POSTGRES_USER=<username> POSTGRES_PASSWORD=<password> POSTGRES_DB=<db_name> DATABASE_URL="postgresql://<username>:<password>@<host/service_name>:5432/<db_name>" TOKEN_SECRET=<your_token_secret>
-
Run containers
docker-compose up --build
-
Sync DB
docker exec -it <server_container> /bin/sh npx prisma migrate dev --name init npx prisma generate
All procedures are grouped by module (auth.*, note.*). publicProcedures are accessible without authentication, while protectedProcedure requires authentication. Validation is enforced through zod schemas.
auth.createUser
- Type:
publicProcedure - Method:
Mutation - Input:
{ "email": string, "password": string } - Output:
{ "id": number, "email": string }
auth.loginUser
- Type:
publicProcedure - Method:
Mutation - Input:
{ "email": string, "password": string } - Output:
{ "id": number, "email": string }, "token": string
auth.getUserById
- Type:
protectedProcedure - Method:
Query - Input: None
- Output:
{ "id": number, "email": string }
note.createNote
- Type:
protectedProcedure - Method:
Mutation - Input:
{ "title": string, "content": string } - Output:
{ "noteId": number, "title": string, "content": string, "userId": number, "createdAt": timestamp }
note.updateNote
- Type:
protectedProcedure - Method:
Mutation - Input:
{ "title": string, "content": string, "nodeId": number } - Output:
{ "noteId": number, "title": string, "content": string, "userId": number, "createdAt": timestamp },
note.deleteNote
- Type:
protectedProcedure - Method:
Mutation - Input:
{ "nodeId": number "userId": number, } - Output:
{ "success": true }
note.getNoteById
- Type:
protectedProcedure - Method:
Query - Input:
{ "nodeId": number "userId": string, } - Output:
{ "noteId": number, "title": string, "content": string, "userId": number, "createdAt": timestamp },
note.getUserNotes
- Type:
protectedProcedure - Method:
Query - Input: None
- Output:
[ { "noteId": number, "title": string, "content": string, "userId": number, "createdAt": timestamp }, ... ]