Skip to content

CoreDumped-ETSISI/core-dumped-website-api

Repository files navigation

Core Dumped Website API

API to interface with a Mongo database that stores all the events, projects and people needed for the Core Dumped Website.

Table of Contents

About

This API connects to a Mongo database and provides access to its data to the Core Dumped Website. It needs to handle GET requests on the Projects, Event and People, accesible to anyone. It needs to allow POST and PUT requests for Projects and Event, only for logged administrators using JSON Web Tokens. It needs to allow PUT requests for People, only for logged administrators using JSON Web Tokens.

Installation

Install nodejs 20.5.1 here

Clone this repository and run

npm install

Routes

All routes with PUT, POST or DELETE are protected with authentication, use the instructions in the /admin endpoint to authenticate. The routes of this API are:

Cartas

  • /cartas GET returns an array of all projects and events sorted by date
  • /cartas POST creates a new project or event
  • /cartas/[:id] GET returns a single project or event with the corresponding ID
  • /cartas/[:id] DELETE deletes a single project or event with the corresponding ID
  • /cartas/[:id] PUT updates a single project or event with the corresponding ID

Eventos

  • /eventos/ GET returns an array of all events sorted by date
  • /eventos/categorias GET returns an array of all event categories

Proyectos

  • /proyectos/ GET returns an array of all projects sorted by date
  • /proyectos/categorias GET returns an array of all project categories

Personas

  • /personas GET returns an array of all stored people
  • /personas/:id GET returns a single person with the corresponding ID
  • /personas/:id PUT updates a single person with the corresponding ID

Auth

  • /login POST returns a valid for 2h JWT if the password is correct. Apply the password to the header Authorization: Bearer <JWT>

Items

  • /items GET returns an array of all items
  • /items/:id resturns the item with the corresponding ID
  • /items POST creates a new item
  • /items/:id PUT updates a single item with the corresponding ID
  • /items/:id DELETE deletes the item with the matching ID

Loaners

  • /loaners POST creates a new loaner
  • /loaners/byid/:id GET gets loaner with matching ID (Auth protected)
  • /loaners/bymat/:mat GET gets loaner with matching matricula (Auth protected)
  • /loaners/:id DELETE deletes the loaner with matching ID
  • /loaners/:id PUT updates the loaner with matching ID

Loans

  • /loans/:id GET gets loan with matching ID
  • /loans/item/:id GET loans associated with item of matching ID
  • /loans/loaner/:id GET loans associates with loaner of matching ID
  • /loans POST creates a new loan
  • /loans/:id DELETE deletes the loan with matching ID
  • /loans/:id PUT updates the loan with matching ID

Usage

To run on dev mode locally

npx nodemon

The API will be hosted in port 3000 if no other port is specified.

How to Dockerize

First, create a new .env inside /app, following the example in .env.example.

Then run, replacing imageName and port

docker build -t <imageName> .
docker run -p <port>:3000 <imageName>

Contributing

We welcome contributions from the community! If you want to contribute to Core Dumped Website API, please follow the guidelines in the CONTRIBUTING.md file.

License

Core Dumped Website API is released under the Apache 2.0.

Authors and Contributors

Check out the AUTHORS.md file to see a list of all the wonderful people who have contributed to this project.

Code of Conduct

We expect all contributors to follow our Code of Conduct to maintain a respectful and inclusive environment for everyone.

Changelog

For a detailed list of changes and versions, check the CHANGELOG.md file.

About

API for the Core Dumped website

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •