npm install
forever start server.js
to stop server: forever stop server.js
default port is 8080
npm install
npm start
#server routes:
{}
{
"minVersionRequired": "x.x"
}
#Hittup routes:
an error message of 404 for /JoinHittup
, /UnjoinHittup
, /RemoveHittup
means the hittup doesn't exist.
timeInterval's first element is time before hittup starts, second element is time after hittup ends.
uid is optional, if it doesnt exist, it will only retrieve public hittups (i.e isPrivate==false)
{
"uid": "<uid>",
"timeInterval": [<seconds>,<seconds>]
}
{"success":true, "hittups":[
{
"_id": "<uid>",
"title": "<title>",
"isPrivate": <boolean>,
"duration": <seconds>,
"dateCreated": <seconds>,
"images": [ {
"lowQualityImageurl": "<full url>",
"highQualityImageurl": "<full url>"
},...],
"usersJoined": [
"_id": "<uid>",
"fbid": "<fbid>",
"firstName": "<firstName>",
"lastName": "<lastName>",
},
...
],
"usersInvited": [ {
"_id": "<uid>",
"fbid": "<fbid>",
"firstName": "<firstName>",
"lastName": "<lastName>",
},
...
],
"loc": {
"state": "<state>",
"city": "<city>",
"type": "Point",
"coordinates": [<long>, <lat>],
"lastUpdatedTime": <Int>
}
}
, ...
]
}
{
"hittupuid": "<uid>",
"useruid": "<uid>",
"userName": "<string>"
}
{"success":true}
or
{"success":false, "error":"<error message>"}
{
"hittupuid": "<uid>",
"owneruid": "<uid>",
"ownerName": "<string>"
}
{"success":true}
or
{"success":false, "error":"<error message>"}
the first image is the image posted by the host
{
"uid": "<uid>"
}
{"success":true, "hittup": {
"_id": "<uid>",
"owner": {
"firstName": "<firstname>",
"lastName: "<lastName>",
"fbid": "<fbid>"
},
"title": "<title>",
"isPrivate": <boolean>,
"duration": <seconds>,
"dateCreated": <seconds>,
"images": [ {
"lowQualityImageurl": "<full url>",
"highQualityImageurl": "<full url>"
},...],
"usersJoined": [ {
"_id": "<uid>",
"fbid": "<fbid>",
"firstName": "<firstName>",
"lastName": "<lastName>",
},
...
],
"usersInvited": [ {
"_id": "<uid>",
"fbid": "<fbid>",
"firstName": "<firstName>",
"lastName": "<lastName>",
},
...
],
"loc": {
"state": "<state>",
"city": "<city>",
"type": "Point",
"coordinates": [<long>, <lat>],
"lastUpdatedTime": <Int>
}
}
}
the first image is the image posted by the host
{
}
{"success":true, "hittup": {
"_id": "<uid>",
"owner": {
"name": "<name>",
"imageurl": "<url>"
},
"title": "<title>",
"isPrivate": <boolean>,
"duration": <seconds>,
"dateStarts": <seconds>,
"description": "<description >",
"dateCreated": <seconds>,
"images": [ {
"lowQualityImageurl": "<full url>",
"highQualityImageurl": "<full url>"
},...],
"usersJoined": [ {
"_id": "<uid>",
"fbid": "<fbid>",
"firstName": "<firstName>",
"lastName": "<lastName>",
},
...
],
"usersInvited": [ {
"_id": "<uid>",
"fbid": "<fbid>",
"firstName": "<firstName>",
"lastName": "<lastName>",
},
...
],
"loc": {
"state": "<state>",
"city": "<city>",
"type": "Point",
"coordinates": [<long>, <lat>],
"lastUpdatedTime": <Int>
}
}
}
gets all the hittups created by the user or by any of his friends
uid is optional, if it doesnt exist, it will only retrieve public hittups (i.e isPrivate==false)
{
"uid": "<uid>"
}
[ FriendHittups ] //just like the one in GetHittup
timeInterval's first element is time before hittup starts, second element is time after hittup ends.
{
"timeInterval": [<seconds>, <seconds>]
}
[ EventHittups ] //just like the one in GetHittup
{
"hittupuid": "<uid>",
"useruid": "<uid>",
"userName": "<string>"
}
{"success":true}
or
{"success":false, "error":"<error message>"}
POST format:
{"success":false, "error":"<error message>"}
{
"uid": "<uid>"
}
{
"owner": {
firstName: "<firstName>",
lastName: "<lastName>"
},
"title": "<title>",
"isPrivate": <boolean>,
"duration": "<duration>",
"dateCreated": "<dateCreated>",
"usersJoined": [
{
"_id": "<uid>",
"fbid": "<fbid>",
firstName: "<firstName>",
lastName: "<lastName>"
}
],
"usersInvited": [
{
"_id": "<uid>",
"fbid": "<fbid>",
firstName: "<firstName>",
lastName: "<lastName>"
}
],
"loc": {
"state": "<state>",
"city": "<city>",
"type": "<Point>",
"coordinates":[<long>,<lat>],
"lastUpdatedTime": <int>
}
}
{
"coordinates": [longitude, latitude],
"duration": <seconds>,
"title": "<title>",
"isPrivate": <boolean>,
"image": "<base64encodedimage>"
"isPrivate": <boolean>,
"uid": "<useruid>",
"ownerName": "<string>",
"usersInviteduids": ["<uid>","<uid>",...],
"image": "<base64encodedstring>"
}
format of the image doesn't matter
{"success":true, "uid": "<uid>"}
or
{"success":false, "error":"<error message>"}
{
"coordinates": [longitude, latitude],
"duration": <seconds>,
"title": "<title>",
"description": "<title>",
"image": "<base64encodedimage>",
"emoji": <String>,
"uid": "<EventOrganizeruid>",
"dateStarts": <seconds>
}
format of the image doesn't matter
{"success":true, "uid": "<uid>"}
or
{"success":false, "error":"<error message>"}
{
"hittupuid": "<uid>",
"owneruid": "<uid>",
"title": "<title>",
"coordinates": [<long>,<lan>],
"isPrivate": <boolean>,
"duration": <seconds>
}
{"success":true, "uid": "<uid>"}
or
{"success":false, "error":"<error message>"}
{
"inviteruid": "<uid>",
"hittupuid": "<uid>",
"inviterName": "<uid>",
"hittupTitle": "<string>",
"friendsuids": ["<uid>","<uid>"]
}
{"success":true}
or
{"success":false, "error":"<error message>"}
{
"coordinates": [longitude, latitude]
"uid": "<uid>"
}
{"city":location.city,"success":true}
{
"uid": "<uid>"
}
{"fb_friends":
[
{
"firstName":"<firstname>",
"lastName": "<lastname>",
"_id": "<uid>",
"fbid": fbid,
"loc":{
"type":"Point",
"state":"<state>",
"city":"<city>",
"coordinates":[<long>,<lat>],
"lastUpdatedTime": <int>
}
},
...
]
}
deviceToken is optional
{
"fbid": "<fbid>",
"fbToken": "<fbToken>",
"deviceToken": "<deviceToken"
}
if user doesn't exist:
{
"userStatus": "new",
"uid": "<uid>",
"fb_friends": [ ... ] (same as below)
}
if user already exists:
{
"userStatus": "returning",
"uid": "<uid>",
"fb_friends":
[
{
"firstName":"<firstname>",
"lastName": "<lastname>",
"_id": "<uid>",
"fbid": fbid,
"loc":{
"type":"Point",
"state":"<state>",
"city":"<city>",
"coordinates":[<long>,<lat>],
"lastUpdatedTime": <int>
}
},
...
]
}
HOW TO PUSH NOTIFY
download the certificate from http://developer.apple.com/iphone/manage/overview/index.action
open it using keychain access, export it to apns-cert.p12, then expand it and export the key to apns-key.p12
to convert them to .pem:
openssl pkcs12 -clcerts -nokeys -out apns-cert.pem -in apns-cert.p12
openssl pkcs12 -nocerts -out apns-key.pem -in apns-key.p12
#<<<<<for that one make sure u set a password
now we need to remove the password:
openssl rsa -in apns-key.pem -out apns-key-noenc.pem
now mv apns-key-noenc.pem key.pem
and mv apns-dev-cert.pem cert.pem
and make sure you remove anything before and after ---BEGIN CERTIFICATE---
and ---END CERTIFICATE-----
run with: NODE_ENV=production node <scriptName>.js