MPMV API uses Node.js, Typescript, Express and Postgres to help college students to find study material like exams from previous years.
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.
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 |
NewCourse {
id: number
name: string
code: string
universityId: number
}
Course {
id: number
name: string
code: string
}
NewUniversity {
name: string
acronym: string
}
BasicUniversity {
id: number
name: string
acronym: string
}
University {
id: number
name: string
acronym: string
courses: Course[]
}
User {
id: number
name: string
email: string
avatar: string
}
PublicUser {
id: number
name: string
email: string
avatar: string
}
JWTAndUser {
jwt: string
user: User
}
File {
id: number
name: string
file: string
createdAt: Date
type: "exam" | "test"
course: Course
university: BasicUniversity
user: PublicUser
}
NewFile {
name: string
file: Blob File
type: "exam" | "test"
universityId: string
courseId: string
}
- Node.js
- Postgres
- AWS Account
git clone https://github.com/dygufa/minhaprovaminhavida_api.git
cd minhaprovaminhavida_api
yarn
In order to run this webserver you need to define the .env
file using the .env.example
:
cp .env.example .env
nano .env
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.
Convert code to ES6 (babel + gulp);Implement sessions with JWT;Implement file upload;- Add user roles;
- Add location related data to university;
- PUT methods;
- Allow administrator to review files before making it public;
- Implement virus verification on the files before making it public using clamscan;