REST API
written in Express.js
with TypeScript
using hexagonal architecture pattern. Project: URL shortener with registration, authorization, URL redirection with caching and URL uses counter
-
POST:/users
- Registrates new user and returns created rowUsage:
"email": "email@gmail.com", "password": "AJSFa*Fya97GFAD", "username": "Example username"
Response:
"email": "email@gmail.com", "username": "Example username", "createdAt": "2024-08-05T12:44:11.705Z"
-
POST:/auth
- Authorizes user and returns JWT tokenUsage:
"email": "email@gmail.com", "password": "AJSFa*Fya97GFAD"
Response:
"token":"afnajkfjoajf87dsf89asuf89asfu89as7f8a7f89asd7fya8d9uf8a9d7fa8d97f89adfd9", "expiresIn": "24h"
-
GET:/users/me
(requires JWT inBearer
header) - Returns user profileAuthorization:
Bearer afnajkfjoajf87dsf89asuf89asfu89as7f8a7f89asd7fya8d9uf8a9d7fa8d97f89adfd9
-
POST:/urls
(optional JWT inBearer
header) - Creates url short-linkAuthorization (optional):
Bearer afnajkfjoajf87dsf89asuf89asfu89as7f8a7f89asd7fya8d9uf8a9d7fa8d97f89adfd9
Usage:
"to": "https://github.com/LCcodder/typing-assets"
Response:
"id": "Sf531d", "to": "https://github.com/LCcodder/typing-assets", "createdAt": "2024-08-05T12:44:11.705Z", "usesCount": 0
-
GET:/r/:id
- Redirects to initial URL by id param -
GET:/urls/:id
- Returns URL object Response:"id": "Sf531d", "to": "https://github.com/LCcodder/typing-assets", "createdAt": "2024-08-05T12:44:11.705Z", "usesCount": 0
-
GET:/urls/my
(requires JWT inBearer
header) - Returns created URLsAuthorization:
Bearer afnajkfjoajf87dsf89asuf89asfu89as7f8a7f89asd7fya8d9uf8a9d7fa8d97f89adfd9
Response:
[ "id": "Sf531d", "to": "https://github.com/LCcodder/typing-assets", "createdAt": "2024-08-05T12:44:11.705Z", "ownerEmail": "email@gmail.com", "usesCount": 0 ]
- Make sure that
docker
anddocker compose
are installed on your system
To launch application run:
docker compose up --build
-
If app throws cassandra connection error reload app container
-
If you want launch app without docker you can find keyspace creation statements in
init_keyspace.cql
file