This is the backend of the Harper project.
You need to have Node.js
and yarn
installed.
You need an .env
file in order to run this project. It looks like this:
EMAIL_SENDER=
EMAIL_RECEIVER_1=
EMAIL_RECEIVER_2=
EMAIL_RECEIVER_3=
EMAIL_RECEIVER_4=
ID=
MONGO=
PASSWORD=
PORT=
SECRETE_KEY=
In order to install and use this project please run the following commands in your terminal:
yarn
yarn service
This will run the development server, so you will a message as follows:
yarn run v1.22.4
$ nodemon --exec babel-node -r dotenv/config src/index.js
[nodemon] 2.0.3
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): \*.\*
[nodemon] watching extension: js,mjs,json
[nodemon] starting `babel node -r dotenv/config src/index`
Server running at port 4000
We are connected to the database!
-
There are seven endpoints implemented:
-
Home:
/home
, it has a get method. It is just decorative. -
Areas:
/api/areas
, it has a get and a post method. The get method is just decorative. The post method has four different functionalities, according to what payload you send, here are some examples:-
To store a new area:
{ "args": { "type": "store", "data": { "abstract": "This is mandatory", "image": "This is optional", "name": "This is mandatory" } } }
-
To get all the areas:
{ "args": { "type": "getAll", "data": null } }
-
To get one area:
{ "args": { "type": "getOne", "data": { "name": "Desarrollo Web" } } }
-
To update an area:
{ "args": { "type": "update", "data": { "abstract": "This is optional", "image": "This is optional", "name": "Area to update" } } }
-
-
Careers:
/api/careers
, it has a get and a post method. The get method is just decorative. The post method has three different functionalities, according to what payload you send, here are some examples:-
To store a new career in the database:
{ "args": { "type": "store", "data": { "code": "N1", "name": "Física" } } }
-
To get all the careers from the database:
{ "args": { "type": "getAll", "data": null } }
-
To get one career from the database:
{ "args": { "type": "getOne", "data": { "code": "N1" } } }
-
-
Members:
/api/members
, it has a get and a post method. The get method is just decorative. The post method has five different functionalities, according to what payload you send, here are some examples:-
To store a new member:
{ "args": { "type": "store", "data": { "area": "Area name", "birthday": "YYYY-MM-DD", "career": "N1 || N2 || N3 || N5 || N6", "code": "XXXXXXXXA", "email": "[email protected]", "git": "Link to GitHub or GitLab profile", "key": "true || false", "lastName": "FirstLastName SecondLastName", "name": "Name1 Name2", "phone": "987654321", "photo": "Url to the member photo", "status": "Junta Directiva || Regular || Aspirante" } } }
-
To get all the members:
{ "args": { "type": "getAll", "data": null } }
-
To get one member:
{ "args": { "type": "getOne", "data": { "code": "XXXXXXXXA" } } }
-
To get all the members per area:
{ "args": { "type": "getMembersPerArea", "data": { "area": "Area name" } } }
-
To update a member:
{ "args": { "type": "update", "data": { "area": "New Area name", "birthday": "new birthday in format: YYYY-MM-DD", "career": "N1 || N2 || N3 || N5 || N6", "code": "current code: XXXXXXXXA", "email": "new email: [email protected]", "git": "new Link to GitHub or GitLab profile", "key": "true || false", "lastName": "new FirstLastName SecondLastName", "name": "new Name1 Name2", "newCode": "XXXXXXXXA", "phone": "new phone: 987654321", "photo": "new Url to the member photo", "status": "Junta Directiva || Regular || Aspirante" } } }
All the parameters shown before are optional, except the current code (code).
-
-
Projects:
/api/projects
, it has a get and a post method. The get method is just decorative. The post method has four different functionalities, according to what payload you send, here are some examples:-
To store a new project:
{ "args": { "type": "store", "data": { "area": "Area name", "description": "Project description", "name": "Project name", "participants": "XXXXXXXXA, YYYYYYYYB", "repo": "git.example.com, git.example2.com", "topic": "Project topic" } } }
-
To get all the projects:
{ "args": { "type": "getAll", "data": null } }
-
To get one projects:
{ "args": { "type": "getOne", "data": { "name": "Project name" } } }
-
To update a project:
{ "args": { "type": "update", "data": { "area": "Area name", "description": "New project description", "name": "Current project name", "newName": "New project name", "participants": "New participants: XXXXXXXXA, YYYYYYYYB", "repo": "New repo: git.example.com, git.example2.com", "topic": "New project topic" } } }
All the parameters shown before are optional, except the current name (name).
-
-
Status:
/api/status
, it has a get and a post method. The get method is just decorative. The post method has three different functionalities, according to what payload you send, here are some examples:-
To store a new status:
{ "args": { "type": "store", "data": { "name": "Regular" } } }
-
To get all the status:
{ "args": { "type": "getAll", "data": null } }
-
To get one of the status:
{ "args": { "type": "getOne", "data": { "name": "Regular" } } }
-
-
Contact us:
/api/contactUs
: it has a get and a post method. The get method is just decorative. The post method has one functionality, here is the payload:- To send a mail to contact ACECOM:
{ "args": { "type": "mail", "data": { "lastName": "Person last name", "mail": "[email protected]", "message": "Bla bla bla...", "name": "Person name", "subject": "Mail subject" } } }
This method will send an email to a ACECOM and to its web development team, in order to reply as soon as possible.
- To send a mail to contact ACECOM:
-
-
Every post request requires an authorization header (it uses a bearer), so it should be supplied when a post request is performed. This is token is provided by the server (it may be one stored in the database or another one just generated), you must provide an email receiver int the
.env
file to get this token, also and ID must be provided too, in order to create a 'user'. Without this token you wont be able to perform any post request. Finally (and obviously) you need to provide the sender email and at least 4 receivers, this is because the first one is going to send the email, be aware of the email configuration (gmail is set as default, but feel free to change it), in development, the server will send an email to the first receiver, but once is deployed it will send an email to 3 different receivers.
- Anthony Luzquiños - Initial Work - Database - Documentation - Deployment - Development - Maintenance AnthonyLzq.