Backend for the application to automatize the registration of lists.
- You need to have
Node.js
andYarn
installed. - You need an
.env
file in order to run this project. Here is an example of its content:
# Firebase config
GOOGLE_APPLICATION_CREDENTIALS =
FIREBASE_AUTH_PROVIDER_X509_CERT_URL =
FIREBASE_AUTH_URI =
FIREBASE_CLIENT_EMAIL =
FIREBASE_CLIENT_ID =
FIREBASE_TYPE =
FIREBASE_PRIVATE_KEY_ID =
FIREBASE_PRIVATE_KEY =
FIREBASE_PROJECT_ID = rhoades
FIREBASE_TOKEN_URI =
FIREBASE_URL =
FIREBASE_X509_CERT_URL =
# Security
ALGORITHM =
KEY =
KEY_PASSWORD =
KEY_JSON =
IV =
# Mail
EMAIL_PASSWORD =
EMAIL_SENDER =
In order to install and use this project (in development mode), please run the following commands in your terminal:
yarn
yarn service
You will a message as follows:
yarn run v1.22.4
$ nodemon
[nodemon] 2.0.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): .env src/**/*
[nodemon] watching extensions: ts
[nodemon] starting `ts-node -r dotenv/config ./src/index`
Server running at port XXXX.
Firebase connection established.
- All the endpoints begins in
/api
, excepthome
.
There are sixteen endpoints implemented:
-
Home:
/
, it has a get method. It is only decorative. -
Verify user:
/user/verify/:code?condition=&documentType=
, it has a get method which will verify whether a user can be a spokesperson or not.-
The
code
must be the document number the user has selected. -
The
condition
must bestudent
orteacher
. -
The
documentType
must be 0 (DNI, CE or others) or 1 (UNI code). -
If everything is correct you will get a success response, if not, an error response. Also, consider this for all the incoming endpoints.
-
The result key of the
JSON
response will contain:{ "id": "cFNUGLxWH8MpGLzv6FBk", "lastName": "LUZQUIÑOS", "mail": "[email protected]", "names": "STEVE ANTHONY", "registered": false, "secondLastName": "AGAMA" }
-
-
Notify user:
/user/notify
, is has a patch method which will create a password for the user and send it to the user's email.-
The body of the request must be as follows:
{ "args": { "id": "QnYUvCKk74N3vfJZSHxW (id user)" } }
-
The result key of the
JSON
response will contain:Se ha generado su contraseña correctamente y ha sido enviada a su correo
-
-
Enroll user in a list:
/user/enroll/:code?condition=&documentType=
, it has a post method which will enroll a user into a list, if he is able to postulate.-
The body of the request must be as follows:
{ "id": "xiaphgU3T9Atd1OlrCfm (id list)" }
-
The result key of the
JSON
response will contain:{ "id": "LUZQUIÑOS", "specialty": "N6", "names": "STEVE ANTHONY", "secondLastName": "AGAMA", "mail": "[email protected]", "optionalMail": "", "documentNumber": "77073848", "faculty": "FC", "UNICode": "20140118I", "documentType": "DNI" }
-
-
Create a list:
/list/createList?condition=
, it has a post method which will create a list that will be represented by the spokesperson who has performed the request.-
The body of the request must be as follows:
{ "owner": "QnYUvCKk74N3vfJZSHxW (id user)" }
-
The result key of the
JSON
response will contain::{ "applicants": [], "id": "RqezH0q4leKxysebcfwa", "owner": "QnYUvCKk74N3vfJZSHxW", "type": "third-of-faculty" }
-
-
Get lists of a user:
/list/getListsOfUser/:id
, it has a get method which will return you all the lists that the requested user has inscribed.-
The result key of the
JSON
response will contain:{ "students": { "owner": "QnYUvCKk74N3vfJZSHxW", "applicants": [ { "UNICode": "20140118I", "documentType": "DNI", "lastName": "LUZQUIÑOS", "documentNumber": "77073848", "specialty": "N6", "names": "STEVE ANTHONY", "postulating": true, "secondLastName": "AGAMA", "list": "xiaphgU3T9Atd1OlrCfm", "optionalMail": "", "faculty": "FC", "mail": "[email protected]", "id": "cFNUGLxWH8MpGLzv6FBk" } ], "type": "university-third-assembly", "id": "xiaphgU3T9Atd1OlrCfm" }, "teachers": { "owner": "QnYUvCKk74N3vfJZSHxW", "applicants": [ { "documentType": "DNI", "optionalMail": "", "documentNumber": "06686041", "lastName": "ACRUTA", "specialty": "", "UNICode": "19918003I", "faculty": "FIA", "secondLastName": "SANCHEZ", "mail": "[email protected]", "names": "ALFREDO", "id": "07bEwbinesBRgmidYSSl" } ], "type": "faculty-council", "id": "h8hqCv0pbyAynn20vBxp" } }
Note: There may be an empty object, or a object with only one key (students or teachers).
-
-
In case of success you will get a generic success response as follows, with a 200 code:
{ "error": false, "message": { "result": "An object with the corresponding result" } }
-
In case of error you will get a generic error response as follows, with a 500 error code:
{ "error": true, "message": "Error message" }
- Anthony Luzquiños - Initial Work - Database - Deployment - Documentation - AnthonyLzq.