commonroutesServer/README.md
README.mdRaw
1# commonroutesServer
2
3- Current status:
4 - Server and App almost done, need to finish details.
5 - I'm focusing on having a first stable and usable version
6 - The plan is to have the first stable version in the middle of February 2018
7- Comments:
8 - the code is not a good quality code, as:
9 - it was developed in a discontinued way
10 - in the process I learned stuff that I didn't know at the beginning
11- Future plans:
12 - If somebody can do the frontend, maybe we can implement the frontend app in React
13 - I can focus on implementing the backend in Go lang
14
15---
16
17- server code: https://github.com/arnaucube/commonroutesServer
18- frontend app code: https://github.com/arnaucube/commonroutesApp
19- frontend webapp code: https://github.com/arnaucube/commonroutesWebApp
20- images server: https://github.com/arnaucube/goImgServer
21- admin web: https://github.com/arnaucube/commonroutesAdminWeb
22- landing page: https://github.com/arnaucube/commonroutesLandingPage
23- telegram bot: https://github.com/arnaucube/commonroutesBot
24
25**Backend:**
26
27- Nodejs + Express + MongoDB
28- Go --> for the images server
29
30**Frontend:**
31
32- Angularjs + Ionic
33
34
35
36App:
37
38
39code: https://github.com/arnaucube/commonroutesApp
40
41---
42
43
44**To Do Backend and Frontend:**
45```
46- pagination search
47- https (tls/ssl)
48```
49
50### Configuration before run:
51In controllers/userController.js, define the port of the goImgServer:
52```
53function postImage(req, res, filename, fileImg) {
54 url = "http://127.0.0.1:3001/image";
55 [...]
56```
57
58### Launch using Tmux
59First move the `launch-all.sh` to the parent directory.
60Having the following directory scheme:
61```
62./
63 commonRoutesBot/
64 commonRoutesLandingPage/
65 commonRoutesServer/
66 goImgServer/
67 launch-all.sh
68```
69
70Make sure to have `tmux` installed, and mongodb running, and the `npm` packages of the different directories installed.
71
72Then just need to run:
73```
74bash launch-all.sh
75```
76
77#### RESOURCES using:
78
79initial avatars users: [http://www.flaticon.com/packs/animal-icon-collection](http://www.flaticon.com/packs/animal-icon-collection)
80
81
82---
83
84## API Documentation
85This section is not finished.
86
87### GET /travels
88Returns a json array with the page travals.
89- Pagination option: **/travels?page=2**
90 - Each page has a length of 20 travels.
91
92### GET /travels/id/{travelid}
93Returns the full json data of a travel.
94```json
95{
96 "_id": "5b582cc8a920010ebdba5445",
97 "from": {
98 "lat": 43.6170137,
99 "long": 13.5170982,
100 "name": "Ancona, AN, MAR, Italy"
101 },
102 "to": {
103 "lat": 43.8198253,
104 "long": 7.7748827,
105 "name": "Sanremo, IM, Liguria, Italy"
106 },
107 "joins": [],
108 "joinPetitions": [],
109 "comments": [],
110 "title": "Visiting Torri Superiori",
111 "user": {
112 "_id": "5b3cf604a920010ebdba1111",
113 "avatar": "https://imgc.artprintimages.com/img/print/janet-muir-cape-washington-antarctica-adelie-penguin-walks-forward_u-l-pyoufg0.jpg",
114 "validated": false,
115 "username": "person1",
116 "telegram": "person1"
117 },
118 "date": "2018-08-04T22:00:00.000Z",
119 "generateddate": "2018-07-25T07:54:48.000Z",
120 "seats": 2,
121 "type": "asking",
122 "__v": 0
123}
124```
125### GET /users
126
127- Pagination option: **/users?page=2**
128 - Each page has a length of 20 users.
129
130### GET /users/id/{userid}
131
132```json
133{
134 "_id": "5a83528d7ce0482bab4f4111",
135 "description": "Hello world",
136 "avatar": "https://imgc.artprintimages.com/img/print/janet-muir-cape-washington-antarctica-adelie-penguin-walks-forward_u-l-pyoufg0.jpg",
137 "faircoinString": "faircoin address",
138 "faircoin": "url/data of QR faircoin address",
139 "validated": true,
140 "valorations": [],
141 "likes": ["5ad4b4f69a32d22cc7848011"],
142 "favs": [],
143 "travels": [{
144 "_id": "5b0a66daab8f07271498a411",
145 "from": {
146 "lat": 41.816082,
147 "long": 2.5138924,
148 "name": "Arbúcies, Selva, Girona, Catalonia, 17401, Spain"
149 },
150 "to": {
151 "lat": 41.3828939,
152 "long": 2.1774322,
153 "name": "Barcelona, BCN, Catalonia, Spain"
154 },
155 "title": "Arbúcies-Barcelona",
156 "date": "2018-05-27T14:00:00.000Z",
157 "type": "offering"
158 }, {
159 "_id": "5b2780f4ab8f07271498a411",
160 "from": {
161 "lat": 41.3828939,
162 "long": 2.1774322,
163 "name": "Barcelona, BCN, Catalonia, Spain"
164 },
165 "to": {
166 "lat": 41.1172364,
167 "long": 1.2546057,
168 "name": "Tarragona, Tarragonès, Tarragona, Catalonia, Spain"
169 },
170 "title": "going to Tarragona",
171 "date": "2018-07-02T08:00:00.000Z",
172 "type": "asking"
173 }],
174 "notifications": [],
175 "username": "person2",
176 "telegram": "person2",
177 "localNode": "Catalunya",
178 "__v": 4,
179 "validatedBy": {
180 "_id": "5a835596c45e042c19d3fb11",
181 "username": "commonroutesadmin01"
182 }
183}
184```