https://github.com/ash1605/notesappbackend
This is the backend service for CookieNote, a note-taking application. The backend is built using modern web technologies, ensuring scalability, maintainability, and secure handling of user data.
https://github.com/ash1605/notesappbackend
expressjs knexjs nodejs postgresql typescript
Last synced: 3 months ago
JSON representation
This is the backend service for CookieNote, a note-taking application. The backend is built using modern web technologies, ensuring scalability, maintainability, and secure handling of user data.
- Host: GitHub
- URL: https://github.com/ash1605/notesappbackend
- Owner: AsH1605
- Created: 2025-01-25T14:55:12.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-06T17:49:09.000Z (over 1 year ago)
- Last Synced: 2025-03-06T18:36:03.155Z (over 1 year ago)
- Topics: expressjs, knexjs, nodejs, postgresql, typescript
- Language: TypeScript
- Homepage:
- Size: 107 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CookieNote Backend
This is the backend service for **[CookieNote](https://github.com/AsH1605/CookieNote)**, a note-taking application. The backend is built using modern web technologies, ensuring scalability, maintainability, and secure handling of user data.
## Tech Stack
| Component | Technology |
|------------------|-------------|
| Language | Typescript |
| Runtime | Node.js |
| Framework | Express.js |
| Database | PostgreSQL |
| Query Builder | Knex.js |
| Authentication | JWT |
| Password Hashing| bcrypt |
---
## Architecture Overview
### Project Structure
```
/auth - Contains JWT verification and user auth logic
/controller - Contains all logic for handling requests and forming responses
/db - Knex configuration and DB functions
/dto - TypeScript interfaces for Data Transfer Objects
/error - JS Error classes with error codes for different types of error responses
/models - Database models
/routes - Defines user and note-related routes
```
### Routers
| Router | Purpose |
|---|---|
| `userRouter` | Handles user actions like register and login |
| `noteRouter` | Handles note actions like create, update, delete, fetch notes |
---
## Authentication
- Users register and login through the `userRouter`.
- Passwords are **hashed** before being stored in PostgreSQL.
- Authentication is handled using **JWT** tokens.
- Protected routes (note routes) require a valid **JWT token** to access.
---
## Environment Variables
The backend relies on environment variables for configuration. Example `.env` file:
```
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_NAME=postgres
DB_PASSWORD=hi
JWT_SECRET=999
SALT=applepie
```
---
## Routes
### User Router (`/user`)
| Endpoint | Method | Description |
|---|---|---|
| `/register` | POST | Registers a new user |
| `/login` | POST | Logs in a user, returns JWT token |
### Note Router (`/note`)
| Endpoint | Method | Description |
|---|---|---|
| `/createNote` | POST | Creates a new note |
| `/getNotes` | GET | Fetch all notes for the logged-in user |
| `/getNote/:note_id` | GET | Fetch a specific note by ID |
| `/deleteNote/:note_id` | DELETE | Delete a note by ID |
| `/updateNote/:note_id` | PUT | Update a note by ID |
---
*Happy Coding 🍪*