Giter Site home page Giter Site logo

3_sided_cube_api's Introduction

Laravel Blog API

This is a simple RESTful API for a blog post system using Laravel. It provides CRUD operations for blog posts. The API uses Laravel Sanctum for authentication.

Requirements

  • PHP 8.1+
  • Composer
  • MySQL/MariaDB or any other database supported by Laravel

Setup

  1. Clone the repository:

    git clone https://github.com/rodinmehr/3_sided_cube_api.git
    cd 3_sided_cube_api
    
  2. Install dependencies:

    composer install
    
  3. Copy the .env.example file to .env and configure the database settings:

    cp .env.example .env
    
  4. Generate an application key:

    php artisan key:generate
    
  5. Run migrations:

    php artisan migrate
    
  6. Seed the database with sample data:

    php artisan db:seed
    
  7. Generate OpenAPI (Swagger) documentation:

    php artisan l5-swagger:generate
    
  8. Run Queue for handling jobs:

    php artisan queue:work
    

Running the Application

To start the development server, run:

php artisan serve

The API will be available at http://localhost:8000/api.

API Endpoints

  • POST /api/login: Log in and receive an access token
  • POST /api/logout: Log out (requires authentication)
  • GET /api/posts: Show all posts (Public)
  • POST /api/posts: Create a new post (Requires Authentication)
  • GET /api/posts/{id}: Show a specific post (Public)
  • PUT /api/posts/{id}: Update a specific post (Requires Authentication)
  • DELETE /api/posts/{id}: Delete a specific post (Requires Authentication)

You can use Postman collection that is provided in 3_sided_cube_api.postman_collection.json file to test the endpoints.

API Documentation

API documentation is available here: http://localhost:8000/api/documentation where detailed information about the API endpoints is displayed.

Authentication

This API uses Laravel Sanctum for authentication. To authenticate:

  1. Make a POST request to /api/login with the email and password to receive an access token.
  2. Include the access token in the Authorization header of the requests:
Authorization: Bearer {received_access_token}

Default user:

email: [email protected]
password: cubetest

Running Tests

To run the tests, it's better to set up a new database to preserve the original one. Copy the .env.example file to .env.testing and configure the test database settings:

cp .env.example .env.testing

Run migrations:

php artisan migrate --env=testing

To run the feature tests, use the following command:

php artisan test --env=testing

License

This open-source project is licensed under the MIT License - see the LICENSE file for details.

3_sided_cube_api's People

Contributors

rodinmehr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.