Skip to content

feat: update next backend #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
99e26ab
feat: update next backend
May 31, 2025
9bca8b8
fix: authorization logic
May 31, 2025
6bfd00e
chore: update docker
imrim12 May 31, 2025
5b26f8b
chore: update example env
imrim12 May 31, 2025
7f2a227
feat: add api folder
imrim12 May 31, 2025
dca3d57
chore: remove redundant store
imrim12 Jun 8, 2025
f6568be
fix: auth redirect
imrim12 Jun 8, 2025
e753e2b
chore: bump version
imrim12 Jun 9, 2025
57c9a05
fix: account settings page
buituananhdev Jun 9, 2025
9a8aa1e
Merge pull request #63 from thecodeorigin/feat/update-next-backend-ac…
buituananhdev Jun 9, 2025
f820ff1
feat: fix notifications API and UI integration
buituananhdev Jun 9, 2025
c016939
Merge pull request #62 from thecodeorigin/feat/update-next-backend-no…
buituananhdev Jun 9, 2025
1250571
chore: bump version
imrim12 Jun 9, 2025
f9e90ef
feat: credit base payment use sepay (#64)
huynamboz Jun 10, 2025
f7386f9
chore: bump version to 1.12.0-rc.3
buituananhdev Jun 12, 2025
a8d52b8
Merge pull request #65 from thecodeorigin/chore/bump-version-1.12.0-rc.3
buituananhdev Jun 12, 2025
983baa8
feat: add reference logic
buituananhdev Jun 12, 2025
921b618
fix: change logic isReferenceUsableByUser base on quantity of ref
buituananhdev Jun 12, 2025
2f8aecd
Merge pull request #66 from thecodeorigin/feat/update-next-backend-re…
buituananhdev Jun 12, 2025
68ff09a
fix: using wrong toast (#67)
huynamboz Jun 12, 2025
2d03b3e
feat: add reference to order
buituananhdev Jun 12, 2025
96f2634
Merge pull request #68 from thecodeorigin/feat/update-next-backend-re…
buituananhdev Jun 12, 2025
81607b3
fix: change from get unused to get available ref
buituananhdev Jun 13, 2025
a0fe7a7
Merge pull request #69 from thecodeorigin/feat/update-next-backend-re…
buituananhdev Jun 13, 2025
0b34da6
chore: bump version to 1.12.0-rc.6
buituananhdev Jun 13, 2025
73ac9dd
Merge pull request #70 from thecodeorigin/chore/bump-version-1.12.0-rc.6
buituananhdev Jun 13, 2025
fd74718
feat: references usage history UI and affiliate share
buituananhdev Jun 14, 2025
f9d5471
Merge pull request #71 from thecodeorigin/feat/reference
buituananhdev Jun 14, 2025
73513c5
fix: align avatar and information on the same row
buituananhdev Jun 14, 2025
2c542c7
Merge pull request #72 from thecodeorigin/feat/account-settings
buituananhdev Jun 14, 2025
1878a1b
chore: bump version to 1.12.0-rc.7
buituananhdev Jun 14, 2025
05808f6
Merge pull request #73 from thecodeorigin/chore/bump-version-1.12.0-rc.7
buituananhdev Jun 14, 2025
cc7df47
feat: use upstash redis
imrim12 Jun 23, 2025
8491918
fix: missing upstash creds
imrim12 Jun 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
AUTH_MAX_AGE="2592000"

AWS_CLOUDFRONT_DOMAIN=

AWS_S3_ACCESS_KEY=
AWS_S3_BUCKET="nuxt-template"
AWS_S3_REGION=
Expand Down Expand Up @@ -30,15 +31,16 @@ GOOGLE_CLIENT_SECRET=
LOGTO_APP_ID=
LOGTO_APP_SECRET=
LOGTO_COOKIE_ENCRYPTION_KEY=
LOGTO_ENDPOINT=""
LOGTO_ENDPOINT="https://auth.thecodeorigin.com"

LOGTO_ADMIN_APP_ID=""
LOGTO_ADMIN_APP_SECRET=""

MONGODB_COLLECTION_NAME="nuxt-template-cache"
MONGODB_CONNECTION_STRING=
MONGODB_CONNECTION_STRING="mongodb://root:password@localhost:27017/nuxt-template?authSource=admin"
MONGODB_DATABASE_NAME="nuxt-template"

NUXT_APP_CDN_URL=""
NUXT_PUBLIC_API_BASE_URL="http://localhost:3000"
NUXT_PUBLIC_APP_BASE_URL="http://localhost:3000"
NUXT_PUBLIC_APP_NAME="nuxt-template"
Expand All @@ -52,9 +54,9 @@ POSTGRES_PASSWORD="postgres"
POSTGRES_PORT="54321"
POSTGRES_USER="postgres"

REDIS_HOST=
REDIS_PASSWORD=
REDIS_PORT=
REDIS_HOST="localhost"
REDIS_PASSWORD="secret"
REDIS_PORT="6379"
REDIS_USER="default"

SMTP_FROM="[email protected]"
Expand All @@ -70,14 +72,15 @@ STRIPE_PUBLISHABLE_KEY=
STRIPE_SECRET_KEY=
STRIPE_WEBHOOK_SECRET=

VERCEL_ORG_ID=
VERCEL_PROJECT_ID=
VERCEL_TOKEN=

VNPAY_DISABLE_TEST_MODE=
VNPAY_HASHSECRET=
VNPAY_TMNCODE=

PAYOS_CLIENT_ID=
PAYOS_API_KEY=
PAYOS_CHECKSUM_KEY=

SEPAY_WEBHOOK_SIGNING_KEY=
SEPAY_BANK_NUMBER=
SEPAY_BANK_NAME=
SEPAY_TRANSACTION_PREFIX=
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@ public/mockServiceWorker.js
# Ignore the build directory
public/firebase-config.json

docker/postgres
docker/redis

server/db/schemas/cjs
server/db/schemas/mjs

server/db/migrations

areas
docker
13 changes: 1 addition & 12 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"extends": [
"stylelint-config-standard-scss",
"stylelint-config-idiomatic-order",
"@stylistic/stylelint-config"
],
"plugins": [
"@stylistic/stylelint-plugin"
"stylelint-config-idiomatic-order"
],
"overrides": [
{
Expand All @@ -22,13 +18,6 @@
}
],
"rules": {
"@stylistic/max-line-length": [
220,
{
"ignore": "comments"
}
],
"@stylistic/indentation": 2,
"selector-class-pattern": null,
"color-function-notation": null,
"annotation-no-unknown": [
Expand Down
69 changes: 37 additions & 32 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,42 +1,47 @@
# Step 1: Base image for building
FROM node:22-bullseye-slim AS build
# Step 2: Set working directory
# Dockerfile
# Production-grade Dockerfile for Nuxt 3 with PNPM and Node 22 Alpine, multi-stage build
# --- Stage 1: Base Image Setup ---
FROM node:22-alpine AS base

# Set working directory
WORKDIR /app
# Step 3: Install dependencies for pnpm
RUN npm install -g [email protected] # Ensure a specific version of pnpm
# Step 4: Copy application files

# --- Stage 2: Dependencies Installation ---
FROM base AS builder

# Install pnpm globally
RUN npm install -g pnpm@latest

COPY scripts/ ./scripts
COPY .npmrc ./
COPY .nuxtignore ./
COPY package*.json ./
COPY pnpm-*.yaml ./
COPY *.config.ts ./
COPY tsconfig.json ./
COPY package.json package.json
COPY public/ ./public
COPY . .
# Step 5: Clean up old node_modules (if any) and install dependencies
RUN rm -rf node_modules && pnpm install
# Step 6: Build the application
RUN pnpm build
# Step 7: Use a smaller image for production
FROM node:22-bullseye-slim AS prod
# Step 8: Set working directory
WORKDIR /app
# Step 9: Install required packages (curl needed for AWS CLI)
RUN apt-get update && apt-get install -y curl unzip
# Step 10: Install pnpm (again) to ensure it's available in the production environment
RUN npm install -g [email protected] # Ensure the same version of pnpm
# Step 11: Copy built application from build stage
COPY --from=build /app /app
# Step 12: Remove unnecessary dev dependencies

# Install dependencies
RUN pnpm install
# Step 13: Install AWS CLI
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \
&& unzip awscliv2.zip \
&& ./aws/install \
&& rm -rf awscliv2.zip aws
# Step 14: Expose port 3000
RUN NODE_OPTIONS="--max-old-space-size=4096" pnpm build

FROM node:22-alpine AS production

# Set working directory
WORKDIR /app

RUN apk add --no-cache curl

# Copy the .output directory from the builder stage
COPY --from=builder /app/.output ./.output

COPY --from=builder /app/.env ./.env

ENV NITRO_HOST=0.0.0.0
ENV NITRO_PORT=3000

EXPOSE 3000
# Step 15: Push output files to S3 before starting the application
CMD aws s3 sync /app/.output s3://$AWS_S3_BUCKET
# Step 16: Start the application
CMD ["pnpm", "start"]

# Command to run the Nuxt application
CMD ["node", ".output/server/index.mjs"]
4 changes: 1 addition & 3 deletions app/@core/scss/base/skins/_bordered.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ $header: ".layout-navbar";
.layout-nav-type-vertical.window-scrolled #{$header} {
border-block-start: none !important;
}
}
// stylelint-disable-next-line @stylistic/indentation
@else {
} @else {
@include mixins.bordered-skin(".layout-nav-type-vertical.window-scrolled.layout-navbar-sticky #{$header}", "border-bottom");
}

Expand Down
32 changes: 20 additions & 12 deletions app/@layouts/components/NavBarNotifications.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<script lang="ts" setup>
import { formatDistanceToNow } from '#imports'
import { useEventBus } from '@vueuse/core'

type Notification = any

const systemNotificationStore = useNotificationStore()
const notificationApi = useApiNotification()
const emptyNotification = ref(false)
const location = ref('bottom end' as const)
const badgeProps = ref<object>({})
Expand All @@ -16,20 +17,24 @@ const notificationQuery = ref({
})
const notifications = ref<Notification[]>([])
const notificationVisible = ref(false)
const notificationUpdatedBus = useEventBus('notification-updated')

const { data, refresh: fetchNotifications } = await useLazyAsyncData(() => systemNotificationStore.fetchNotifications(notificationQuery.value), {
const { data, refresh: fetchNotifications } = useLazyAsyncData(() => notificationApi.fetchNotifications(notificationQuery.value), {
default: () => ([] as Notification[]),
})
notifications.value.push(...data.value)

const { data: unreadNotifications, refresh: fetchUnreadNotifications } = await useLazyAsyncData(() => systemNotificationStore.countUnreadNotifications(), {
if (Array.isArray(data.value)) {
notifications.value.push(...data.value)
}

const { data: unreadNotifications, refresh: fetchUnreadNotifications } = useLazyAsyncData(() => notificationApi.countUnreadNotifications(), {
default: () => ({ total: 0 }),
})
const { refresh: markAllUnread } = await useLazyAsyncData(() => systemNotificationStore.markAllUnread(), {
const { refresh: markAllUnread } = useLazyAsyncData(() => notificationApi.markAllUnread(), {
default: () => ({}),
immediate: false,
})
const { refresh: markAllRead } = await useLazyAsyncData(() => systemNotificationStore.markAllRead(), {
const { refresh: markAllRead } = useLazyAsyncData(() => notificationApi.markAllRead(), {
default: () => ({}),
immediate: false,
})
Expand All @@ -47,7 +52,9 @@ async function fetchMoreNotifications({ done }: { done: (type: 'ok' | 'empty' |
notificationQuery.value.page++

await fetchNotifications()
notifications.value.push(...data.value)
if (Array.isArray(data.value)) {
notifications.value.push(...data.value)
}

if (!data || data.value?.length === 0) {
emptyNotification.value = true
Expand All @@ -63,7 +70,7 @@ async function fetchMoreNotifications({ done }: { done: (type: 'ok' | 'empty' |

async function removeNotification(notificationId: string) {
try {
await systemNotificationStore.deleteNotification(notificationId)
await notificationApi.deleteNotification(notificationId)

notifications.value.forEach((item, index) => {
if (notificationId === item.id) {
Expand All @@ -79,10 +86,10 @@ async function removeNotification(notificationId: string) {
async function handleNotificationClick(notification: Notification) {
try {
if (!notification.read_at) {
await systemNotificationStore.markRead(notification.id)
await notificationApi.markRead(notification.id)
}
else {
await systemNotificationStore.markUnread(notification.id)
await notificationApi.markUnread(notification.id)
}

for (const item of notifications.value) {
Expand All @@ -92,6 +99,7 @@ async function handleNotificationClick(notification: Notification) {
}
}
fetchUnreadNotifications()
notificationUpdatedBus.emit(notification)
}
catch (error) {
console.error(error)
Expand All @@ -103,10 +111,10 @@ const isAllMarkRead = computed(() => unreadNotifications.value.total === 0)
async function handleMarkAllReadOrUnread() {
try {
if (isAllMarkRead.value) {
markAllUnread()
await markAllUnread()
}
else {
markAllRead()
await markAllRead()
}
notifications.value.forEach((item) => {
item.read_at = !isAllMarkRead.value ? new Date().toDateString() : null
Expand Down
41 changes: 0 additions & 41 deletions app/@layouts/components/NavbarShortcuts.vue

This file was deleted.

28 changes: 13 additions & 15 deletions app/@layouts/components/UserProfile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@ import { PerfectScrollbar } from 'vue3-perfect-scrollbar'

const { t } = useI18n()
const authStore = useAuthStore()
const tokenDeviceStore = useTokenDeviceStore()
const userEmail = computed(() => authStore.currentUser?.email)
const userAvatar = computed(() => authStore.currentUser?.picture)
const userEmail = computed(() => authStore.currentUser?.primary_email)
const userAvatar = computed(() => authStore.currentUser?.avatar)
const userFullname = computed(() => authStore.currentUser?.name)
const userRole = computed(() => authStore.currentUser?.roles?.[0] || authStore.currentUser?.organization_roles?.[0] || t('User'))

async function logout() {
try {
if (authStore.currentUser)
await tokenDeviceStore.clearTokenDevice()
const referCode = useCookie('referCode')
referCode.value = null

await authStore.signOut()
await navigateTo({ path: '/sign-out' }, { external: true })

navigateTo({ name: 'auth-login' })
}
Expand Down Expand Up @@ -51,12 +49,12 @@ const userProfileList = computed<Array<{
title: t('Pricing'),
to: { name: 'settings-pricing' },
},
{
type: 'navItem',
icon: 'ri-question-line',
title: 'FAQ',
to: { name: 'faq' },
},
// {
// type: 'navItem',
// icon: 'ri-question-line',
// title: 'FAQ',
// to: { name: 'faq' },
// },
])
</script>

Expand Down Expand Up @@ -114,8 +112,8 @@ const userProfileList = computed<Array<{
<div class="text-body-2 font-weight-medium text-high-emphasis">
{{ userFullname || userEmail }}
</div>
<div class="text-capitalize text-caption text-disabled">
{{ userRole }}
<div class="text-caption text-disabled">
{{ userEmail }}
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ const config = useRuntimeConfig()
<NavBarI18n />

<NavbarThemeSwitcher />
<NavbarShortcuts />
<NavBarNotifications class="me-2" />
<!-- <NavBarNotifications class="me-2" /> -->
<UserProfile />
</template>

Expand Down
Loading