GithubHelp home page GithubHelp logo

message's Introduction

Message

node-icon express-icon mongoose-icon jquery-weui-icon build-icon

This is a private letter system demo. Version: 0.1.0

Installation & Start

    1. 克隆文件
$ git clone https://github.com/TalkWIthKeyboard/Message.git
    1. 安装包和前端库
$ cd Message
$ npm install
$ bower install
    1. 启动项目
$ nodemon

Design

Technology Stack

这次的技术栈是 express + mongo,前端使用的是 Jade模板Jquery-weui库

Code Design

.
├── app.js
├── builder               // 切面生成器
│   ├── middleBuilder.js
│   ├── responseBuilder.js
│   └── utilBuilder.js
├── model                 // 数据库映射
│   ├── conf.js           // 统一配置文件
│   ├── create.js         // schema到model的生成器
│   ├── friendSchema.js
│   ├── messageSchema.js
│   ├── promise.js        // 数据库操作API Promise对象
│   └── userSchema.js
├── nodemon.json
├── package.json
├── routes                // 路由
│   ├── api-router.js
│   └── h5-router.js
├── server                // 业务逻辑
│   ├── apiServer.js      // 通用的增删查改API
│   ├── messageServer.js  // message相关业务
│   ├── requestServer.js  // 请求参数检测业务
│   └── userServer.js     // user相关业务

Back-end Design

因为时间原因没有来得及实现动态刷新的功能,后面会给出一些思路。现在项目中都是基于 Http 的短连接进行实现的,登录用户的状态是通过在服务器端维护 session 来进行实现,并且也通过 session 做了拦截器,会将没有登录的用户拦截到登录页面。

API Design

  • H5 (GET)
    • 登录页面:/h5/login
    • 注册页面:/h5/register
    • 好友页面:/h5/friend
    • 好友搜索:/h5/search
    • 消息页面:/h5/message/:receiver
  • API
    • 用户注册:/api/user
      • Type:POST
      • Body:
        • username
        • password
    • 用户登录:/api/login
      • Type:POST
      • Body:
        • username
        • password
    • 寻找用户:/api/friend/:username
      • Type:GET
      • Params:username
    • 添加朋友:/api/friend
      • Type:POST
      • Body:friend
    • 删除朋友:/api/friend/:friend
      • Type:DELETE
      • Params:friend
    • 发消息:/api/message
      • Type:POST
      • Body:
        • receiver
        • message
    • 删除消息:/api/message/:id
      • Type:DELETE
      • Params:id

Schema Design

  • User
    • username: String
    • password: String
    • meta:
      • createAt: Date
      • updateAt: Date
  • Message
    • sender: ObjectId
    • receiver: ObjectId
    • notRead: Number
    • meta:
      • createAt: Date
      • updateAt: Date
  • Friend
    • adder: ObjectId
    • friend: ObjectId
    • message: String
    • meta:
      • createAt: Date
      • updateAt: Date

Todo List

  • 前端加密
  • 好友模糊搜索
  • 实时更新**(以消息接收发送为例)**
    • 进入页面后连入 websocket
    • 定义多个 Event,发送消息后不仅通过 HTTP API 修改数据库,send messagewebsocket 监听端口,服务端再广播到另一端的用户。
    • 另一端的用户监听到消息以后,通过前端 Javascript 将消息添加到屏幕。

Demo

因为适配的是手机端,所以浏览器请切换成手机屏幕大小。

内容的输入提交,都是监听的enter事件,所以输入完成以后直接点回车即可。

http://115.159.1.222:8888/

message's People

Contributors

talkwithkeyboard avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.