Skip to content

a-cs/42StoreAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

42 São Paulo logo

42 Store API

ABOUT THE PROJECT

This project was done during the 42Labs (internship) selection process of 42 São Paulo. The main goal was to create a REST API using C, collect logs of the application and also a CLI to visualize the logs.

API

The main idea of this API is to be used to control inventory of the 42Store.

Main functionalities

  • List endpoints: The user can list all available endpoints.

    GET /

  • List items: The user can list all created items.

    GET /items

  • Create item: The user can create an item.

    POST /items

     {
     	"name": "item_name"
     }

    Parameters:

    name: A string containing the item name.

  • List transactions: The user can list all created transactions.

    GET /transactions

  • Create transactions: The use can create a transaction.

    POST /transactions

     {
     	"item_id": 42,
     	"item_quantity": 42, 
     	"type": "in"
     }

    Parameters:

    item_id: An int of an already created item id.

    item_quantity: An int for the item quantity.

    type: A string containing in or out depending on the type of the transaction.


CLI

CLI Example

The main goal of the CLI is to be a user-friendly tool to visualise the logs generated by the API.


Preparing the environment

First of all, you need to install Docker.

To set up the database, run on your terminal:

docker run --name 42labsdb -p 3306:3306 -d acarneirosousa/42labsdb:v0

To build the API and CLI applications, use the following lines on your terminal:

git clone https://github.com/a-cs/42StoreAPI.git 42store
cd 42store
sudo apt-get update
sudo apt-get install libmysqlclient-dev
make
export PATH=$PATH:$(pwd)

Running the applications

To run the API, type on your terminal:

42store_api
*make sure the database container is running before starting the API.

To run the CLI, type on your terminal:

42store_cli
*make sure the database container is running before starting the CLI.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published