https://github.com/egeuysall/notes-api
Create. Organize. Share.
https://github.com/egeuysall/notes-api
api dev full-stack golang nextjs notes project typescript
Last synced: 4 months ago
JSON representation
Create. Organize. Share.
- Host: GitHub
- URL: https://github.com/egeuysall/notes-api
- Owner: egeuysall
- License: mit
- Created: 2025-06-02T19:42:32.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-06-20T16:57:24.000Z (about 1 year ago)
- Last Synced: 2025-07-07T05:39:08.718Z (12 months ago)
- Topics: api, dev, full-stack, golang, nextjs, notes, project, typescript
- Language: Go
- Homepage: https://notes.egeuysal.com
- Size: 39.5 MB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# 🧠 Go Backend Practice – Day 1
**Goal:** Build a minimal REST API with chi to lock in routing, JSON decoding, and error handling — all from memory.
**To install, use:**
```bash
curl -fsSL https://raw.githubusercontent.com/egeuysall/notes-api/master/install.sh | sh
```
---
## ✅ Mini Project: Notes API (In-Memory)
| Method | Route | Description |
| ------ | ------------ | --------------------------------------- |
| GET | `/ping` | Returns `{ "message": "pong" }` |
| POST | `/note` | Accepts `{ "text": "..." }`, returns ID |
| GET | `/note/{id}` | Returns note by ID or 404 |
- Use: `chi`, `json.NewDecoder`, `json.NewEncoder`, `http.Error`, `chi.URLParam`
- Store data in: `map[string]string`
- Generate random ID (e.g. `6-char` string)
---
## ⏱️ Schedule (3 Hours)
### 🕒 Hour 1: Recall Drill – No Copying
- [x] Write `main.go` with `chi.NewRouter`
- [x] Create `GET /ping` route
- [x] Respond with JSON manually: `json.NewEncoder(w).Encode(...)`
- [x] Set correct headers/status codes
### 🕒 Hour 2: Build Note API
- [x] Add `POST /note`
- [x] Decode JSON body into struct
- [x] Generate random ID
- [x] Store in map
- [x] Respond with ID in JSON
- [x] Add `GET /note/{id}`
- [x] Get param with `chi.URLParam`
- [x] Lookup in map, return value or 404
- [x] Add `DELETE /note/{id}`
- [x] Get param with `chi.URLParam`
- [x] Check if note exists
- [x] Delete from map
- [x] Return 204 No Content
### 🕒 Hour 3: Review & Refactor
- [x] Build the Notes CLI
- [x] Flags package
- [x] error handling
- [x] Publish via Goreleaser
- [x] Configure Goreleaser
### 🕒 Hour 3: Review & Refactor
- [x] Clean up code structure (handlers, error messages)
- [x] Write a reflection note in Obsidian:
- What did I remember easily?
- What did I forget?
- Any confusing areas?
- [x] Save code to `~/go-snippets/notes-api`