Skip to content

Latest commit

Β 

History

History
113 lines (77 loc) Β· 3.12 KB

File metadata and controls

113 lines (77 loc) Β· 3.12 KB

MERN URL Shortener

Motivation

In order to learn about the MERN Stack and Back-End development I decided to build a URL Shortener Server.

Getting Started

Development

  1. Run just dev to start Docker Services
  2. Run the HTTP Server using just server
  3. Run the Front-End using just client in a separate terminal

Spec

The following section describes the server solution architecture and available endpoints.

REST API

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 API

Links

Public links usage

Method Path Description πŸ”
GET /:slug Redirects user to actual link (if exists). βž–

Private API

Authentication

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. βœ…

User Managent

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-Link Managent

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. βœ…

Entities

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.

User

Property Data Type Description πŸ‘οΈ
name String User's name. βœ…
surname String User's surname. βœ…
email 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. βœ…

Link

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. βœ…

Link History Item

TODO

License

MIT Licensed Β© David Alejandro RodrΓ­guez 2024