Git Product home page Git Product logo

core-dumped-website-api's Introduction

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.

core-dumped-website-api's People

Contributors

rowiz49 avatar pandita-ia avatar dependabot[bot] avatar

core-dumped-website-api's Issues

Create endpoints for loans

Create the following endpoints:

Method & URI Response
GET /loans/:id Return the loan with the matching id
GET /loans/item/:id Return a list of all loans made to the item with the corresponding id
GET /loans/loaner/:id Return a list of all loans made to the loaner with the corresponding id
POST/PUT/DELETE /loans/:id Create/Update/Delete the loan with the matching id

Add endpoints and controllers for people

There needs to be a GET handler to get all people in the route personas
There need to be a way to update when new board members are elected in personas/:personId with a PATCH request.

Add autentication for PATCH/DELETE/POST methods

Authentication should follow this process:

  1. Login attempt as a POST request, only one valid password stored hashed and salted in the database
  2. Return a JWT valid for 2h, with a secret located in the .env
  3. All methods that require authentication should pass through the check-auth middleware, checking if the JWT is valid

Create routes and controllers for Items

Create the following endpoints:

Method & URI Response
GET /items Return a list of all items, ideally with a boolean that tells if an item is or isn't available, maybe use virtuals
GET /items/:id Return the item with the matching id, populate with latest transactions
POST/PUT/DELETE /items/:id Create/Update/Delete the item with the matching id

Create endpoints for Loaners

Create the following endpoints:

Method & URI Response
GET /loaner/:mat Return the corresponding loaner by matricula number, populate with the latest loans
GET /loaner/:id Return the corresponding loaner by id, populate with the latest loans
POST/PUT/DELETE /loaner/:id Create/Update/Delete the item with the matching id

Add endpoints and controllers for events

The list of endpoints should be:

For the GET requests:

  • events to get an array of events sorted by date
  • events/:eventId to get an event by its id

The POST request should be handled in events

The DELETE/PUT request should be handled with events/:eventId to delete/update that specific event.

Refactor events and projects

Events and projects should be a single object Card, with a new enum[evento, proyecto] variable Type.

The new endpoints should be:

  • cartas for a mix of both in date order
  • eventos for only event cards
  • proyectos for only project cards
  • cartas/:id for only one cards information

Add a project+event endpoint

Add a GET enpoint for projects mixed with events at /novedades
The endpoint should return the latest 20 events and projects, sorted by date

Add endpoints and controllers for projects

The list of endpoints should be:

For the GET requests:

  • proyecto to get an array of projects sorted by date
  • proyecto/proyecto-:projectId to get a project by its id
  • proyecto/categorias to get all distinct categories of projects

The POST request should be handled in projects

The DELETE/PATCH request should be handled with proyecto/proyecto-:projectId to delete/update that specific project.

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.