Git Product home page Git Product logo

assessment's Introduction

Album assessment

Web application that allows users to browse and interact with a collection of albums and photos. I leveraged Next.js for server-side rendering and API routes, and MongoDB for data persistence. Users can view user profiles, browse albums, and view photos within each album.

Table of Contents

Installation

  1. Clone the repository:

    git clone https://github.com/jkitsao/assessment.git

  2. Navigate to the project directory:

    cd assessment

  3. Install dependencies:

    yarn

API Routes Documentation

Next.js has built-in API routes, which allowed me to create serverless functions to handle backend logic. These API routes serve as endpoints for the application, enabling me to perform operations such as fetching data from a database, processing form submissions, or integrating with third-party services.

Users API

  • GET /api/users: Retrieve all users.
  • GET /api/users/:userId: Retrieve a specific user by ID.

Albums API

  • GET /api/albums: Retrieve all albums.
  • GET /api/albums/:userId: Retrieve albums by user ID.

Photos API

  • GET /api/albums/info/:albumId: Retrieve album information by album ID.
  • GET /api/photos/album-photo: Retrieve photos by album ID.

Custom Hooks

I used A Custom Hook to abstract away the implementation details of data fetching and state management, making our code more modular, reusable, and easier to understand.

useUser(userId)

A custom hook to fetch user details by ID.

import { useUser } from "./hooks/useFetch";

const { user, loading, error } = useUser(userId);

useAlbumPhotos(albumId)

A custom hook to fetch photos of a specific album.

import { useAlbumPhotos } from "./hooks/useFetch";

const { album, loading, error } = useAlbumPhotos(albumId);

usePhotos()

A custom hook to fetch all photos.

import { usePhotos } from "./hooks/useFetch";

const { photos, loading, error } = usePhotos();

Test: HomePage Component

This test suite verifies the behavior of the Home Page, ensuring that it behaves correctly under different authentication statuses.

The next-auth/react module is mocked to simulate different authentication statuses using the useSession hook. The next/router

Running Tests

Run Jest tests using the following command:

yarn test

assessment's People

Contributors

jkitsao avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.