Skip to content

YoussifElhelaly/rayaBackend

Repository files navigation

Raya Backend API

A Node.js backend API built with Express and MySQL, featuring user authentication and management.

Features

  • User authentication (register/login)
  • JWT-based authorization
  • Role-based access control
  • User CRUD operations
  • Error handling
  • MySQL databadse with Sequelize ORM

Prerequisites

  • Node.js (v14 or higher)
  • MySQL server
  • npm or yarn

Setup

  1. Clone the repository
  2. Install dependencies:
    npm install
  3. Create a MySQL database named raya_db
  4. Copy .env.example to .env and update the values:
    cp .env.example .env
  5. Start the server:
    npm run dev

API Endpoints

Authentication

  • POST /api/auth/register - Register a new user
  • POST /api/auth/login - Login user

Users

  • GET /api/users - Get all users (Admin only)
  • GET /api/users/:id - Get user by ID
  • PUT /api/users/:id - Update user
  • DELETE /api/users/:id - Delete user (Admin only)

Authentication

All protected routes require a Bearer token in the Authorization header:

Authorization: Bearer <token>

Error Handling

The API returns appropriate HTTP status codes and error messages in JSON format:

{
  "message": "Error message",
  "errors": [{ "field": "fieldName", "message": "validation message" }]
}

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy