Skip to content

node+mongo project archetype demonstrating how to use node and mongo to build a restful webservice

Notifications You must be signed in to change notification settings

ltebean/node-mongo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Feb 21, 2013
9d6c4a4 · Feb 21, 2013

History

55 Commits
Feb 13, 2013
Feb 6, 2013
Feb 19, 2013
Feb 17, 2013
Feb 18, 2013
Nov 27, 2012
Nov 27, 2012
Feb 4, 2013
Jan 27, 2013
Feb 13, 2013
Jan 15, 2013
Feb 21, 2013
Jan 15, 2013
Feb 19, 2013
Feb 18, 2013
Jan 30, 2013
Feb 21, 2013

Repository files navigation

Introduction

This project provides a restful api of the invitation service

API

create an invitation

post - /resource/invitation

body - the fully fledged invitaion object that must contain all fields it might need later

load an invitation

get - /resource/invitation/:id

load open invitations

get - /resource/invitation/open/weiboId/:weiboId/page/:page

load closed invitations

get - /resource/invitation/closed/weiboId/:weiboId/page/:page

change status

post - /resource/invitation/:id/status

body- {user:{},status:""};

reply

post - /resource/invitation/:id/reply

body - {content:"",date:new Date(),user:{weiboId:"",weiboName:""...}}

get city and shop

get - /resource/cities

get - /resource/shop

apns registration

post - /resource/apns/registration

body - {user:{},deviceToken:''}

The structure of the invitation object is like this:

{
  "_id": "50b3237a0cf235d0ba9143a8",
  "inviter": {
    "user": {
      "weiboId": "1794581765",
      "weiboName": "福禄钱恩",
      "weiboIcon": "http://tp2.sinaimg.cn/1794581765/180/40008135152/0",
      "weiboIconSmall": "http://tp2.sinaimg.cn/1794581765/50/40008135152/0"
    }
  },
  "invitees": [
    {
      "user": {
        "weiboId": "2134062323",
        "weiboName": "ltebean",
        "weiboIcon": "http://tp4.sinaimg.cn/2134062323/180/5644408802/1",
        "weiboIconSmall": "http://tp4.sinaimg.cn/2134062323/50/5644408802/1"
      },
      "status": "unknown"
    }
  ],
  "replyList": [
    {
      "content": "nice",
      "user": {
        "weiboId": "1794581765",
        "weiboName": "福禄钱恩",
        "weiboIcon": "http://tp2.sinaimg.cn/1794581765/180/40008135152/0",
        "weiboIconSmall": "http://tp2.sinaimg.cn/1794581765/50/40008135152/0"
      },
      "date": "2012-11-26T08:10:57.749Z"
    }
  ],
  "creatDate": "2012-11-26T08:08:26.211Z",
  "startDate": "2012-11-21T16:00:00.000Z",
  "lastUpdateDate": "2012-11-26T08:10:57.749Z",
  "description": "在阿猫一条鱼吃饭chifan",
  "shopList": [
    {
      "shopId": 2725198,
      "shopName": "阿猫一条鱼",
      "address": "杨浦区国顺路587号(近政肃路)",
      "phoneNo": "13127530310",
      "latitude": 31.29442,
      "longtitude": 121.50675,
      "picUrlList": [
        "http://i3.dpfile.com/2010-11-08/5764433_m.jpg"
      ]
    },
    {
      "shopId": 2725198,
      "shopName": "阿猫一条鱼",
      "address": "杨浦区国顺路587号(近政肃路)",
      "phoneNo": "13127530310",
      "latitude": 31.29442,
      "longtitude": 121.50675,
      "picUrlList": [
        "http://i3.dpfile.com/2010-11-08/5764433_m.jpg"
      ]
    }
  ]
}

receive message through websocket

<script src="/socket.io/socket.io.js"></script>
<script>
    var socket = io.connect('http://192.168.32.84:3000');
    // first register with weiboId
    socket.emit('register',weiboId);
    // then listent on this topic
    socket.on('news', function (data) {;
        // data is an array,the element is like this:
        // {type:'new|status|reply',body:{the corresponding body}};
    });
</script>

About

node+mongo project archetype demonstrating how to use node and mongo to build a restful webservice

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published