Skip to content

Commit 5d57c5c

Browse files
authored
Migrate to Nuxt.js (#15)
* Add initial project setup with Nuxt, including layout components, routing, and styles; remove unused files * Implement login/logout functionality and update header for authentication state; remove unused cookie utility * Remove unused cookTimeIcon constant from RecipeCard component * Refactor RecipeCard component to destructure recipe prop from defineProps * Re-add GitHub Actions workflow for Super Linter to re-enforce code quality * Wrap login text in a div for improved structure in login.vue * Improve indentation for better readability in Header.vue * Update Super Linter configuration and enhance README structure * Implement authentication forms with toggle between login and registration * Enhance authentication forms with v-model binding and submit handling for login and registration * Implement login and registration enhancements with session cookie management and redirection * Disable SSR * Add instructions for generating static hosting builds in README * Improve recipe fetching error handling and loading states in index.vue * Enhance contact page with improved layout and GitHub link * Refactor registration component to redirect to the login page after successful registration * Refactor login component to use Composition API and improve error handling * Refactor styles to use CSS variables for colors, typography, and spacing * Update color variables and improve component styles for consistency * Add secondary color to footer styles for improved visibility * Remove unused styles * Enhance registration form with password visibility SVG icons * Enhance password input fields with visibility toggle functionality * Add SVG icons to header navigation for improved UI * Update header styles to enhance text visibility and weight * Remove unused background properties * Enhance main layout with custom scrollbar styles for improved aesthetics * Update main width to 100% for some reason * Update main overflow property for improved scrolling behavior * Refactor API endpoints to use runtime configuration for improved flexibility * Add .dockerignore and update .gitignore to include lock file * Add .gitattributes to ignore diffs for package-lock.json * Refactor Dockerfile to implement multi-stage builds for simplified Nuxt.js app deployment * Update .dockerignore to include Nuxt.js build outputs and additional local files * Update README.md to clarify local development setup with Nuxt.js and Docker * Refactor recipe list rendering in index.vue for improved semantics and styling * Refactor index.vue template structure for improved readability and layout * Implement search functionality for recipes and enhance loading spinner management * Remove unused watch function * Refactor main layout in index.vue for improved alignment and spacing * Remove unused text-wrap property from main style in index.vue * Implement search bar component and refactor search functionality in index.vue * Fix font size in SearchBar component * Remove unnecessary blank line in README.md * Refactor LoadingSpinner styles for improved readability and consistency * Add recipe detail and index pages; update navigation and clean up imports * Update Dockerfile to use slimmer base images * Add GitHub Actions workflow to scan Docker images for vulnerabilities * Remove unnecessary triggers and permissions from workflow configuration files * Update Trivy action version in Docker image scanning workflow * Fix Trivy action version format in Docker image scanning workflow * Refactor GitHub Actions workflows to enhance Docker image scanning and update permissions * Update workflow triggers to only run on pushes to the main branch * Fix workflow trigger configuration to support multiple branches for Docker image scanning * Update Docker image scanning workflow to use Trivy in repo mode * Add permissions for GitHub Actions to enhance security event reporting * Update Docker image scanning workflow to output results in table format and adjust exit code * Refactor Docker image scanning workflow to remove 'ignore-unfixed' option and output results to 'table.txt' * Remove output specification from Docker image scanning workflow * Remove Trivy because it's useless, I expected a report table and got nothing * Refactor footer and header components for improved rendering and update app title format * Update page titles dynamically * Refactor authentication components to destructure apiBaseUrl from runtime config * Refactor recipe details display into a separate Recipe component * Refactor Recipe component layout for improved structure and styling * Enhance responsive design for Recipe component and details page * Refactor Recipe component layout and styles for improved readability and responsiveness; add custom scrollbar styles * Enhance Recipe component to dynamically fetch and display recipe images; add error handling for image loading * Add ButtonHome component for navigation; update Header and Recipe index to use new component * Refactor layout and styles for improved responsiveness; update section IDs and add media queries for better mobile support * Add Comment component and integrate comments fetching in Recipe component; refactor recipe fetching logic in index page * Refactor recipe fetching logic in index page; update API endpoint and add initial fetch on component mount
1 parent 8195c87 commit 5d57c5c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+10950
-1063
lines changed

.dockerignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Nuxt dev/build outputs
2+
.output
3+
.data
4+
.nuxt
5+
.nitro
6+
.cache
7+
dist
8+
9+
# Node dependencies
10+
node_modules
11+
12+
# Logs
13+
logs
14+
*.log
15+
16+
# Misc
17+
.DS_Store
18+
.fleet
19+
.idea
20+
21+
# Local env files
22+
.env
23+
.env.*
24+
!.env.example

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Ignore diffs for package-lock.json
2+
package-lock.json diff=none

.github/workflows/super-linter.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,14 @@ jobs:
3131
env:
3232
# To report GitHub Actions status checks
3333
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34-
VALIDATE_ALL_CODEBASE: false
34+
VALIDATE_ALL_CODEBASE: true
3535
VALIDATE_CSS_PRETTIER: false
3636
VALIDATE_HTML_PRETTIER: false
3737
VALIDATE_JAVASCRIPT_STANDARD: false
3838
VALIDATE_JAVASCRIPT_PRETTIER: false
3939
VALIDATE_JSON_PRETTIER: false
4040
VALIDATE_YAML_PRETTIER: false
41+
VALIDATE_JSON: false
42+
VALIDATE_TYPESCRIPT_PRETTIER: false
43+
VALIDATE_TYPESCRIPT_STANDARD: false
44+
VALIDATE_VUE_PRETTIER: false

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Nuxt dev/build outputs
2+
.output
3+
.data
4+
.nuxt
5+
.nitro
6+
.cache
7+
dist
8+
9+
# Node dependencies
10+
node_modules
11+
12+
# Logs
13+
logs
14+
*.log
15+
16+
# Misc
17+
.DS_Store
18+
.fleet
19+
.idea
20+
21+
# Local env files
22+
.env
23+
.env.*
24+
!.env.example

Dockerfile

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
1-
# Use the latest nginx as the base image
2-
FROM nginx:1.27.3
1+
# Stage 1: Build the Nuxt.js app
2+
FROM node:18.20-slim AS build-stage
3+
4+
# Set the working directory
5+
WORKDIR /app
6+
7+
# Copy package.json and package-lock.json
8+
COPY package*.json ./
9+
10+
# Install dependencies
11+
RUN npm install
12+
13+
# Copy the rest of the application code
14+
COPY . .
15+
16+
# Build the application for static hosting
17+
RUN npm run generate
18+
19+
# Stage 2: Serve the static files using Nginx
20+
FROM nginx:1.24-alpine-slim
321

422
# Set environment variables
523
ENV TEMP_FRONTEND_DIR=/temp-frontend-files
624

7-
# Set the shell for safer execution
8-
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
9-
1025
# Create a non-root user and group
11-
RUN groupadd -r frontenduser && useradd -r -g frontenduser frontenduser
26+
RUN addgroup -S frontenduser && adduser -S -G frontenduser frontenduser
1227

1328
# Create a directory for the PID file and assign ownership to frontenduser
1429
RUN mkdir -p /var/run/nginx && chown -R frontenduser:frontenduser /var/run/nginx
1530

16-
# Copy all files to the container
17-
COPY . /usr/share/nginx/html
31+
# Copy the generated static files from the build stage
32+
COPY --from=build-stage /app/dist /usr/share/nginx/html
1833

1934
# Copy nginx.conf to a writable location and modify the PID path
2035
RUN cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.custom && \

README.md

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,50 @@
1-
# Nginx HTTP web server
1+
# Nginx HTTP Web Server
22

3-
This repository contains the frontend for smartcooking.
3+
This repository contains the frontend for SmartCooking.
44

55
## Getting Started
66

7-
To set up the frontend locally, you'll need Docker installed. Follow the steps below to build and run the database in a container.
7+
### Nuxt Minimal Development Server
88

9-
### Setup Steps
9+
- To develop the frontend locally, you'll need Nuxt.js installed. Follow the steps below to develop the frontend with Nuxt.js.
10+
11+
1. Install the dependencies:
12+
13+
```bash
14+
# npm
15+
npm install
16+
17+
# pnpm
18+
pnpm install
19+
20+
# yarn
21+
yarn install
22+
23+
# bun
24+
bun install
25+
```
26+
27+
2. Start the development server on `http://localhost:3000`:
28+
29+
```bash
30+
# npm
31+
npm run dev
32+
33+
# pnpm
34+
pnpm dev
35+
36+
# yarn
37+
yarn dev
38+
39+
# bun
40+
bun run dev
41+
```
42+
43+
Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
44+
45+
### Docker image and Container and hosting with Nginx
46+
47+
To set up the frontend locally, you'll need Docker installed. Follow the steps below to build and run the frontend in a container.
1048

1149
1. **Build the Docker Image**:
1250

@@ -20,5 +58,5 @@ To set up the frontend locally, you'll need Docker installed. Follow the steps b
2058
docker run -d --name Smart-Cooking_Frontend -p 8080:80 smartcooking-nginx
2159
```
2260

23-
3. **Access the site**
24-
Open your brower and access `http://localhost:8080/`
61+
3. **Access the Site**:
62+
Open your browser and access `http://localhost:8080/`.

app.vue

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<template>
2+
<div class="layout">
3+
<Header />
4+
<NuxtPage />
5+
<Footer />
6+
<LoadingSpinner class="hidden" />
7+
</div>
8+
</template>
9+
10+
<style scoped>
11+
.layout {
12+
align-items: center;
13+
display: flex;
14+
flex-direction: column;
15+
gap: var(--spacing-large);
16+
height: 100svh;
17+
justify-content: center;
18+
width: 100%;
19+
}
20+
21+
.layout > :nth-child(2) {
22+
flex: 1;
23+
overflow-y: auto;
24+
}
25+
26+
@media screen and (width<=850px) {
27+
.layout {
28+
gap: var(--spacing-small);
29+
}
30+
}
31+
</style>

assets/icons/eye-off.svg

Lines changed: 6 additions & 0 deletions
Loading

assets/icons/eye.svg

Lines changed: 6 additions & 0 deletions
Loading

assets/icons/home.svg

Lines changed: 6 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)