Skip to content

jason-tuttle/oneday-server

Repository files navigation

Oneday

Oneday is an ephemeral social app

This is the server-side app for Oneday, built in TypeScript, utilizing an Express server with WebSocket integration.

REST API

GET "/channels" : Channel[]

  • returns a list of Channels stored on the server

GET "/channels/:id" : Channel

  • returns a single Channel by id

POST "/channels/create" : Channel

  • create a Channel with ChannelInput as JSON body

DELETE "/channels/:idOrName" : number

  • deletes a channel by id or name, returning the number of channels deleted

GET "/channels/:channel/messages" : Message[]

  • get all Messages by channel_id

WebSocket API

socket.on("message": IncomingMessage): OutgoingMessage

  • type "SUBSCRIBE":
    • subscribe username to channel, response with OutgoingMessage type INFO
  • type "PUBLISH":
    • store IncomingMessage to db as Message
    • broadcast OutgoingMessage type MESSAGE to all subscribers

Types

Channel

interface Channel {
  id: string;
  name: string;
  description?: string;
  location?: string;
  created_at: string; // ISO8601 format
}

ChannelInput

interface ChannelInput {
  name: string;
  description?: string;
  location?: string;
}

Message

interface Message {
  id?: number;
  channel_id: string;
  username: string;
  content: string;
  created_at: string; // ISO 8601
}

IncomingMessage (ws)

interface IncomingMessage {
  type: "SUBSCRIBE" | "PUBLISH";
  channel?: string; // displayed channel name
  channel_id?: string; // uuid
  username?: string;
  content?: string;
}

OutgoingMessage (ws)

interface OutgoingMessage {
  type: "MESSAGE" | "INFO";
  channel?: string;
  channel_id?: string; // uuid
  username?: string;
  content?: string;
  created_at?: string; // ISO 8601
  message?: string;
}

About

API endpoints for oneday

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors