This is still a on going working project
Table of Content
- Deploy
- Development
- API Documentation
- GET /friends
- GET /friends/update
- GET /invite
- GET /invite/update
- GET /notification/push
- GET /subscribe
- GET /subscribe/all
- GET /subscribe/mine
- GET /subscribe/create
- GET /subscribe/dismiss
- GET /subscribe/add
- GET /subscribe/remove
- GET /user/login
- GET /user/avatar
- GET /user/position
- GET /user/update/email
- GET /user/update/avatar
- GET /user/update/nickname
- GET /user/update/position
- GET /user/update/status
This instance must run behind a proxy if you expect HTTPS and other advanced web server settings.
$ git clone https://github.com/crypto-meetup-dev/cryptomeetup-be
$ cd cryptomeetup-be
$ cp config.json.example config.json
$ vim config.json
Currently we are only having one parameter here, you can change the port number for your instance. But later we will have more envirnment settings in this file which is important.
After editing the config.json and change the things you want, run to install dependencies:
$ yarn
# for npm users
$ npm install
After your installation finished, run this command on another screen or pm2:
$ yarn start
# For npm command is compatible though
$ npm start
# For pm2 command
$ pm2 start app.js --name YOU_INSTANCE_NAME -- start
Let's go to edit our web server configuration. In this case, I use Nginx.
$ cd /etc/nginx/sites-available
$ sudo vim api.instance.domain.conf
Use something simular to this:
server {
listen 80;
server_name api.instance.domain;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
# listen [::]:443 ssl;
server_name api.instance.domain;
ssl on;
ssl_certificate /usr/share/nginx/private/fullchain.pem;
ssl_certificate_key /usr/share/nginx/private/privkey.pem;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS !RC4";
keepalive_timeout 70;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
add_header Strict-Transport-Security max-age=63072000;
add_header X-Content-Type-Options nosniff;
location ^~ /cryptomeetup/ {
rewrite ^/cryptometup(/.*)$ $1 break;
proxy_pass http://127.0.0.1:7000/; #Port number
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-PORT $remote_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Use the modern web browser to access the domain you just filled in.
If you see the Welcome Page, then you are done, your API instance is online now.
Make sure you have your data
and cache
setup correctly.
For local development, you don't need any other configuration, edit the environment variables in config.json
and code on your IDE.
Fields | Type | Description |
---|---|---|
id | Integer | id of the user in Matataki.io |
Field | Type | Description |
---|---|---|
Array of Friend Object | Array | array of the requested user's friends |
Fields | Type | Description |
---|---|---|
userId | Integer | user id of the friend |
nickname | String | nickname of the user |
lng | Float | longitude of the user last seen |
lat | Float | latitude of the user last seen |
status | Boolean | online status of friend |
Example:
https://api.instance.com/friends?id=0
Example response:
[{"userId": 2, "nickname": "Sam", "lng": 32.2338, "lat": -64.1292, status: false}]
Fields | Type | Description |
---|---|---|
id | Integer | id of the user to modify |
removeId | Integer | id of the user to remove |
Field | Type | Description |
---|---|---|
message | String | 'success' or 'No need to modify' based on user |
Example:
https://api.instance.com/subscribe/dismiss?id=0
Example response:
{ message: 'success' }
Fields | Type | Description |
---|---|---|
id | Integer | id of the user to send invite |
String | email of the user to get the invite |
Field | Type | Description |
---|---|---|
Object of Notification Object | Notification Object | the invited notification object updated |
Example:
https://api.instance.com/invite?id=12&email=root@instance.com
Example response:
{notifyGlobalId: siw92is8, notifyId: 1, userId: 12, title: John, body: "John 希望和你共享 TA 的地图信息(这并不会暴露你的地图信息),要接受吗?", proceed: false}
Fields | Type | Description |
---|---|---|
id | Integer | id of the user to update |
result | String | 'accept' or 'deny' of the result |
notifyId | Integer | id of the notifyObject for user |
inviteUser | Integer | id of the user to be invited |
Field | Type | Description |
---|---|---|
message | String | 'success' or 'No need to modify' based on user |
Example:
https://api.instance.com/invite/update?id=0&result=accept¬ifyId=2&inviteUser=4
Example response:
{ message: 'success' }
Field | Type | Description |
---|---|---|
id | Integer | id of the user to get push |
Field | Type | Description |
---|---|---|
Array of Notification Object | Array | array of the request user's notifications |
Fields | Type | Description |
---|---|---|
notifyGlobalId | Integer | Global Id of the notify object |
notifyId | Integer | notification id of the user |
userId | Integer | the id of user who request |
title | String | the title of notification, nickname here |
body | String | the body of notification |
proceed | Boolean | a boolean value weither this notification is proceeded |
Example:
https://api.instance.com/notification/push?id=0
Example response:
[{notifyGlobalId: siw92is8, notifyId: 1, userId: 0, title: John, body: "John 希望和你共享 TA 的地图信息(这并不会暴露你的地图信息),要接受吗?", proceed: false}]
Field | Type | Description |
---|---|---|
None | N/A | N/A |
Field | Type | Description |
---|---|---|
Array of Subscription Profile | Array | a array contains all the available subscriptions |
Fields | Type | Description |
---|---|---|
id | Integer | id of the user who created the subscription |
nickname | String | nickname of the user |
token | Integer | the tokenId for required token |
symbol | String (CAPS) | the symbol of the token |
amount | Integer | the required amount token to unlock |
Example:
https://api.instance.com/subscribe/all
Example response:
[{"userId":"1332","nickname":"アヤカ","token":"22","symbol":"DAO","amount":"1000000"}]
Field | Type | Description |
---|---|---|
id | Integer | id of the reuqested user to query subscription |
Field | Type | Description |
---|---|---|
Object of Subscription Profile | Subscription Profile |
Example:
https://api.instance.com/subscribe/mine?id=0
Example response:
{"userId":"1332","nickname":"アヤカ","token":"22","symbol":"DAO","amount":"1000000"}
Fields | Type | Description |
---|---|---|
id | Integer | id of the user who create the subscription |
tokenId | Integer | tokenId of the required token |
symbol | String (CAPS) | token symbol of the required token |
amount | Integer | a specified amount of token for subscription |
Field | Type | Description |
---|---|---|
message | String | 'create success' or 'update success' based on user |
Example:
https://api.instance.com/subscribe/create?id=0&tokenId=22&symbol=DAO&amount=1000000
Example response:
{ message: 'create success' }
Field | Type | Description |
---|---|---|
id | Integer | id of the dismiss subscription user |
Field | Type | Description |
---|---|---|
message | String | 'success' or 'No need to modify' based on user |
Example:
https://api.instance.com/subscribe/dismiss?id=0
Example response:
{ message: 'success' }
Fields | Type | Description |
---|---|---|
id | Integer | id of the requested user |
addId | Integer | id of the user who to add to subscription |
Field | Type | Description |
---|---|---|
message | String | 'success' or 'No need to modify' based on user |
Example:
https://api.instance.com/subscribe/add?id=0
Example response:
{ message: 'success' }
Fields | Type | Description |
---|---|---|
id | Integer | id of the requested user |
removeId | Integer | id of the user who to remove from subscription |
Field | Type | Description |
---|---|---|
message | String | 'success' or 'No need to modify' based on user |
Example:
https://api.instance.com/subscribe/remove?id=0
Example response:
{ message: 'success' }
Fields | Type | Description |
---|---|---|
id | Integer | id of this user in Matataki.io |
String | email of this user in Matataki.io | |
nickname | String | nickname of this user in Matataki.io |
Avatar | String | Partial avatar imgae url of this user in Matataki.io |
Fields | Type | Description |
---|---|---|
message | String | Welcome message according to the users nickname |
Example:
https://api.instance.com/user/login?id=1&email=master@instance.com&nickname=john&avatar=avatar_url
Example response:
{ message: Welcome new user john! }
Fields | Type | Description |
---|---|---|
id | Integer | id of the requested user for the avatar |
Fields | Type | Description |
---|---|---|
Image/png | Image/png | The circle image avatar of the requested user |
Example:
https://api.instance.com/user/avatar?id=1
Example response:
BASE64 imgae/png
Fields | Type | Description |
---|---|---|
id | Integer | id of the requested user for the email change |
String | email address that needs to be modified |
Fields | Type | Description |
---|---|---|
Message | String | The message saying weither the update is success or not modified |
Example:
https://api.instance.com/user/update/email?id=1@email=root@instance.com
Example response:
{ "message": "success" }
Fields | Type | Description |
---|---|---|
id | Integer | id of the requested user for the avatar change |
avatar url | String | Partial avatar url of the requested user |
Fields | Type | Description |
---|---|---|
Message | String | The message saying weither the update is success or not modified |
Example:
https://api.instance.com/user/update/avatar?id=1&avatar=avatar_url
Example response:
{ "message": "success" }
Fields | Type | Description |
---|---|---|
id | Integer | id of the requested user for the nickname change |
nickname | String | nickname that is going to change for requested user |
Fields | Type | Description |
---|---|---|
Message | String | The message saying weither the update is success or not modified |
Example:
https://api.instance.com/user/update/nickname?id=1&nickname=steve
Example response:
{ "message": "success" }
Fields | Type | Description |
---|---|---|
id | Integer | id of the requested user for the position change |
lng | Float | Longtitude for the position to update |
lat | Float | Latitude for the position to update |
Fields | Type | Description |
---|---|---|
Message | String | The message saying weither the update is success or not modified |
Example:
https://api.instance.com/user/update/position?id=1&lng=123.22&lat=32.3331
Example response:
{ "message": "success" }
Fields | Type | Description |
---|---|---|
id | Integer | id of the user to update statuss |
status | Boolean | a boolean value of weither the user is online or not |
Fields | Type | Description |
---|---|---|
Message | String | The message saying weither the update is success or not modified |
Example:
https://api.instance.com/user/update/position?id=1&lng=123.22&lat=32.3331
Example response:
{ "message": "success" }