jheysonsaav / nextchat-server

NextChat API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NextChat Server (API)

This repository contains the source code of the server application for NextChat written with Rustlang.

Pre-requisites

Endpoints

Error response example (400 Bad Request):

{
    "code": 0,
    "message": "Unknown"
}

Version Checker

  • PATCH /version_checker?version={version}

See versions.md for more information about the available versions.

Response examples:

{
    "_url": "/version_checker?version=0.0.1",
    "required_update": true,
    "to": "1.0.0-alpha1"
}
{
    "_url": "/version_checker?version=1.0.0-alpha1",
    "required_update": false,
    "to": null
}

WebSockets

  • WebSocket /ws/?user_id={id}

Users

  • GET /users/all
  • GET /users/all?skip={number}
  • GET /users/all?take={number}
  • GET /users/all?skip={number}&take={number}

Default values:

{
    "skip": 0,
    "take": 10
}

Error codes:

0 -> Cannot get the users from the table.

Response example:

[
    {
        "id": "5959ad9c-598e-4deb-bcbe-053c1f73b400",
        "username": "danielsolartech",
        "profile_image": "",
        "online": false,
        "last_online": "2021-02-02T18:27:08",
        "created_at": "2021-02-02T18:27:08"
    }
]
  • GET /users/search/{text_to_search}
  • GET /users/search/{text_to_search}?skip={number}
  • GET /users/search/{text_to_search}?take={number}
  • GET /users/search/{text_to_search}?skip={number}&take={number}

Default values:

{
    "skip": 0,
    "take": 10
}

Error codes:

0 -> Cannot get the users from the table.

Response example:

[
    {
        "id": "5959ad9c-598e-4deb-bcbe-053c1f73b400",
        "username": "danielsolartech",
        "profile_image": ""
    }
]
  • GET /users/find?id={id}

Error codes:

0 -> Username and id in the query: `/users/find?id={}&username={username}`
1 -> The user id does not exist.

Response example:

{
    "id": "5959ad9c-598e-4deb-bcbe-053c1f73b400",
    "username": "danielsolartech",
    "profile_image": "",
    "online": false,
    "last_online": "2021-02-02T18:27:08",
    "created_at": "2021-02-02T18:27:08"
}
  • GET /users/find?username={username}

Error codes:

0 -> Username and id in the query: `/users/find?id={}&username={username}`
1 -> The username does not exist.

Response example:

{
    "id": "5959ad9c-598e-4deb-bcbe-053c1f73b400",
    "username": "danielsolartech",
    "profile_image": "",
    "online": false,
    "last_online": "2021-02-02T18:27:08",
    "created_at": "2021-02-02T18:27:08"
}
  • POST /users/signup

Error codes:

0 -> Username is empty.
1 -> Username between 4 and 15 characteres.
2 -> Password is empty.
3 -> Password between 8 and 40 characteres.
4 -> Username already exists.
5 -> Unknown.

Body example:

{
    "username": "danielsolartech",
    "password": "1234"
}

Response example:

{
    "id": "5959ad9c-598e-4deb-bcbe-053c1f73b400",
    "username": "danielsolartech",
    "profile_image": ""
}
  • POST /users/signin

Error codes:

0 -> Username is empty.
1 -> Password is empty.
2 -> Username does not exist.
3 -> The password is incorrect.

Body example:

{
    "username": "danielsolartech",
    "password": "1234"
}

Response example:

{
    "id": "5959ad9c-598e-4deb-bcbe-053c1f73b400",
    "username": "danielsolartech",
    "profile_image": ""
}

Authors

Changelog

View the lastest repository changes in the CHANGELOG.md file.

Copyright

License: GPL-2.0

Read file LICENSE for more information.

About

NextChat API

License:GNU General Public License v2.0


Languages

Language:Rust 99.6%Language:Shell 0.4%