In order to learn about the MERN Stack and Back-End development I decided to build a URL Shortener Server.
- Run
just devto start Docker Services - Run the HTTP Server using
just server - Run the Front-End using
just clientin a separate terminal
The following section describes the server solution architecture and available endpoints.
The server solution serves a HTTP Server using the
REST Spec. The available endpoints are listed below.
The column "π" determines wether the user should provide a token to perform the operation.
Public links usage
| Method | Path | Description | π |
|---|---|---|---|
GET |
/:slug |
Redirects user to actual link (if exists). | β |
Authentication is performed via Cookies which are signed by the server.
| Method | Path | Description | π |
|---|---|---|---|
POST |
/api/v1/auth/signup |
Registers a new account. | β |
POST |
/api/v1/auth/signin |
Generates a token and sets a cookie if credentials are valid. | β |
GET |
/api/v1/user/me |
Retrieves authenticated user data. | β |
DELETE |
/api/v1/auth/session |
Invalidates user's token. | β |
Users can update their profiles data using the user
API.
| Method | Path | Description | π |
|---|---|---|---|
PUT |
/api/v1/user |
Updates user details such as name and surname. |
β |
Short links are the main resource of this server and should be treated as a first-class citizen.
| Method | Path | Description | π |
|---|---|---|---|
GET |
/api/v1/links/:slug |
Retrieves a link's summary. | β |
POST |
/api/v1/links |
Creates a shortened link. | β |
PUT |
/api/v1/links/:slug |
Updates a shortened link details. | β |
PATCH |
/api/v1/links/deactivate/:slug |
Deactivates link by slug. | β |
PATCH |
/api/v1/links/activate/:slug |
Activates link by slug. | β |
The column "ποΈ" determines the public visibility of this field. Generally speaking, fields that are not public visible lives only in the server-side or as database reference.
| Property | Data Type | Description | ποΈ |
|---|---|---|---|
| name | String |
User's name. | β |
| surname | String |
User's surname. | β |
String |
User's email. Cannot be updated. | β | |
| passwordHash | String |
Hash used to validate password. | β |
| accessToken | Option<String> |
Hash used to validate password. | β |
| createdAt | Date |
Date of creation. | β |
| updatedAt | Date |
Date of most recent update. | β |
| Property | Data Type | Description | ποΈ |
|---|---|---|---|
| fullUrl | String |
Link's full url | β |
| slug | String |
Link's slug | β |
| activated | Boolean |
Determines whether a link is active or not | β |
| userId | String |
Link owner | β |
| createdAt | Date |
Date of creation. | β |
| updatedAt | Date |
Date of most recent update. | β |
TODO
MIT Licensed Β© David Alejandro RodrΓguez 2024