Skip to content

RCOM363/notes-app-trpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Notes App (tRPC)

Simple full-stack note app that uses standalone tRPC server in the backend, providing end-to-end type safety across the project.

Built With

Typescript React React Router React Hook Form Tailwind React Query Node.JS tRPC Zod JWT Prisma PotgreSQL Docker

Getting started

Prerequisites

  • Docker

Installation

  1. Clone the respository

    git clone https://github.com/RCOM363/notes-app-trpc
    cd notes-app-trpc
  2. Environment variable setup Create a .env file in /server directory with following variables

    PORT=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>
  3. Run containers

    docker-compose up --build
  4. Sync DB

    docker exec -it <server_container> /bin/sh
    
    npx prisma migrate dev --name init
    
    npx prisma generate

API Documentation

All procedures are grouped by module (auth.*, note.*). publicProcedures are accessible without authentication, while protectedProcedure requires authentication. Validation is enforced through zod schemas.

Auth Procedures

  1. auth.createUser
  • Type: publicProcedure
  • Method: Mutation
  • Input:
    {
        "email": string,
        "password": string
    }
  • Output:
    {
        "id": number,
        "email": string
    }
  1. auth.loginUser
  • Type: publicProcedure
  • Method: Mutation
  • Input:
    {
        "email": string,
        "password": string
    }
  • Output:
    {
        "id": number,
        "email": string
    },
    "token": string
  1. auth.getUserById
  • Type: protectedProcedure
  • Method: Query
  • Input: None
  • Output:
    {
        "id": number,
        "email": string
    }

Note Procedures

  1. note.createNote
  • Type: protectedProcedure
  • Method: Mutation
  • Input:
    {
        "title": string,
        "content": string
    }
  • Output:
    {
      "noteId": number,
      "title": string,
      "content": string,
      "userId": number,
      "createdAt": timestamp
    }
  1. note.updateNote
  • Type: protectedProcedure
  • Method: Mutation
  • Input:
    {
        "title": string,
        "content": string,
        "nodeId": number
    }
  • Output:
    {
      "noteId": number,
      "title": string,
      "content": string,
      "userId": number,
      "createdAt": timestamp
    },
  1. note.deleteNote
  • Type: protectedProcedure
  • Method: Mutation
  • Input:
    {
        "nodeId": number
        "userId": number,
    }
  • Output:
    {
      "success": true
    }
  1. note.getNoteById
  • Type: protectedProcedure
  • Method: Query
  • Input:
    {
        "nodeId": number
        "userId": string,
    }
  • Output:
    {
      "noteId": number,
      "title": string,
      "content": string,
      "userId": number,
      "createdAt": timestamp
    },
  1. note.getUserNotes
  • Type: protectedProcedure
  • Method: Query
  • Input: None
  • Output:
    [
      {
          "noteId": number,
          "title": string,
          "content": string,
          "userId": number,
          "createdAt": timestamp
      },
      ...
    ]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published