Skip to content

xHenrySx/API-REST

Repository files navigation

License Repo Size TOP_LANGUAGE FORKS Stars

Books API REST

Table of Contents

Description

The book API help to obtain information about a specific book or a lot of books as you want to query.

Screenshots

Built With

Getting Started

To start first run the command npm install

then to run like a developer just run the command npm run dev or to build it npm run build && npm run start

Prerequisites

javascript node.js npm

Usage

ATTENTION:

  • Some test only works when is run one time, beacuse it create users and users can be unique.
  • The server is listening to port 3000 locally

To run the test:

npm run test

or

mocha

DOCUMENTATION

BOOKS

The book model is constructed like this:

{    
    "title": "String",
    "author":  "String",
    "year": "Number",
    "pages": "Number",
    "description": "String",
    "image": "String"
}

Parameters

title

The title of the book. Type: String. Required.

author

The author of the book. Type: String. Required.

year

The publishing year of the book. Type: Number. Required.

pages

The amount of pages of the book. Type: Number. Required.

description

The description of the book Type: String Required

image

The url of the book image. Type: String. Required

USERS

The user construction is created like this:

{
    "username": "String",
    "email": "String",
    "password": "String",
    "roles": [] 
}

Params

username

The user, username. Type: String. Required and Unique.

email

The user email. Type: String. Required and Unique.

password

The user password. Type: String. Required.

roles

The user roles. Type: Array. Default role is user.

AUTH

The authentication is used to sign in or sign up. The sign up can be performed by anyone as well as the sing in. But only the admins or moderators previous registerd can add users by the user class, update, or delete them.

sign up

The sign up require:

{
    "username": "somename",
    "email": "email@something.com",
    "password": "password"
}

When you sign up as a user it gives you, your user and a token to perform basic operations to the API, almost every get request.

sign in

The sign in require:

{
    "email": "email@something.com",
    "password": "password"
}

When you sign in the API return the user and a token to use. The tokes expires depends on the role:

  • admin or moderator: Unlimited for every sign in
  • user: 24 hours for every sign in

License

MIT License

Acknowledgements

API for a work test. :)

Contacts

About

API REST de libros.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published