Skip to content

Julioxfiles/redsky-clean-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

<<<<<<< HEAD Absolutely! Let’s summarize what I remember about skynet-api and then create a full README.md draft for it.


What I remember about skynet-api

  • It's the backend REST API for your Skynet projects.
  • Provides endpoints for user authentication and registration (at least /auth/register).
  • Returns JSON responses, including proper validation errors.
  • Works with skynet-ui as the frontend and skynet-core for API client and helpers.
  • Uses HTTP status codes to indicate success (2xx) or errors (4xx for validation, 5xx for server errors).
  • Can be consumed via the ApiClient from skynet-core.

Draft README.md for skynet-api

# Skynet API

**Skynet API** is a RESTful backend service for the Skynet project.  
It provides endpoints for user authentication, registration, and other resources to be consumed by frontend applications like **skynet-ui**.

---

## Features

- **User Authentication & Registration**
  - `POST /auth/register` → Register a new user
  - `POST /auth/login` → Authenticate a user (planned)
  - Validation with proper HTTP error codes
- **JSON Responses**
  - Standardized response format
  - Returns `errors` for validation failures
  - Uses HTTP status codes for success and errors
- **Robust API Design**
  - RESTful conventions
  - Easily extendable for future resources
- **Integrates with Skynet UI and Core**
  - Can be consumed with `Core\Http\Client\ApiClient` from `skynet-core`

---

## Installation

Clone the repository:

```bash
git clone https://github.com/Julioxfiles/skynet-api.git
cd skynet-api

Install dependencies:

composer install

Set up environment variables:

cp .env.example .env

Configure database credentials and other settings in .env.


Usage

Register a User

Endpoint: POST /auth/register

Request Body (JSON):

{
  "name": "John Doe",
  "email": "john@example.com",
  "password": "secret",
  "password_confirmation": "secret"
}

Success Response:

{
  "status": 201,
  "message": "User registered successfully",
  "data": {
    "id": 1,
    "name": "John Doe",
    "email": "john@example.com"
  }
}

Validation Error Response (422):

{
  "status": 422,
  "message": "Validation failed",
  "errors": {
    "email": ["The email field is required."],
    "password": ["The password must be at least 6 characters."]
  }
}

Integration with Skynet UI

use Core\Http\Client\ApiClient;
use Core\Http\Exceptions\ApiValidationException;

$api = new ApiClient();

try {
    $response = $api->post('/auth/register', [
        'name' => 'John Doe',
        'email' => 'john@example.com',
        'password' => 'secret',
        'password_confirmation' => 'secret'
    ]);

    if ($response->isSuccess()) {
        echo "User registered successfully!";
    }

} catch (ApiValidationException $e) {
    print_r($e->errors());
}

Folder Structure (example)

skynet-api/
├─ app/
│  ├─ Http/
│  │  ├─ Controllers/
│  │  └─ Middleware/
├─ routes/
│  └─ api.php
├─ database/
│  ├─ migrations/
│  └─ seeders/
├─ composer.json
├─ .env.example
└─ README.md

License

MIT


---

If you want, I can **also make a shorter, GitHub-friendly “About” version** for `skynet-api` just like we did for `skynet-ui` and `skynet-core`.  

Do you want me to do that?

=======

SkynetApi

This is a Clean Architectural API starting proyect.

9f0501da6550a47bcd97870ced6ea08097d5cf6f

About

Clean Architecture Api

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages