All Projects β†’ JayZang β†’ Twitter Clone

JayZang / Twitter Clone

Twitter clone. The target is learning Vue framework and technique of backend to implement a SPA website.

Programming Languages

javascript
184084 projects - #8 most used programming language
es7
32 projects

Projects that are alternatives of or similar to Twitter Clone

Chirrapp
Chirr App splits text into tweets and posts it as a thread
Stars: ✭ 75 (-13.79%)
Mutual labels:  twitter
Aztro
The Astrology API πŸ’« Get daily horoscope!
Stars: ✭ 78 (-10.34%)
Mutual labels:  restful-api
Orange3 Text
🍊 πŸ“„ Text Mining add-on for Orange3
Stars: ✭ 83 (-4.6%)
Mutual labels:  twitter
Twitter media downloader
Twitter media downloader.
Stars: ✭ 75 (-13.79%)
Mutual labels:  twitter
Do more with twitter data
Tutorials for getting the most out of Twitter data.
Stars: ✭ 78 (-10.34%)
Mutual labels:  twitter
Jayme
Abstraction layer that eases RESTful interconnections in Swift
Stars: ✭ 79 (-9.2%)
Mutual labels:  restful-api
Network Avatar Picker
A npm module that returns user's social network avatar. Supported providers: facebook, instagram, twitter, tumblr, vimeo, github, youtube and gmail
Stars: ✭ 74 (-14.94%)
Mutual labels:  twitter
Python Ilorest Library Old
Python library for iLO RESTful API
Stars: ✭ 85 (-2.3%)
Mutual labels:  restful-api
Sharexin
ShareX for Linux and BSD
Stars: ✭ 79 (-9.2%)
Mutual labels:  twitter
Evolutility Server Node
Model-driven REST or GraphQL backend for CRUD and more, written in Javascript, using Node.js, Express, and PostgreSQL.
Stars: ✭ 84 (-3.45%)
Mutual labels:  restful-api
Restfm
RESTful web services for FileMaker server.
Stars: ✭ 76 (-12.64%)
Mutual labels:  restful-api
Userscripts
Userscripts for Greasemonkey, Tampermonkey etc.
Stars: ✭ 78 (-10.34%)
Mutual labels:  twitter
Social Login Helper Deprecated
A simple android library to easily implement social login into your android project
Stars: ✭ 81 (-6.9%)
Mutual labels:  twitter
Tweetview
This project is an example Android Twitter feed reader app from the Codehenge Android development tutorials.
Stars: ✭ 75 (-13.79%)
Mutual labels:  twitter
Fake Tweet
Tweet React Component
Stars: ✭ 85 (-2.3%)
Mutual labels:  twitter
Blum
A simple android Twitter client written in Kotlin
Stars: ✭ 74 (-14.94%)
Mutual labels:  twitter
Spam Bot 3000
Social media research and promotion, semi-autonomous CLI bot
Stars: ✭ 79 (-9.2%)
Mutual labels:  twitter
Batio
A fast and extensible micro-framework for PHP to build RESTful API.
Stars: ✭ 87 (+0%)
Mutual labels:  restful-api
Yourfukurou
Hackable YoruFukurou alternative Twitter client
Stars: ✭ 85 (-2.3%)
Mutual labels:  twitter
Clutter
Fully distributed twitter built on holochain
Stars: ✭ 84 (-3.45%)
Mutual labels:  twitter

twitter-clone

build

This project is built using Node and Vue.
The target is learning Vue framework and technique of backend to implement a SPA website.
All right of picture and sign is reserved for Twitter.
Used techniques, tools and packages by this project are not actually used by Twitter.
Welcome technical exchange, if this project has mistake of code or concept of programming, let me know, thanksπŸ‘

Demo

Main used package

Feature

  • Sign up
  • Login
  • Post
  • Comment
  • Follow

Build Setup

You have to has installed Docker.

Development Environment

docker-compose up

Custom configurations can be set at /server/config/config.json

Simple Introduction

Express

Official document
Use RESTful routes to handle http request.

const app = require('expess')

app.get('/', (req, res, next) => {
  res.json({
    res: 'This is GET method'
  })
})
app.post('/', (req, res, next) => {
    res.json({
      res: 'This is POST method'
    })
})
app.delete('/', (req, res, next) => {
  res.json({
    res: 'This is DELETE method'
  })
})
app.update('/', (req, res, next) => {
  res.json({
    res: 'This is UPDATE method'
  })
})

Mongoose

Official document
Use relational database.
This project has three models:

  • Users
  • Posts
  • Comments

Schema setting:

const userSchema = mongoose.Schema({
  posts: [{
    type: mongoose.Schema.Types.ObjectId,
    ref: 'Posts'
  }],
  //...
})
const postSchema = mongoose.Schema({
  author: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'Users'
  },
  comments: [{
    type: mongoose.Schema.Types.ObjectId,
    ref: 'Comments'
  }],
  //...
})
const commentSchema = mongoose.Schema({
  user: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'Users'
  },
  target: {
    model: String,
    id: mongoose.Schema.Types.ObjectId()
  },
  //...
})

const userModel = mongoose.Model('Users', userSchema)
const postModel = mongoose.Model('Posts', postSchema)
const commentModel = mongoose.Model('Comments', commentSchema)

Get populated data:

userModel.findById(USER_ID)
  .then(user => {
    if (!user) {
      //...
    }
    
    let opt = {
      path: 'posts',
      populate: {
        path: 'comments'
      }
    }
    
    user.populate(opt).execPopulate()
      .then(populatedUser => {
        // Do what tou want to do
      }).
      catch(e => {
        //...
      })
  })
  .catch(e => {
    //...
  })

Jsonwebtoken

Official document
Create an token and it will be invalid after 1 hour.
You can put some data into token to let server know this token's owner and information.

const jwt = require('jsonwebtoken')

const token = jwt.sign({
  id: USER_ID,
  access: 'auth',
  exp: Math.floor(Date.now() / 1000) + (60 * 60 * 1)
}, 'YOUR_SECRET_KEY')

Token verification:

try {
  let data = jwt.verify(RECEIVED_TOKEN, 'YOUR_SECRET_KEY')
} catch (e) {
  // Verify fail
}

Vue

Official document
The following picture shows the life cycle of a instance component.
I think it is the most important thing to understand each event when will be invoked.

Vue component's life cycle

If we have the component needs props of 'userID' to get user's info async.
When the components is instanced, function of created will be invoked and get user's information by current 'userID'. But if the next route also has this component and has different props of 'userID', this component is reused rather than instance a new component again. At this time the created function is not invoked, so the other method is using watch property to monitor the 'userID' props change or not, if the indicated target change, the function you set will be invoked.

Vue.component('your-component', {
  props:['userID'],
  data: function () {
    return {
      user: null
    }
  },
  created() {
    this.getUserInfo()
  },
  watch: {
    // here is important
    'userID': 'getUserInfo'
  },
  method: {
    getUserInfo() {
      // Some http Request to get user information from server
    }
  },
  template: '<div v-if="user">{{ user.name }}</div>'
})
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].