Skip to content

goooseman/sample-chat-backend

Repository files navigation

Sample Chat Backend

Publicly availible at https://sample-chat.api.goooseman.ru/

Quick start

  • npm start to run the project in development mode
  • npm run build && node dist/src/main to run the project in production mode (or just use a pre-built Docker image)

API

A server has the following API.

Send message
const content: {
  id: string;
  userId: string;
  text: string;
  username: string;
  createdAt: string; // ISO 8601
  status: "none";
} = { ... };
await chatIO.emit("message", content, cb);
List messages
const Content: {
  id: string;
  userId: string;
  text: string;
  username: string;
  createdAt: string; // ISO 8601
  status: "none";
} = { ... };
await chatIO.emit("listMessages", (err?: Error, data: { items: Content[]} ) => { ... });
Recieve message
const Content: {
  id: string;
  userId: string;
  text: string;
  username: string;
  createdAt: string; // ISO 8601
  status: "none";
} = { ... };
chatIO.on("message", (data: Content) => { ... });

TODO

  • Pagination
  • Authorization
  • Seen marks

About

A sample real-time chat built on Express and Socket.io.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages