This project implements a URL shortener using NestJS. It includes user authentication using the passport-local strategy and allows users to generate short codes for long URLs.
This document has been authored by referencing the content provided in the backendinfo.txt file. For more comprehensive information about the project, kindly consult the aforementioned file.
- NestJS
- Passport (passport-local strategy)
- express-session
- nanoid (optional)
-
Clone the repository:
git clone https://github.com/paulaji/authenticated-urlshortener-nestjs.git
-
Navigate to the project directory:
cd your-url-shortener
-
Install project dependencies:
npm install
npm run start:dev
npm run start
Use the links given below in the Notable URLs category
The project follows a modular structure, including modules, services, guards, strategies, and more.
-
Main:
- http://localhost:3000/login - Login page
-
Postman:
- http://localhost:3000/login - Use Postman or similar agent to POST and confirm login
- http://localhost:3000/protected - After login using Postman or similar agent, this URL is available for access
-
Browser:
- http://localhost:3000/ - URL shortener accessed via browser (bypass the login)
- http://localhost:3000/login - Login form accessed via browser
For testing purposes, three users are created with the usernames: user1, user2, and user3. The password for all is "resu321321".
The URL shortening logic includes taking the long url and clipping it into a small one with randomly generated characters and mapping the short-url to the long one. (Optional) The URL shortening logic can also use the nanoid library to generate short codes for long URLs.
The frontend is served by the backend and provides access to the URL shortener.
Session management is implemented using express-session
with the secret set as "resu321321". User serialization is handled to store user information in sessions.
- The project uses
@nestjs/serve-static
to serve static files. - For production use, consider using modules like
node.bcrypt.js
for password hashing.
Project created by Paul Aji (https://github.com/paulaji)
This project is licensed under the MIT License.
Programming Assistance: Documentations, Youtube, ChatGPT Text/Document Refactoring: ChatGPT Aesthetic/UI Support: ChatGPT