https://github.com/lccodder/nodejs-hexagonal-architecture-boilerplate
Hexagonal architecture template (URL shortener) written in Express.js using Cassandra and Redis
https://github.com/lccodder/nodejs-hexagonal-architecture-boilerplate
backend boilerplate expressjs hexagonal-architecture nodejs rest-api template typescript
Last synced: 8 months ago
JSON representation
Hexagonal architecture template (URL shortener) written in Express.js using Cassandra and Redis
- Host: GitHub
- URL: https://github.com/lccodder/nodejs-hexagonal-architecture-boilerplate
- Owner: LCcodder
- License: mit
- Created: 2024-08-02T21:23:37.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-26T17:58:07.000Z (over 1 year ago)
- Last Synced: 2025-04-13T13:48:27.123Z (11 months ago)
- Topics: backend, boilerplate, expressjs, hexagonal-architecture, nodejs, rest-api, template, typescript
- Language: TypeScript
- Homepage:
- Size: 96.7 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `Express.js` hexagonal architecture boilerplate *(URL shortener)*







### `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*
## Endpoints:
1. `POST:/users` - Registrates new user and returns created row
Usage:
```JSON
"email": "email@gmail.com",
"password": "AJSFa*Fya97GFAD",
"username": "Example username"
```
Response:
```JSON
"email": "email@gmail.com",
"username": "Example username",
"createdAt": "2024-08-05T12:44:11.705Z"
```
2. `POST:/auth` - Authorizes user and returns **JWT** token
Usage:
```JSON
"email": "email@gmail.com",
"password": "AJSFa*Fya97GFAD"
```
Response:
```JSON
"token":"afnajkfjoajf87dsf89asuf89asfu89as7f8a7f89asd7fya8d9uf8a9d7fa8d97f89adfd9",
"expiresIn": "24h"
```
3. `GET:/users/me` (requires JWT in `Bearer` header) - Returns user profile
Authorization:
```
Bearer afnajkfjoajf87dsf89asuf89asfu89as7f8a7f89asd7fya8d9uf8a9d7fa8d97f89adfd9
```
4. `POST:/urls` (**optional** JWT in `Bearer` header) - Creates url short-link
Authorization (**optional**):
```
Bearer afnajkfjoajf87dsf89asuf89asfu89as7f8a7f89asd7fya8d9uf8a9d7fa8d97f89adfd9
```
Usage:
```JSON
"to": "https://github.com/LCcodder/typing-assets"
```
Response:
```JSON
"id": "Sf531d",
"to": "https://github.com/LCcodder/typing-assets",
"createdAt": "2024-08-05T12:44:11.705Z",
"usesCount": 0
```
5. `GET:/r/:id` - Redirects to initial URL by id param
6. `GET:/urls/:id` - Returns URL object
Response:
```JSON
"id": "Sf531d",
"to": "https://github.com/LCcodder/typing-assets",
"createdAt": "2024-08-05T12:44:11.705Z",
"usesCount": 0
```
7. `GET:/urls/my` (requires JWT in `Bearer` header) - Returns created URLs
Authorization:
```
Bearer afnajkfjoajf87dsf89asuf89asfu89as7f8a7f89asd7fya8d9uf8a9d7fa8d97f89adfd9
```
Response:
```JSON
[
"id": "Sf531d",
"to": "https://github.com/LCcodder/typing-assets",
"createdAt": "2024-08-05T12:44:11.705Z",
"ownerEmail": "email@gmail.com",
"usesCount": 0
]
```
## Usage:
+ Make sure that `docker` and `docker 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
---
### Made by [LCcodder](https://github.com/LCcodder)