Git Product home page Git Product logo

backend's Introduction

Rest API Server for URL Shortener App

Authorization:

Authorization is performed by the AccessToken in Authorization header. Access token issues for 30 minutes, and refreshs by RefreshToken in cookies. RefreshToken issues for 30 days. On logout refresh token adds to blacklist, and access token will never updated with this refresh token.

Data structures:

User:

Field Type Description
id string The ID of user
username string The username of user
email string The email of user
telegram_id sstring ID of assigned telegram account

URL:

Field Type Description
id string The ID of url
alias string The short alias of url
url string The original url
redirects int The redirects counter

Token pair:

Field Type Description
access_token string The access token
refresh_token string The refresh token

Endpoints:

POST /api/auth/session - login (create a session)

Body:

Field Type Required
email string Yes
password string Yes

Success response: 200 OK and token pair object.

Possible errors:

Code Description
400 Bad request. Missing required fields. User with this credentials already exists.

DELETE /api/auth/session - logout (close a session):

Success response: 200 OK

Possible errors:

Code Description
401 Unauthorized

POST /api/auth/signup - registration (create user)

Body:

Field Type Required
email string Yes
username string Yes
password string Yes

Success response: 201 Created and user object.

Possible errors:

Code Description
400 Bad request. Missing required fields
409 User with this email or username already exists

POST /api/auth/refresh - refresh tokens

Body:

Field Type Required
token string Yes

Success response: 200 OK and token pair object.

Field Type
access_token string
refresh_token string

Possible errors:

Code Description
403 Invalid refresh token

GET /api/user/{id} - get user

Success response: 200 OK and user object.

Possible errors:

Code Description
404 User not found

DELETE /api/user/{id} - delete user

Success response: 200 OK

Possible errors:

Code Description
400 Bad request. User not found in database
401 Unauthorized

GET /api/user/{id}/urls - get my URLs

Success response: 200 OK and array of url objects.

Possible errors:

Code Description
401 Unauthorized

POST /api/url - create URL

Request body:

Field Type Required
url string Yes
alias string No

Success response: 201 Created and url object.

Possible errors:

Code Description
400 Bad request. Missing required fields
401 Unauthorized
409 URL with this alias already exists

PATCH /api/url/{alias} - update url

Request body:

Field Type Required
url string Yes
alias string No

Success response: 200 OK and url object with not-updated fields.


DELETE /api/url/{alias} - delete URL

Success response: 200 OK

Possible errors:

Code Description
401 Unauthorized
403 Forbidden. You are not owner of this URL
404 URL to delete not found

backend's People

Contributors

jus1d avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.