Link Union is a web application designed for managing links from various sources. It allows users to save links along with a name, description, and tags. The application supports user authentication, user profiles, CRUD operations for managing links, contact forms, and more.
- Installation
- Usage
- Backend Setup
- Routes
- Controllers
- Models
- Middleware
- Setting Up Development Environment
- Testing
- Contributing
- Further Help
To install Link Union locally, follow these steps:
- Clone the repository:
git clone <repository-url>
- Navigate to the project directory:
cd link-union
- Install dependencies:
npm install
ornpm i
To run the Link Union backend locally, follow these steps:
- Clone the repository
- Navigate to the project directory
- Install dependencies
git clone <repository-url>
cd link-union
npm install
- Create a
.env
file in the root directory and add the necessary environment variables:
MONGO_DB_CLUSTER_URL=<your-mongodb-cluster-url>
TOKEN_SECRET_KEY=<your-secret-key>
- Ensure MongoDB is installed and running locally or provide the URL for MongoDB Atlas cluster in the
.env
file. - Start the server using the following command
npm start #starting the server
- The server will start running locally on port 5000 by default. You can access the endpoints using an API testing tool like Postman or via frontend integration.
Link Union is deployed on Render as a web service. Follow these steps to deploy:
- Build the Angular application
- Navigate to the build directory
ng build #build angular application
cd dist/link-union #navigate to directory
- Create a new file named
render.yaml
and add the following configuration:
services:
- name: link-union
type: web
buildCommand: npm install && npm run build
startCommand: npm start
Create a new Render account if you haven't already. Add a new web service on Render and specify the GitHub repository where your Link Union code is hosted. Deploy the service on Render.
-
Environment Variables: Create a
.env
file with the necessary environment variables, including MongoDB cluster URL and token secret key. -
MongoDB Setup: Ensure MongoDB Atlas cluster is set up and accessible. The cluster URL should be provided in the
.env
file. -
Middleware: Configure middleware such as CORS, cookie-parser, and express.json for handling requests.
-
Passport Configuration: Configure Passport.js for user authentication, including JWT token strategy and Google OAuth2.0 strategy.
/register
: POST request to register a new user./login
: POST request to log in a user./auth/google
: GET request for Google sign-in authentication./auth/google/callback
: GET request callback route for Google authentication.
/:userId
: GET request to fetch user details by ID./:userId/delete
: DELETE request to delete a user and associated links./:userId/contact
: POST request to submit a contact form.
/:userId/add-link
: POST request to add a new link for a user./:userId/links/:linkId
: GET request to fetch a specific link by ID./:userId/links
: GET request to fetch all links associated with a user./:userId/delete-link/:linkId
: DELETE request to delete a specific link./:userId/delete-all-links
: DELETE request to delete all links associated with a user./:userId/edit-link/:linkId
: PUT request to edit a specific link.
- AuthController: Handles user registration, login, and Google OAuth authentication.
- UserController: Manages user-related operations such as fetching user details, deleting users, and submitting contact forms.
- LinkController: Controls link-related operations including adding, fetching, deleting, and editing links.
- UserModel: Defines the schema for the user collection, including fields for fullname, email, password, and links.
- LinkModel: Specifies the schema for the link collection, including fields for name, link, description, and tags.
- ContactModel: Defines the schema for the contact form collection, including fields for subject, description, and userId.
- Authorization Middleware:
authorize
middleware function to verify JWT tokens and authenticate users.
- Unit tests:
npm test
- End-to-end tests:
npm run e2e
Contributions to Link Union are welcome! To contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature/my-feature
). - Make your changes and commit them (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature/my-feature
). - Create a new pull request.
For more information on using Angular CLI, refer to the Angular CLI Overview and Command Reference page.