Skip to content

anolivei/42Labs

Repository files navigation

lab

42 Labs Selection Process

Norminette

About   |   Methods   |   Technologies   |   Requirements   |   Starting   |   Testing   |   Author


About

This project has two applications: a Rest API and a CLI application, both written in C language.
The Rest API send, receive, change and remove movie data in format json, using the methods POST, GET, PUT and DELETE, while print the logs in a file api.log and also on terminal.
The CLI application is a simple applicaton which reads the api.log file and prints a resume of this logs.

It's running on DigitalOcean cloud: http://162.243.163.141:8080/

Project Planning

Notion with important links

Methods

  • POST:

    localhost:8080/ - add a new movie

  • GET:

    localhost:8080/ - lists all movies

    localhost:8080/:id - lists a specifc movie

  • PUT:

    localhost:8080/:id - modify an existing movie

  • DELETE:

    localhost:8080/:id - delete an existing movie

A movie is a JSON object with the following model:

{
  "id": "1",
  "title": "Back to the Future",
  "genre": "Sci-fi",
  "year": "1985"
}

Technologies

The following tools were used in this project:

Requirements

Before starting, you need to have Git and Docker installed.

Starting

Rest API:

# Clone this project
git clone https://github.com/42sp/42labs-selection-process-v2-anolivei

# Access
cd 42labs-selection-process-v2-anolivei

# Run the project
bash run.sh

# The server will initialize in the <http://localhost:8080>

# To stop the server press enter

# To remove the container
docker rm labs_api

# To remove the images
docker rmi labs_api ubuntu

CLI Application:

# Open a new terminal and execute
docker exec -it labs_api /bin/bash

# Access
cd cli

# Compile and run
make run

Testing

Rest API:

# Open a new terminal and execute
docker exec -it labs_api /bin/bash

# Access
cd tests

# Run
bash test.sh

 

Back to top