Skip to content

An API designed for shortening URLs and ranking those more clicked.

License

Notifications You must be signed in to change notification settings

erickssguerra/projeto17-shortly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

projeto17-shortly

  • An API designed for shortening URLs and ranking the most viewed ones.
🛠 Tools and technologies
- Node.js
- Express
- Postgres
🗂 Folders organization
    📂 src
    ├── 📂 controllers
    │   ├── sessions.controllers.js
    │   ├── urls.controllers.js
    │   └── users.controllers.js
    ├── 📂 database
    │   └── database.js
    ├── 📂 middlewares
    │   ├── authValidation.middleware.js
    │   ├── 📂 sessions
    │   │   └── sessionSignInValidation.middleware.js
    │   ├── 📂 urls
    │   │   ├── urlExistingId.middleware.js
    │   │   ├── urlExistingShortUrl.middleware.js
    │   │   ├── urlIsUserAuthor.middleware.js
    │   │   └── urlSchemaValidation.middleware.js
    │   └── 📂 users
    │       ├── userExistingEmail.middleware.js
    │       └── userSchemaValidation.middleware.js
    ├── 📂 repositories
    │   ├── sessionsRepositories.js
    │   ├── urlsRepositories.js
    │   └── usersRepositories.js
    ├── 📂 routes
    │   ├── router.js
    │   ├── sessions.routes.js
    │   ├── urls.routes.js
    │   └── user.routes.js
    ├── 📂 schemas
    │   ├── url.schema.js
    │   └── user.schema.js
    └── server.js
🧭 Routes
  • post("/signup")

    • send body in the format

       {
       "name": "erick",
       "email": "[email protected]",
       "password": "12345",
       "confirmPassword": "12345"
       }
      
  • post("/signin")

  • post("/urls/shorten")

    • send a token authorization via headers

        {
        "authorization": "Bearer token"
        }
      
    • send body in the format

       {
       "url": "http:https://www.linkedin.com/in/erickssguerra"
       }
      
  • get("/urls/:id")

    • send an id via params
    • get a body object
        {
        "id": "24",
        "shortUrl": "12%af#",
        "url": "http:https://www.linkedin.com/in/erickssguerra
        }
      
  • get("/urls/open/:shortUrl")

    • send a shortUrl via params
    • user is redirected to the original Url
  • delete("/urls/:id")

    • send an id via params
    • send user authorization via header
    • erase the url from the database
  • get("/users/me")

    • send the authorization via params
    • get a body object
       {
        "id": 3,
        "name": "Erick",
        "visitCount": 0,
        "shortenedUrls": [
           {
            "id": 28,
            "shortUrl": "Gyk-ov",
            "url": "http:https://www.linkedin.com/in/erickssguerra",
            "visitCount": 0
          },
          {
            "id": 29,
            "shortUrl": "O7sAt0",
            "url": "https://www.github.com/erickssguerra",
            "visitCount": 0
          }
        ]
      }
      
  • get("/ranking")

    • get a body object limited by the top 10

      [
        {
          "id": 1,
          "name": "Erika",
          "linksCount": "1",
          "visitCount": "10"
        },
        {
          "id": 4,
          "name": "Berg",
          "linksCount": "1",
          "visitCount": "1"
        },
        {
          "id": 3,
          "name": "Erick",
          "linksCount": "2",
          "visitCount": "0"
        }...
      ]
      
🎁 Features
  • validation of object schemas
  • validation of existing params
  • encrypt password
  • log of each middleware and controllers
  • repositories of Postgres queries
  • one single query priorizing

About

An API designed for shortening URLs and ranking those more clicked.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published