Not uygulaması için RESTful API servisi. Kullanıcı kimlik doğrulama, not yönetimi ve favori notlar gibi özellikler sunar.
- Runtime: Node.js 22
- Framework: Express.js 5
- Veritabanı: MongoDB (Mongoose ODM)
- Kimlik Doğrulama: JWT (Access Token + Refresh Token)
- Validasyon: Zod
- Email: Nodemailer
- Güvenlik: Helmet, CORS, Rate Limiting, bcrypt
- Loglama: Winston
- Dokumantasyon: Swagger/OpenAPI
- Konteyner: Docker, Docker Compose
- Node.js 22+
- MongoDB 7+ veya Docker
Proje kök dizininde .env dosyası oluşturun:
NODE_ENV=development
PORT=5000
CORS_ORIGIN=http://localhost:3000
COOKIE_SAME_SITE=strict
MONGO_URI=mongodb://admin:password123@localhost:27017/noteapp?authSource=admin
MONGO_ROOT_USERNAME=admin
MONGO_ROOT_PASSWORD=password123
MONGO_DATABASE=noteapp
JWT_SECRET_KEY=your-jwt-secret-key
JWT_EXPIRES_IN=15m
EMAIL_USER=[email protected]
EMAIL_PASSWORD=your-app-password
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=465
EMAIL_TOKEN_SECRET_KEY=your-email-token-secret
EMAIL_TOKEN_EXPIRES_IN=1h
REFRESH_TOKEN_SECRET_KEY=your-refresh-token-secret
REFRESH_TOKEN_EXPIRES_IN=7d
REFRESH_TOKEN_COOKIE_MAX_AGE=604800000# Bağımlılıkları yükle
npm install
# Geliştirme modunda çalıştır
npm run dev
# Production modunda calistir
npm start
# Testleri calistir
npm test
# Watch modunda testler
npm run test:watch
# Test coverage raporu
npm run test:coverage# Tüm servisleri başlat (API + MongoDB)
docker compose up -d
# Logları görüntüle
docker compose logs -f
# Servisleri durdur
docker compose down
# Veritabanı dahil tüm verileri sil
docker compose down -vTum endpoint'ler /api/v1 prefix'i ile baslar. Korumali endpoint'ler Authorization: Bearer <token> header'i gerektirir.
API dokumantasyonuna erisim: http://localhost:5000/api-docs
| Method | Endpoint | Aciklama | Auth |
|---|---|---|---|
| POST | /api/v1/auth/register |
Yeni kullanici kaydi | Hayir |
| POST | /api/v1/auth/login |
Kullanici girisi | Hayir |
| POST | /api/v1/auth/refresh |
Access token yenileme | Hayir |
| POST | /api/v1/auth/logout |
Cikis yap | Hayir |
| POST | /api/v1/auth/logout-all |
Tum cihazlardan cikis | Evet |
| GET | /api/v1/auth/verify |
Email dogrulama | Hayir |
| POST | /api/v1/auth/reset-password-email |
Sifre sifirlama emaili gonder | Hayir |
| POST | /api/v1/auth/reset-password-confirmation |
Sifre sifirlama onayi | Hayir |
POST /api/v1/auth/register
Content-Type: application/json
{
"name": "User",
"email": "[email protected]",
"password": "12345678"
}
POST /api/v1/auth/login
Content-Type: application/json
{
"email": "[email protected]",
"password": "12345678"
}
| Method | Endpoint | Aciklama | Auth |
|---|---|---|---|
| GET | /api/v1/users/:id |
Kullanici bilgilerini getir | Evet |
| PUT | /api/v1/users/:id |
Kullanici bilgilerini guncelle | Evet |
PUT /api/v1/users/:id
Authorization: Bearer <token>
Content-Type: application/json
{
"name": "New Name",
"email": "[email protected]"
}
| Method | Endpoint | Aciklama | Auth |
|---|---|---|---|
| GET | /api/v1/notes |
Tum notlari listele | Evet |
| POST | /api/v1/notes |
Yeni not olustur | Evet |
| GET | /api/v1/notes/:id |
Tek not getir | Evet |
| PUT | /api/v1/notes/:id |
Not guncelle | Evet |
| DELETE | /api/v1/notes/:id |
Not sil | Evet |
| GET | /api/v1/notes/search?query= |
Notlarda ara | Evet |
| GET | /api/v1/notes/query?tag= |
Tag'e gore filtrele | Evet |
| GET | /api/v1/notes/favorites |
Favori notlari listele | Evet |
| POST | /api/v1/notes/favorites/:id |
Favorilere ekle | Evet |
| DELETE | /api/v1/notes/favorites/:id |
Favorilerden cikar | Evet |
POST /api/v1/notes
Authorization: Bearer <token>
Content-Type: application/json
{
"title": "Note Title",
"content": "Note Content",
"tags": ["personel", "work"],
"color": "#FF5733"
}
PUT /api/v1/notes/:id
Authorization: Bearer <token>
Content-Type: application/json
{
"title": "New Title",
"content": "New Note Content...",
"tags": ["New Tag"],
"color": "#3498DB"
}
note-app-backend/
├── config/
│ ├── db.js # MongoDB baglantisi
│ ├── env.js # Ortam degiskenleri
│ └── swagger.js # Swagger konfigurasyonu
├── controllers/
│ ├── auth.controller.js
│ ├── note.controller.js
│ └── user.controller.js
├── middlewares/
│ ├── auth.middleware.js
│ ├── error.middleware.js
│ ├── logger.middleware.js
│ ├── noteOwner.middleware.js
│ ├── notFound.middleware.js
│ ├── user.middleware.js
│ └── validation.middleware.js
├── models/
│ ├── note.model.js
│ ├── refreshToken.model.js
│ └── user.model.js
├── routes/
│ ├── auth.routes.js
│ ├── note.routes.js
│ └── user.routes.js
├── templates/
│ ├── password-reset.template.html
│ └── verification.template.html
├── utils/
│ ├── email.service.js
│ ├── logger.js
│ └── token.js
├── validation/
│ └── validation.js
├── app.js
├── server.js
├── Dockerfile
└── docker-compose.yml
MIT