Giter Club home page Giter Club logo

minhaprovaminhavida_api's Introduction

Minha prova, minha vida (MPMV) API

MPMV API uses Node.js, Typescript, Express and Postgres to help college students to find study material like exams from previous years.

Build Status

Using

Response

The response from the API is formatted as:

{
    ok: boolean
    data: any | Error
} 

Error {
    error: string
    msg: string
}

In case of success the API will return a 200 HTTP Code along with the "ok" parameter defined as true. In case of error the HTTP code will be the one that best fit the situation, "ok" will be false and "data" will return an object with the error name and the message related to the error.

Endpoints

All the comunication is encoded using JSON (application/json), except for the endpoint POST /files that uses multipart/form-data in order to handle the file upload.

Some endpoints (GET) also allow filtering using a query string, in these cases the fielterable fields will be described under the the "Body (POST) / Query String (GET)" column.

URL Content-Type Body (POST) / Query String (GET) Success Response
GET /files - ?universityId=&courseId=&type=<test|exam> File[]
GET /files/:id - - File
POST /files multipart/form-data Keys: i) json: containing a NewFile JSON object; ii) files: the files to be uploaded. File
DELETE /files/:id - - -
GET /universities - - BasicUniversity[]
GET /universities/:id - - University
POST /universities application/json NewUniversity University
DELETE /universities/:id - - -
GET /courses - - Course[]
GET /courses/:id - - Course
POST /courses application/json NewCourse Course
DELETE /courses/:id - - -
GET /users/me - - User
POST /users/login/facebook application/json { access_token: string } JWTAndUser
POST /users/login/google application/json { access_token: string } JWTAndUser

Types

NewCourse

NewCourse {
    id: number
    name: string
    code: string
    universityId: number
}

Course

Course {
    id: number
    name: string
    code: string
}

NewUniversity

NewUniversity {
    name: string
    acronym: string
}

BasicUniversity

BasicUniversity {
    id: number
    name: string
    acronym: string
}

University

University {
    id: number
    name: string
    acronym: string
    courses: Course[]
}

User

User {
    id: number
    name: string
    email: string
    avatar: string
}

PublicUser

PublicUser {
    id: number
    name: string
    email: string
    avatar: string
}

JWTAndUser

JWTAndUser {
    jwt: string
    user: User
}

File

File {
    id: number
    name: string
    file: string
    createdAt: Date 
    type: "exam" | "test"
    course: Course
    university: BasicUniversity
    user: PublicUser
}

NewFile

NewFile {
    name: string
    file: Blob File
    type: "exam" | "test"
    universityId: string
    courseId: string
}

Development

Requirements:

  • Node.js
  • Postgres
  • AWS Account

Get the code:

git clone https://github.com/dygufa/minhaprovaminhavida_api.git
cd minhaprovaminhavida_api
yarn

Define the environment variables

In order to run this webserver you need to define the .env file using the .env.example:

cp .env.example .env
nano .env

Commands:

  • yarn dev will start a express webserver (mpmv.js) using nodemon and a tsc --watch instance to auto compile on file change. The port can be defined on the .env file.

Todos (by priority)

  1. Convert code to ES6 (babel + gulp);
  2. Implement sessions with JWT;
  3. Implement file upload;
  4. Add user roles;
  5. Add location related data to university;
  6. PUT methods;
  7. Allow administrator to review files before making it public;
  8. Implement virus verification on the files before making it public using clamscan;

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.