Skip to content
This repository has been archived by the owner on Jan 12, 2021. It is now read-only.

line-school2018summer/tokyo-c-server

Repository files navigation

Tokyo C Messenger Server

Build

dep ensure and go build -o ~/bin/tokyo-c-server to build into ~/bin/tokyo-c-server.

Make a Start Script

cat > start-server below and chmod +x start-server.

#!/bin/bash

export TOKYO_C_DATABASE_HOST="          "
export TOKYO_C_DATABASE_USER="          "
export TOKYO_C_DATABASE_PASSWORD="      "
export TOKYO_C_DATABASE_NAME="tokyoC_`date +%Y%m%d%H%M%S`"
export TOKYO_C_DATABASE_URI="${TOKYO_C_DATABASE_USER}:${TOKYO_C_DATABASE_PASSWORD}@tcp(${TOKYO_C_DATABASE_HOST})/${TOKYO_C_DATABASE_NAME}"

./install-database

DATABASE_TYPE=mysql DATABASE_URI="${TOKYO_C_DATABASE_URI}" go run *.go -port 9000 &

PID="$!"

mysql --user="${TOKYO_C_DATABASE_USER}" --host="${TOKYO_C_DATABASE_HOST}" --password="${TOKYO_C_DATABASE_PASSWORD}" "${TOKYO_C_DATABASE_NAME}"

kill -KILL "${PID}"

mysql --user="${TOKYO_C_DATABASE_USER}" --host="${TOKYO_C_DATABASE_HOST}" --password="${TOKYO_C_DATABASE_PASSWORD}" <<EOS
DROP DATABASE ${TOKYO_C_DATABASE_NAME};
EOS

Place a Firebase Credentials

cat > firebase-credentials.json

Establish a Server

Execute ./start-server

Endpoints

/messages

  • GET /messages gives a realtime stream of messages of channel.
    • Parameters
      • channel specifies a channel which you want to listen.
      • since_id (optional) specifies a message id from which digging message archive starts.
    • Response (application/json stream): []Message (data_types.go)
  • POST /messages takes a message and broadcast it.

/messages/*

/friendships

  • GET /friendships gives a friend list of the current user.
    • Repsponse (application/json): []string
  • POST /friendships takes PIN and sends a request to the owner.
    • Payload (application/json): PIN code

/friendships/*

  • PUT /friendships/person makes a friendship from the current user to person (requiring that person send a request with PIN).
    • Repsponse (application/json): []string
  • DELETE /friendships/person dissolves a friendship from the current user to person.
    • Repsponse (application/json): []string

/channels

  • GET /channels gives a channel list the current user is participating in.
  • POST /channels makes a new channel with the only participant being the current user.

/channels/*

  • GET /channels/channel gives details of channel
  • POST /channels/channel/person performs a bulk invitation.
  • PUT /channels/channel/person makes person participate in channel (requiring that the current user be a member).
  • DELETE /channels/channel/person makes person withdraw from channel. (requiring that the current user be a member. the channel will perish if the current user is the last participant).
  • PATCH /channels/channel takes a differential data and modifies the information of channel.
    • Payload (application/x-www-form-urlencoded): name (optoinal)

/pin

  • GET /pin gives a realtime stream of event messages

/people/*

  • GET /people/person gives a firebase user info of person

/status

  • GET /status gives the current status of the current user

About

SUPER MASSIVE SPLENDID BACKEND

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •