Compare commits

..

93 Commits

Author SHA1 Message Date
louiscklaw
ebc8a81641 "add docker compose up/down scripts and update vite config for production environment" 2025-06-11 18:49:28 +08:00
louiscklaw
f487427b2c "update service port configuration and docker setup" 2025-06-11 12:37:22 +08:00
louiscklaw
cc4d035f97 update documentation, 2025-06-08 22:26:41 +08:00
louiscklaw
84b223ff60 update, 2025-06-08 19:08:45 +08:00
louiscklaw
fca048074e update public folder, 2025-06-08 19:08:41 +08:00
louiscklaw
bc35e25616 update demo-sliding-profile, 2025-06-08 19:08:01 +08:00
louiscklaw
15f8d2e6aa update demo-shop-app-ui, 2025-06-08 19:08:01 +08:00
louiscklaw
592a099f7b update demo-score-board, 2025-06-08 19:08:01 +08:00
louiscklaw
4c1b30e5c6 update demo-restaurant-finder, 2025-06-08 19:08:00 +08:00
louiscklaw
c765bb49a4 update demo-recipe-app, 2025-06-08 19:08:00 +08:00
louiscklaw
9aeb58379d update demo-react-travel-app, 2025-06-08 19:08:00 +08:00
louiscklaw
6419567005 update demo-react-tabs-menus-custom, 2025-06-08 19:07:48 +08:00
louiscklaw
e2076fe67b update demo-react-switch-tabs, 2025-06-08 19:07:48 +08:00
louiscklaw
766720e075 update demo-react-shop-ui, 2025-06-08 19:07:48 +08:00
louiscklaw
19af60c410 update demo-react-shop, 2025-06-08 19:07:48 +08:00
louiscklaw
ed95621b2f update demo-react-quotes, 2025-06-08 19:07:48 +08:00
louiscklaw
2258fd8fb9 update demo-react-overlay-hooks, 2025-06-08 19:07:48 +08:00
louiscklaw
0f674badd9 update demo-react-onboarding-ui, 2025-06-08 19:07:48 +08:00
louiscklaw
bc731ea2b8 update demo-react-notes, 2025-06-08 19:07:48 +08:00
louiscklaw
c11dba6297 update demo-react-movie-app-with-algolia, 2025-06-08 19:07:38 +08:00
louiscklaw
b9fbe4e476 update demo-react-marvel-app, 2025-06-08 19:07:38 +08:00
louiscklaw
0d844eed3f update demo-react-login, 2025-06-08 19:07:38 +08:00
louiscklaw
2862cddb6b update demo-react-lifecycles, 2025-06-08 19:07:38 +08:00
louiscklaw
55509b483c update demo-react-item-list, 2025-06-08 19:07:38 +08:00
louiscklaw
3f2ac2a285 update demo-react-hook-form-example, 2025-06-08 19:07:38 +08:00
louiscklaw
1216de4ff9 update demo-react-drawing-canvas, 2025-06-08 19:07:29 +08:00
louiscklaw
7966d8abf5 update demo-react-calculator, 2025-06-08 19:07:29 +08:00
louiscklaw
e975aebfcd update demo-react-add-to-cart, 2025-06-08 19:07:29 +08:00
louiscklaw
7f6970b183 update demo-quote-app, 2025-06-08 19:07:29 +08:00
louiscklaw
e83854ed2a update demo-quiz-app, 2025-06-08 19:07:29 +08:00
louiscklaw
6961f058df update demo-list, 2025-06-08 19:06:46 +08:00
louiscklaw
b515337acc update demo-fast-food-app, 2025-06-08 19:06:25 +08:00
louiscklaw
c732d89c34 update demo-ecommerce-example, 2025-06-08 19:06:25 +08:00
louiscklaw
2b71d06c8d update demo-dictionary-app, 2025-06-08 19:06:25 +08:00
louiscklaw
3ec9d87f8b update demo-club-house, 2025-06-08 19:06:25 +08:00
louiscklaw
546fb72732 update demo-banking-ui, 2025-06-08 19:06:05 +08:00
louiscklaw
4303704753 update DemoSkeletonText, 2025-06-08 18:54:06 +08:00
louiscklaw
4bb213ef0c update DemoStickyBottomSheetExample, 2025-06-08 18:47:32 +08:00
louiscklaw
657c652657 updtae Demo2FaExample, 2025-06-08 18:40:35 +08:00
louiscklaw
5be77aae23 update DemoWeatherAppUi, 2025-06-08 16:44:59 +08:00
louiscklaw
ffbe63e421 update DemoStorageExample, 2025-06-08 16:16:40 +08:00
louiscklaw
ba1e718039 update DemoStickyBottomSheetExample, 2025-06-08 15:21:40 +08:00
louiscklaw
8b32d153db update DemoSkeletonText, 2025-06-08 15:04:56 +08:00
louiscklaw
d3e554b218 update DemoSkeletonText, 2025-06-08 11:06:30 +08:00
louiscklaw
5b10977a64 update DemoSkeletonText, 2025-06-08 11:05:39 +08:00
louiscklaw
a40b0fa4b1 update, 2025-06-08 09:20:18 +08:00
louiscklaw
a4692a7d1f update DemoReactThemeSwitcher, 2025-06-08 09:14:26 +08:00
louiscklaw
c3f680aa22 update demo-react-qr-code, 2025-06-07 10:36:15 +08:00
louiscklaw
5b680f2219 update demo-react-whatsapp-clone, 2025-06-07 10:18:28 +08:00
louiscklaw
d3d95469ea update demo-react-profile-dashboard-ui, 2025-06-07 09:41:52 +08:00
louiscklaw
04eaf91d60 update DemoReactMarvelApp, 2025-06-06 23:18:53 +08:00
louiscklaw
be571ba4db update demo-react-lifecycles, 2025-06-06 22:38:16 +08:00
louiscklaw
a6d549b2e8 update react-item-list example, 2025-06-06 22:32:08 +08:00
louiscklaw
beb1e0ae68 update react hook form example, 2025-06-06 22:27:14 +08:00
louiscklaw
b2adcff61b update canvas, 2025-06-06 22:21:22 +08:00
louiscklaw
8200e0d902 update calculator, 2025-06-06 15:00:30 +08:00
louiscklaw
731cb7500e update demo react add to cart, 2025-06-06 14:34:13 +08:00
louiscklaw
d6c87e33f0 update demo pull state, 2025-06-06 14:22:22 +08:00
louiscklaw
e4b6c5e92d update profile example, 2025-06-06 14:11:26 +08:00
louiscklaw
03782cde24 update ordering app, 2025-06-06 14:07:30 +08:00
louiscklaw
7cc6d939f5 update ordering app, 2025-06-06 14:01:03 +08:00
louiscklaw
3bcb40c5ef update kanban, 2025-06-06 13:44:21 +08:00
louiscklaw
43a285dd2c update intsagram demo, 2025-06-06 13:29:35 +08:00
louiscklaw
09a8dc539e update floating action button, 2025-06-06 13:16:31 +08:00
louiscklaw
8f75226763 update floating tab bar, 2025-06-06 13:09:59 +08:00
louiscklaw
7cfbcc1573 update fastfood, 2025-06-06 12:55:43 +08:00
louiscklaw
5234ac06cd update, 2025-06-06 12:41:25 +08:00
louiscklaw
aec59fb328 update, 2025-06-06 12:03:26 +08:00
louiscklaw
7f9b4c2224 Merge branch 'develop/mobile/update-add-demo-pages/demo-capacitor-google-maps-tutorial/trunk' into develop/mobile/update-add-demo-pages/demo-color-tutorial/troubhleshoop 2025-06-06 11:55:04 +08:00
louiscklaw
197b006df3 update, 2025-06-06 11:52:20 +08:00
louiscklaw
3692b2204b update, 2025-06-06 11:51:58 +08:00
louiscklaw
3217a8d594 update, 2025-06-06 11:50:25 +08:00
louiscklaw
d453144500 update App.tsx, 2025-06-06 11:47:14 +08:00
louiscklaw
e8d12f34e8 update, 2025-06-06 11:45:58 +08:00
louiscklaw
56d43062c9 update, 2025-06-05 14:05:24 +08:00
louiscklaw
c2a02cff77 Merge branch 'develop/mobile/update-add-demo-pages/demo-accordion-tutorial/trunk' into develop/mobile/update-add-demo-pages/demo-banking-ui/trunk 2025-06-05 13:53:46 +08:00
louiscklaw
d3ef280b20 update, 2025-06-05 13:51:25 +08:00
louiscklaw
b2e9616178 update, 2025-06-05 13:15:03 +08:00
louiscklaw
d909805283 update, 2025-06-05 11:29:42 +08:00
louiscklaw
8c46a93e61 "chore: update Prettier config, upgrade dependencies including swiper and pigeon-maps, adjust print width settings" 2025-06-05 10:56:02 +08:00
louiscklaw
82507b4b31 refactor: rename DemoRecipeApp, redesign UI with recipe categories, bookmarks, and detailed recipe views 2025-06-04 18:31:12 +08:00
louiscklaw
85651ff204 "refactor: rename DemoWeatherApp to DemoDictionaryApp, update UI components, add favourites tab, and enhance search functionality" 2025-06-04 18:08:28 +08:00
louiscklaw
9caca30e1e update demo-dictionary-app, 2025-06-04 18:04:47 +08:00
louiscklaw
d76d43d17f "chore: add barcode scanner and clipboard plugins, update dev script to use yarn, and add new demo pages" 2025-06-04 17:48:04 +08:00
louiscklaw
dff07ddcb0 update adding demo app, 2025-06-04 14:46:31 +08:00
louiscklaw
b78709db9b "feat: enhance user authentication flow with loading state, improved reducer handling, and login/logout actions" 2025-06-04 11:31:36 +08:00
louiscklaw
df9992454b chore: update workspace settings structure 2025-06-04 02:35:48 +08:00
louiscklaw
22fb620eef "chore: update frontend dev script to include lint checks and add ESLint config file" 2025-06-04 02:35:32 +08:00
louiscklaw
c0fad42f0a update, 2025-06-04 02:35:19 +08:00
louiscklaw
c2c6181332 "feat: update service implementations with new features and structural changes" 2025-06-04 02:35:14 +08:00
louiscklaw
99239c32a5 "feat: refactor API handlers to use services, add logging, and improve security checks" 2025-06-04 02:35:05 +08:00
louiscklaw
ef0c0ab389 "feat: add Student model and migrate user-related data to UserMeta model, update schema and seed data" 2025-06-04 02:34:50 +08:00
louiscklaw
7610d80005 "feat: update data APIs to fetch orders and events via fetch instead of axios, add Order and Event models, update selectors and reducers, add EventDetail page with joined members display" 2025-06-03 17:04:11 +08:00
1273 changed files with 151055 additions and 7826 deletions

View File

@@ -77,12 +77,12 @@ const Chat = () => {
const [toastMessage, setToastMessage] = useState("");
// Refs
const contentRef = useRef();
const contentRef = useRef(null);
const swiperRefs = useRef([]);
const textareaRef = useRef();
const sideRef = useRef();
const sendRef = useRef();
const replyToAnimationRef = useRef();
const textareaRef = useRef(null);
const sideRef = useRef(null);
const sendRef = useRef(null);
const replyToAnimationRef = useRef(null);
const actionSheetButtons = [
{
@@ -104,7 +104,7 @@ const Chat = () => {
icon: alertOutline,
handler: () =>
toaster(
"I haven't implemented unsend :) Simple store update though",
"I haven't implemented unsend :) Simple store update though"
),
},
{
@@ -165,11 +165,11 @@ const Chat = () => {
const chatMessageID = elementID.includes("chatText")
? parseInt(elementID.replace("chatText_", ""))
: elementID.includes("chatTime")
? parseInt(elementID.replace("chatTime_", ""))
: parseInt(elementID.replace("chatBubble_", ""));
? parseInt(elementID.replace("chatTime_", ""))
: parseInt(elementID.replace("chatBubble_", ""));
const chatMessage = chat.filter(
(message) => parseInt(message.id) === parseInt(chatMessageID),
(message) => parseInt(message.id) === parseInt(chatMessageID)
)[0];
setActionMessage(chatMessage);
@@ -278,7 +278,7 @@ const Chat = () => {
replyToMessage,
replyToMessage ? replyToMessage.id : false,
image,
imagePath,
imagePath
);
setMessage("");
@@ -329,7 +329,7 @@ const Chat = () => {
fill="clear"
onClick={() =>
toaster(
"As this is a UI only, video calling wouldn't work here.",
"As this is a UI only, video calling wouldn't work here."
)
}
>
@@ -352,7 +352,7 @@ const Chat = () => {
{chat.map((message, index) => {
const repliedMessage = chat.filter(
(subMessage) =>
parseInt(subMessage.id) === parseInt(message.replyID),
parseInt(subMessage.id) === parseInt(message.replyID)
)[0];
return (
@@ -360,7 +360,9 @@ const Chat = () => {
ref={(ref) => (swiperRefs.current[index] = ref)}
id={`chatBubble_${message.id}`}
key={index}
className={`chat-bubble ${message.sent ? "bubble-sent" : "bubble-received"}`}
className={`chat-bubble ${
message.sent ? "bubble-sent" : "bubble-received"
}`}
{...longPressEvent}
>
<div id={`chatText_${message.id}`}>

View File

@@ -22,7 +22,7 @@ import { useRef } from "react";
import ContactModal from "../components/ContactModal";
const Chats = () => {
const pageRef = useRef();
const pageRef = useRef(null);
const contacts = ContactStore.useState(getContacts);
const latestChats = ChatStore.useState(getChats);
@@ -43,7 +43,7 @@ const Chats = () => {
contacts
.filter((c) => c.id === chat.contact_id)[0]
.name.toLowerCase()
.includes(searchTermLower),
.includes(searchTermLower)
);
setResults(newResults);
} else {

View File

@@ -0,0 +1 @@
# Demo2FaExample

View File

@@ -0,0 +1 @@
# DemoAccordionTutorial

View File

@@ -0,0 +1 @@
# DemoBankingUi

View File

@@ -0,0 +1 @@
# DemoBlogPostUi

View File

@@ -0,0 +1 @@
# DemoCapacitorGoogleMapsTutorial

View File

@@ -0,0 +1 @@
# DemoClubHouse

View File

@@ -0,0 +1 @@
# DemoColorTutorial

View File

@@ -0,0 +1 @@
# DemoDictionaryApp

View File

@@ -0,0 +1 @@
# DemoEcommerceExample

View File

@@ -0,0 +1 @@
# DemoFacebookClone

View File

@@ -0,0 +1 @@
# DemoFastFoodApp

View File

@@ -0,0 +1 @@
# DemoFloatingTabs

View File

@@ -0,0 +1 @@
# DemoInstagramClone

View File

@@ -0,0 +1 @@
# DemoKanbanBoard

View File

@@ -0,0 +1 @@
# DemoList

View File

@@ -0,0 +1 @@
# DemoOrderingApp

View File

@@ -0,0 +1 @@
# DemoPinterestFloatingTabBar

View File

@@ -0,0 +1 @@
# DemoProfileExample

View File

@@ -0,0 +1 @@
# DemoPullstateTutorial

View File

@@ -0,0 +1 @@
# DemoQrScanner

View File

@@ -0,0 +1 @@
# DemoQuizApp

View File

@@ -0,0 +1 @@
# DemoQuoteApp

View File

@@ -0,0 +1 @@
# DemoReactAddToCart

View File

@@ -0,0 +1 @@
# DemoReactCalculator

View File

@@ -0,0 +1 @@
# DemoReactDrawingCanvas

View File

@@ -0,0 +1 @@
# DemoReactHookFormExample

View File

@@ -0,0 +1 @@
# DemoReactItemList

View File

@@ -0,0 +1 @@
# DemoReactLifecycles

View File

@@ -0,0 +1 @@
# DemoReactLogin

View File

@@ -0,0 +1 @@
# DemoReactMarvelApp

View File

@@ -0,0 +1 @@
# DemoReactMovieAppWithAlgolia

View File

@@ -0,0 +1 @@
# DemoReactNotes

View File

@@ -0,0 +1 @@
# DemoReactOnboardingUi

View File

@@ -0,0 +1 @@
# DemoReactOverlayHooks

View File

@@ -0,0 +1 @@
# DemoReactPollApp

View File

@@ -0,0 +1 @@
# DemoReactProfileDashboardUi

View File

@@ -0,0 +1 @@
# DemoReactQuotes

View File

@@ -0,0 +1 @@
# DemoReactShop

View File

@@ -0,0 +1 @@
# DemoReactShopUi

View File

@@ -0,0 +1 @@
# DemoReactSwitchTabs

View File

@@ -0,0 +1 @@
# DemoReactTabsMenusCustom

View File

@@ -0,0 +1 @@
# DemoReactThemeSwitcher

View File

@@ -0,0 +1 @@
# DemoReactTravelApp

View File

@@ -0,0 +1 @@
# DemoRecipeApp

View File

@@ -0,0 +1 @@
# DemoRestaurantFinder

View File

@@ -0,0 +1 @@
# DemoScoreBoard

View File

@@ -0,0 +1 @@
# DemoShopAppUi

View File

@@ -0,0 +1 @@
# DemoSkeletonText

View File

@@ -0,0 +1 @@
# DemoSlidingProfile

View File

@@ -0,0 +1 @@
# DemoStickyBottomSheetExample

View File

@@ -0,0 +1 @@
# DemoStorageExample

View File

@@ -0,0 +1 @@
# DemoWeatherAppUi

View File

@@ -0,0 +1,16 @@
---
tags: docker, ports
---
# REQ0180 service port schedule
## Port Usage
| Service | Host Port | Container Port | Environment | Purpose |
| ----------- | --------- | -------------- | ----------- | -------------------------------- |
| Frontend | 10001 | 8080 | All | Web application access |
| Mobile | 10004 | 3000 | All | Mobile application access |
| CMS Backend | 10002 | 7272 | All | Main API access |
| CMS Backend | 10003 | 5555 | All | Additional service access |
| Postgres | - | 5432 | Production | Database access (container only) |
| Postgres | 5432 | 5432 | Development | Database access |

View File

@@ -28,7 +28,8 @@
"db:generate": "prisma generate",
"db:push": "prisma db push --force-reset",
"db:push:w": "npx nodemon --delay 1 --watch prisma --ext \"ts,tsx,prisma\" --exec \"yarn db:push && yarn seed\"",
"db:studio": "prisma studio"
"db:studio": "prisma studio",
"db:studio:w": "npx nodemon --delay 1 --watch prisma --ext \"prisma\" --exec \"yarn db:studio\""
},
"engines": {
"node": ">=20"

View File

@@ -71,6 +71,15 @@ model VerificationToken {
@@unique([identifier, token])
}
model Student {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
//
email String @unique
metadata Json @default("{}")
}
// ----------------------------------------------------------------
// frontend/src/_mock/_user.ts
@@ -525,6 +534,7 @@ model UserCard {
totalFollowing Float
}
// `UserItem` obsoleted, use `UserMeta` instead
model UserItem {
id String @id @default(uuid())
createdAt DateTime @default(now())
@@ -550,6 +560,31 @@ model UserItem {
isAdmin Boolean @default(false)
}
model UserMeta {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
//
name String
city String
role String
email String
state String
status String
address String
country String
zipCode String
company String
avatarUrl String
phoneNumber String
isVerified Boolean
//
username String
password String
//
isAdmin Boolean @default(false)
}
model UserAccountBillingHistory {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())

View File

@@ -30,6 +30,7 @@ import { EventItemSeed } from './seeds/eventItem';
import { EventReviewSeed } from './seeds/eventReview';
import { appLogSeed } from './seeds/AppLog';
import { accessLogSeed } from './seeds/AccessLog';
import { userMetaSeed } from './seeds/userMeta';
//
// import { Blog } from './seeds/blog';
@@ -46,7 +47,10 @@ import { accessLogSeed } from './seeds/AccessLog';
await ProductReview;
await FileStore;
await ProductItem;
await userItemSeed;
await userMetaSeed;
await orderItemSeed;
await invoiceItemSeed;
//

View File

@@ -0,0 +1,130 @@
import { PrismaClient } from '@prisma/client';
import { generateHash } from 'src/utils/hash';
import { Config, names, uniqueNamesGenerator } from 'unique-names-generator';
import { faker } from '@faker-js/faker';
import { faker as enFaker } from '@faker-js/faker/locale/en_US';
import { faker as zhFaker } from '@faker-js/faker/locale/zh_CN';
import { faker as jaFaker } from '@faker-js/faker/locale/ja';
import { faker as koFaker } from '@faker-js/faker/locale/ko';
import { faker as twFaker } from '@faker-js/faker/locale/zh_TW';
const SEED_EMAIL_DOMAIN = 'seed.com';
const prisma = new PrismaClient();
async function userMeta() {
const config: Config = { dictionaries: [names] };
const firstName = uniqueNamesGenerator(config);
const lastName = uniqueNamesGenerator(config);
const username = `${firstName.toLowerCase()}-${lastName.toLowerCase()}`;
const alice = await prisma.userMeta.upsert({
where: { id: 'admin_uuid' },
update: {},
create: {
name: `admin test`,
city: '',
role: '',
email: `admin@123.com`,
state: '',
status: '',
address: '',
country: '',
zipCode: '',
company: '',
avatarUrl: '',
phoneNumber: '',
isVerified: true,
//
username: 'admin@123.com',
password: await generateHash('Aa1234567'),
//
isAdmin: true,
},
});
for (let i = 1; i < 3; i++) {
const CJK_LOCALES = {
en: enFaker,
zh: zhFaker,
ja: jaFaker,
ko: koFaker,
tw: twFaker,
};
function getRandomCJKFaker() {
const locales = Object.keys(CJK_LOCALES);
const randomKey = locales[Math.floor(Math.random() * locales.length)] as keyof typeof CJK_LOCALES;
return CJK_LOCALES[randomKey];
}
const randomFaker = getRandomCJKFaker();
await prisma.userMeta.upsert({
where: { id: i.toString() },
update: {},
create: {
name: randomFaker.person.fullName(),
city: randomFaker.location.city(),
role: ROLE[Math.floor(Math.random() * ROLE.length)],
email: randomFaker.internet.email(),
state: randomFaker.location.state(),
status: STATUS[Math.floor(Math.random() * STATUS.length)],
address: randomFaker.location.streetAddress(),
country: randomFaker.location.country(),
zipCode: randomFaker.location.zipCode(),
company: randomFaker.company.name(),
avatarUrl: randomFaker.image.avatar(),
phoneNumber: randomFaker.phone.number(),
isVerified: true,
//
username: randomFaker.internet.username(),
password: await generateHash('Abc1234!'),
//
isAdmin: false,
},
});
}
console.log('seed userMeta done');
}
const userMetaSeed = userMeta()
.then(async () => {
await prisma.$disconnect();
})
.catch(async (e) => {
console.error(e);
await prisma.$disconnect();
process.exit(1);
});
export { userMetaSeed };
const ROLE = [
`CEO`,
`CTO`,
`Project Coordinator`,
`Team Leader`,
`Software Developer`,
`Marketing Strategist`,
`Data Analyst`,
`Product Owner`,
`Graphic Designer`,
`Operations Manager`,
`Customer Support Specialist`,
`Sales Manager`,
`HR Recruiter`,
`Business Consultant`,
`Financial Planner`,
`Network Engineer`,
`Content Creator`,
`Quality Assurance Tester`,
`Public Relations Officer`,
`IT Administrator`,
`Compliance Officer`,
`Event Planner`,
`Legal Counsel`,
`Training Coordinator`,
];
const STATUS = ['active', 'pending', 'banned'];

View File

@@ -25,6 +25,7 @@ export async function POST(req: NextRequest) {
const { data } = await req.json();
try {
// TODO: obsolete createNewAppLog
const createResult = await createNewAppLog(data);
return response(createResult, STATUS.OK);

View File

@@ -1,13 +1,20 @@
import type { User } from '@prisma/client';
import type { NextRequest } from 'next/server';
import { headers } from 'next/headers';
import { verify } from 'src/utils/jwt';
import { STATUS, response, handleError } from 'src/utils/response';
import { _users, JWT_SECRET } from 'src/_mock/_auth';
import { JWT_SECRET } from 'src/_mock/_auth';
import { getUserById } from 'src/app/services/user.service';
import { createAccessLog } from 'src/app/services/AccessLog.service';
import { flattenNextjsRequest } from '../sign-in/flattenNextjsRequest';
// ----------------------------------------------------------------------
export const runtime = 'edge';
// export const runtime = 'edge';
/**
* This API is used for demo purpose only
@@ -17,25 +24,44 @@ export const runtime = 'edge';
* You should not expose the JWT_SECRET in the client side
*/
export async function GET() {
const USER_TOKEN_CHECK_FAILED = 'user token check failed';
const INVALID_AUTH_TOKEN = 'Invalid authorization token';
const USER_ID_NOT_FOUND = 'userId not found';
const USER_TOKEN_OK = 'user token check ok';
const AUTHORIZATION_TOKEN_MISSING_OR_INVALID = 'Authorization token missing or invalid';
export async function GET(req: NextRequest) {
const debug = { 'req.headers': flattenNextjsRequest(req) };
try {
const headersList = headers();
const authorization = headersList.get('authorization');
if (!authorization || !authorization.startsWith('Bearer ')) {
return response({ message: 'Authorization token missing or invalid' }, STATUS.UNAUTHORIZED);
return response({ message: AUTHORIZATION_TOKEN_MISSING_OR_INVALID }, STATUS.UNAUTHORIZED);
}
const accessToken = `${authorization}`.split(' ')[1];
const data = await verify(accessToken, JWT_SECRET);
console.log(data.userId);
const currentUser = _users.find((user) => user.id === data.userId);
if (data.userId) {
// TODO: remove me
// const currentUser = _users.find((user) => user.id === data.userId);
const currentUser: User | null = await getUserById(data.userId);
if (!currentUser) {
return response({ message: 'Invalid authorization token' }, STATUS.UNAUTHORIZED);
if (!currentUser) {
createAccessLog('', USER_TOKEN_CHECK_FAILED, debug);
return response({ message: INVALID_AUTH_TOKEN }, STATUS.UNAUTHORIZED);
}
createAccessLog(currentUser.id, USER_TOKEN_OK, debug);
return response({ user: currentUser }, STATUS.OK);
} else {
return response({ message: USER_ID_NOT_FOUND }, STATUS.ERROR);
}
return response({ user: currentUser }, 200);
} catch (error) {
return handleError('[Auth] - Me', error);
}

View File

@@ -0,0 +1,25 @@
###
# username and password ok
GET http://localhost:7272/api/auth/me
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJjbWJnbnUyengwMDBjaHEzaGZ3dmtjejlvIiwiaWF0IjoxNzQ4OTY0ODkyLCJleHAiOjE3NTAxNzQ0OTJ9.lo04laCxtm0IVeYaETEV3hXKyDmXPEn7SyWtY2VR4dI
###
# There is no user corresponding to the email address.
POST http://localhost:7272/api/auth/sign-in
content-type: application/json
{
"email": "demo@minimals1.cc",
"password": "@2Minimal"
}
###
# Wrong password
POST http://localhost:7272/api/auth/sign-in
content-type: application/json
{
"email": "demo@minimals.cc",
"password": "@2Min111imal"
}

View File

@@ -0,0 +1,5 @@
import type { NextRequest } from 'next/server';
export function flattenNextjsRequest(req: NextRequest) {
return Object.fromEntries(req.headers.entries());
}

View File

@@ -7,6 +7,7 @@ import { JWT_SECRET, JWT_EXPIRES_IN } from 'src/_mock/_auth';
import { createAccessLog } from 'src/app/services/AccessLog.service';
import prisma from '../../../lib/prisma';
import { flattenNextjsRequest } from './flattenNextjsRequest';
// ----------------------------------------------------------------------
@@ -22,7 +23,7 @@ const ERR_USER_NOT_FOUND = 'There is no user corresponding to the email address.
const ERR_WRONG_PASSWORD = 'Wrong password';
export async function POST(req: NextRequest) {
const debug = { 'req.headers': Object.fromEntries(req.headers.entries()) };
const debug = { 'req.headers': flattenNextjsRequest(req) };
try {
const { email, password } = await req.json();

View File

@@ -0,0 +1,25 @@
# GUIDELINE
## Event / event
- this is a `event` api endpoint
- this is a demo to handle `event` record
- use single file for single db table/collection only
## `route.ts`
handle `GET`, `POST`, `PUT`, `DELETE`
## `test.http`
store test request
## `../../services/event.service.ts`
event schema CRUD handler
`listEvents` - list `event` record
`getEvent` - get `event` record by id
`createNewEvent` - create `event` record
`updateEvent` - update `event` record by id
`deleteEvent` - delete `event` record by id

View File

@@ -8,10 +8,11 @@
import type { NextRequest } from 'next/server';
import { logger } from 'src/utils/logger';
import { STATUS, response, handleError } from 'src/utils/response';
import prisma from '../../../lib/prisma';
import { L_INFO, L_ERROR } from 'src/constants';
import { getEvent } from 'src/app/services/eventItem.service';
import { createAppLog } from 'src/app/services/AppLog.service';
// ----------------------------------------------------------------------
@@ -19,29 +20,32 @@ import prisma from '../../../lib/prisma';
* GET Event detail
*************************************** */
export async function GET(req: NextRequest) {
try {
const { searchParams } = req.nextUrl;
const debug = { 'req.headers': Object.fromEntries(req.headers.entries()) };
// RULES: eventId must exist
const eventId = searchParams.get('eventId');
const { searchParams } = req.nextUrl;
// RULES: for the incoming request, the `eventId` must exist
const eventId = searchParams.get('eventId');
try {
if (!eventId) {
return response({ message: 'Event ID is required!' }, STATUS.BAD_REQUEST);
}
// NOTE: eventId confirmed exist, run below
const event = await prisma.eventItem.findFirst({
include: { reviews: true },
where: { id: eventId },
});
// NOTE: `eventId` confirmed exist, run below
const event = await getEvent(eventId);
console.log({ event });
// RULES: show error if not found
if (!event) {
return response({ message: 'Event not found!' }, STATUS.NOT_FOUND);
}
logger('[Event] details', event.id);
// logger('[Event] details', event.id);
await createAppLog(L_INFO, 'get event detail ok', { eventId });
return response({ event }, STATUS.OK);
} catch (error) {
await createAppLog(L_ERROR, 'error during getting event detail', { debug, eventId });
return handleError('Event - Get details', error);
}
}

View File

@@ -1,3 +1,5 @@
###
GET http://localhost:7272/api/event/details?eventId=e99f09a7-dd88-49d5-b1c8-1daf80c2d7b01
###
GET http://localhost:7272/api/event/details

View File

@@ -1,17 +1,17 @@
// src/app/api/event/list/route.ts
import { logger } from 'src/utils/logger';
import { STATUS, response, handleError } from 'src/utils/response';
import prisma from '../../../lib/prisma';
// src/app/api/event/list/route.ts
import { listEvents } from 'src/app/services/eventItem.service';
// ----------------------------------------------------------------------
/** **************************************
* GET - Events
* GET - Events, obsoleted
*************************************** */
export async function GET() {
try {
const events = await prisma.eventItem.findMany();
const events = await listEvents();
logger('[Event] list', events.length);

View File

@@ -10,7 +10,11 @@ import type { NextRequest } from 'next/server';
import { STATUS, response, handleError } from 'src/utils/response';
import { L_INFO, L_ERROR } from 'src/constants';
import { createAppLog } from 'src/app/services/AppLog.service';
import prisma from '../../../lib/prisma';
import { flattenNextjsRequest } from '../../auth/sign-in/flattenNextjsRequest';
// ----------------------------------------------------------------------
@@ -21,6 +25,8 @@ import prisma from '../../../lib/prisma';
*/
export async function GET(req: NextRequest) {
// Original user details functionality
const debug = { 'req.headers': flattenNextjsRequest(req) };
try {
const { searchParams } = req.nextUrl;
@@ -32,8 +38,12 @@ export async function GET(req: NextRequest) {
if (!helloworld) return response({ message: 'User not found!' }, STATUS.NOT_FOUND);
createAppLog(L_INFO, 'Get OK', debug);
return response({ helloworld }, STATUS.OK);
} catch (error) {
createAppLog(L_ERROR, 'Get error', debug);
return handleError('Product - Get details', error);
}
}

View File

@@ -0,0 +1,3 @@
# GUIDELINES
T.B.A.

View File

@@ -1,7 +1,7 @@
// src/app/api/product/details/route.ts
//
// PURPOSE:
// save product to db by id
// get product from db by id
//
// RULES:
// T.B.A.
@@ -11,14 +11,22 @@ import type { NextRequest } from 'next/server';
import { logger } from 'src/utils/logger';
import { STATUS, response, handleError } from 'src/utils/response';
import prisma from '../../../lib/prisma';
import { L_INFO, L_ERROR } from 'src/constants';
import { getProduct } from 'src/app/services/product.service';
import { createAppLog } from 'src/app/services/AppLog.service';
import { flattenNextjsRequest } from '../../auth/sign-in/flattenNextjsRequest';
// ----------------------------------------------------------------------
/** **************************************
/**
**************************************
* GET Product detail
*************************************** */
***************************************
*/
export async function GET(req: NextRequest) {
const debug = { 'req.headers': flattenNextjsRequest(req) };
try {
const { searchParams } = req.nextUrl;
@@ -29,10 +37,7 @@ export async function GET(req: NextRequest) {
}
// NOTE: productId confirmed exist, run below
const product = await prisma.productItem.findFirst({
include: { reviews: true },
where: { id: productId },
});
const product = await getProduct(productId);
if (!product) {
return response({ message: 'Product not found!' }, STATUS.NOT_FOUND);
@@ -40,8 +45,12 @@ export async function GET(req: NextRequest) {
logger('[Product] details', product.id);
createAppLog(L_INFO, 'Get product detail OK', debug);
return response({ product }, STATUS.OK);
} catch (error) {
createAppLog(L_ERROR, 'product detail error', debug);
return handleError('Product - Get details', error);
}
}

View File

@@ -0,0 +1,3 @@
###
GET http://localhost:7272/api/product/details?productId=e99f09a7-dd88-49d5-b1c8-1daf80c2d7b01

View File

@@ -1,22 +1,41 @@
// src/app/api/product/list/route.ts
import { logger } from 'src/utils/logger';
//
// PURPOSE:
// save product to db by id
//
// RULES:
// T.B.A.
import type { NextRequest } from 'next/server';
import { STATUS, response, handleError } from 'src/utils/response';
import prisma from '../../../lib/prisma';
import { L_INFO, L_ERROR } from 'src/constants';
import { createAppLog } from 'src/app/services/AppLog.service';
import { listProducts } from 'src/app/services/product.service';
import { flattenNextjsRequest } from '../../auth/sign-in/flattenNextjsRequest';
// ----------------------------------------------------------------------
/** **************************************
* GET - Products
* GET - Products list
*************************************** */
export async function GET() {
try {
const products = await prisma.productItem.findMany();
export async function GET(req: NextRequest) {
const debug = { 'req.headers': flattenNextjsRequest(req) };
logger('[Product] list', products.length);
try {
// const products = await prisma.productItem.findMany();
const products = await listProducts();
// logger('[Product] list', products.length);
createAppLog(L_INFO, 'product list ok', {});
return response({ products }, STATUS.OK);
} catch (error) {
createAppLog(L_ERROR, 'product list error', debug);
return handleError('Product - Get list', error);
}
}

View File

@@ -0,0 +1,3 @@
###
GET http://localhost:7272/api/product/list

View File

@@ -0,0 +1,23 @@
# GUIDELINE
- this is a helloworld api endpoint
- this is a demo to handle helloworld record
- use single file for single db table/collection only
## `route.ts`
handle `GET`, `POST`, `PUT`, `DELETE`
## `test.http`
store test request
## `../../services/helloworld.service.ts`
helloworld schema CRUD handler
`listHelloworlds` - list helloworld record
`getHelloworld` - get helloworld record by id
`createNewHelloworld` - create helloworld record
`updateHelloworld` - update helloworld record by id
`deleteHelloworld` - delete helloworld record by id

View File

@@ -0,0 +1,39 @@
// src/app/api/helloworld/detail/route.ts
//
// PURPOSE:
// Get single helloworld record detail
//
// RULES:
// - For helloworld requests, return simple response
//
import type { NextRequest } from 'next/server';
import { STATUS, response, handleError } from 'src/utils/response';
import prisma from '../../../lib/prisma';
// ----------------------------------------------------------------------
/**
**************************************
* GET - Handle both helloworld and user details
**************************************
*/
export async function GET(req: NextRequest) {
// Original user details functionality
try {
const { searchParams } = req.nextUrl;
// RULES: helloworldId must exist
const helloworldId = searchParams.get('helloworldId');
if (!helloworldId) return response({ message: 'helloworldId is required!' }, STATUS.BAD_REQUEST);
const helloworld = await prisma.userItem.findFirst({ where: { id: helloworldId } });
if (!helloworld) return response({ message: 'User not found!' }, STATUS.NOT_FOUND);
return response({ helloworld }, STATUS.OK);
} catch (error) {
return handleError('Product - Get details', error);
}
}

View File

@@ -0,0 +1,4 @@
###
GET http://localhost:7272/api/helloworld/details?helloworldId=1165ce3a-29b8-4e1a-9148-1ae08d7e8e01

View File

@@ -0,0 +1,34 @@
import prisma from '@/lib/prisma';
import { NextResponse } from 'next/server';
// GET: 获取所有学生
export async function GET() {
try {
const students = await prisma.student.findMany();
return NextResponse.json(students);
} catch (error) {
return NextResponse.json({ error: 'Failed to fetch students' }, { status: 500 });
}
}
// POST: 创建新学生
export async function POST(request: Request) {
try {
const { email, metadata } = await request.json();
if (!email) {
return NextResponse.json({ error: 'Email is required' }, { status: 400 });
}
const student = await prisma.student.create({
data: {
email,
metadata: metadata || {},
},
});
return NextResponse.json(student, { status: 201 });
} catch (error) {
return NextResponse.json({ error: 'Failed to create student' }, { status: 500 });
}
}

View File

@@ -0,0 +1,25 @@
###
GET http://localhost:7272/api/helloworld
###
GET http://localhost:7272/api/helloworld?helloworldId=1
###
POST http://localhost:7272/api/helloworld?helloworldId=1
content-type: application/json
{
"data":{"hello": "hell"}
}
###
PUT http://localhost:7272/api/helloworld?helloworldId=1
content-type: application/json
{
"data": {"hello": "hell"}
}
###
DELETE http://localhost:7272/api/helloworld?helloworldId=1

View File

@@ -16,6 +16,7 @@ import prisma from '../lib/prisma';
type CreateAppLog = {
level: number;
message: string;
metadata: Record<string, any>;
};
// type UpdateAppLog = {
@@ -31,6 +32,10 @@ async function getAppLog(appLogId: string) {
return prisma.appLog.findFirst({ where: { id: appLogId } });
}
async function createAppLog(level: number, message: string, metadata: Record<string, any>) {
return prisma.appLog.create({ data: { level, message, metadata } });
}
async function createNewAppLog(createForm: CreateAppLog) {
return prisma.appLog.create({ data: createForm });
}
@@ -48,5 +53,6 @@ export {
listAppLogs,
// updateAppLog,
deleteAppLog,
createAppLog,
createNewAppLog,
};

View File

@@ -7,10 +7,6 @@
// - Follows same pattern as helloworld.service.ts
//
import type { Event } from '@prisma/client';
import prisma from '../lib/prisma';
type CreateEvent = {
eventDate: DateTime;
title: string;
@@ -39,27 +35,33 @@ type UpdateEvent = {
memberId?: number;
};
async function listEvents(): Promise<Event[]> {
return prisma.event.findMany();
}
// async function listEvents(): Promise<Event[]> {
// return prisma.event.findMany();
// }
async function getEvent(eventId: number) {
return prisma.event.findFirst({ where: { id: eventId } });
}
// async function getEvent(eventId: number) {
// return prisma.event.findFirst({ where: { id: eventId } });
// }
async function createNewEvent(createForm: CreateEvent) {
return prisma.event.create({ data: createForm });
}
// async function createNewEvent(createForm: CreateEvent) {
// return prisma.event.create({ data: createForm });
// }
async function updateEvent(eventId: number, updateForm: UpdateEvent) {
return prisma.event.update({
where: { id: eventId },
data: updateForm,
});
}
// async function updateEvent(eventId: number, updateForm: UpdateEvent) {
// return prisma.event.update({
// where: { id: eventId },
// data: updateForm,
// });
// }
async function deleteEvent(eventId: number) {
return prisma.event.delete({ where: { id: eventId } });
}
// async function deleteEvent(eventId: number) {
// return prisma.event.delete({ where: { id: eventId } });
// }
export { getEvent, listEvents, updateEvent, deleteEvent, createNewEvent };
export {
listEvents,
// getEvent,
// updateEvent,
// deleteEvent,
// createNewEvent,
};

View File

@@ -0,0 +1,71 @@
// src/app/services/event.service.ts
//
// PURPOSE:
// - Service for handling Event records
//
// RULES:
// - Follows same pattern as helloworld.service.ts
//
import type { EventItem } from '@prisma/client';
import prisma from '../lib/prisma';
type CreateEvent = {
eventDate: DateTime;
title: string;
joinMembers?: Json[];
price: number;
currency: string;
duration_m: number;
ageBottom: number;
ageTop: number;
location: string;
avatar?: string;
memberId?: number;
};
type UpdateEvent = {
eventDate?: DateTime;
title?: string;
joinMembers?: Json[];
price?: number;
currency?: string;
duration_m?: number;
ageBottom?: number;
ageTop?: number;
location?: string;
avatar?: string;
memberId?: number;
};
async function listEvents(): Promise<EventItem[]> {
return prisma.eventItem.findMany();
}
async function getEvent(eventId: string): Promise<EventItem | null> {
return prisma.eventItem.findFirst({ where: { id: eventId } });
}
// async function createNewEvent(createForm: CreateEvent) {
// return prisma.event.create({ data: createForm });
// }
// async function updateEvent(eventId: number, updateForm: UpdateEvent) {
// return prisma.event.update({
// where: { id: eventId },
// data: updateForm,
// });
// }
// async function deleteEvent(eventId: number) {
// return prisma.event.delete({ where: { id: eventId } });
// }
export {
getEvent,
listEvents,
// updateEvent,
// deleteEvent,
// createNewEvent,
};

View File

@@ -68,7 +68,7 @@ async function listProducts(): Promise<ProductItem[]> {
return prisma.productItem.findMany();
}
async function getProduct(productId: string) {
async function getProduct(productId: string): Promise<ProductItem | null> {
return prisma.productItem.findUnique({ where: { id: productId } });
}

View File

@@ -0,0 +1,127 @@
// src/app/services/user.service.ts
//
// PURPOSE:
// - Handle User Record CRUD operations
//
// RULES:
// - Follow Prisma best practices for database operations
// - Validate input data before processing
//
import type { User } from '@prisma/client';
import prisma from '../lib/prisma';
type CreateUser = {
email: string;
// name?: string;
// password: string;
// role?: Role;
// isEmailVerified?: boolean;
// admin?: boolean;
};
type UpdateUser = {
email?: string;
// name?: string;
// password?: string;
// role?: Role;
// isEmailVerified?: boolean;
isAdmin?: boolean;
};
// async function listUsers(): Promise<UserItem[]> {
// return prisma.userItem.findMany();
// }
// async function getUserItem(userId: string): Promise<UserItem | null> {
// return prisma.userItem.findFirst({ where: { id: userId } });
// }
// async function updateUser(userId: string, updateForm: UpdateUser): Promise<User> {
// return prisma.userItem.update({
// where: { id: userId },
// data: updateForm,
// });
// }
// // check if userId is a admin
// // check if userId is a admin
// async function isAdmin(userId: string): Promise<boolean> {
// const user = await getUserItem(userId);
// return user?.isAdmin === true;
// }
// async function changeToAdmin(userIdToPromote: string, userIdOfApplicant: string) {
// // check the applicant is admin or not
// const userApplicant = await getUserItem(userIdOfApplicant);
// let promoteResult = {};
// if (userApplicant && userApplicant.isAdmin) {
// // applicant is an admin
// promoteResult = await updateUser(userIdToPromote, { isAdmin: true });
// } else {
// promoteResult = { status: 'failed', message: 'applicant is not a admin' };
// }
// return promoteResult;
// }
// async function changeToUser(userIdToPromote: string, userIdOfApplicant: string) {
// // check the applicant is admin or not
// const userApplicant = await getUserItem(userIdOfApplicant);
// let promoteResult = {};
// if (userApplicant && userApplicant.isAdmin) {
// // applicant is an admin
// promoteResult = await updateUser(userIdToPromote, { isAdmin: false });
// } else {
// promoteResult = { status: 'failed', message: 'applicant is not a admin' };
// }
// return promoteResult;
// }
async function getUserById(id: string): Promise<User | null> {
return prisma.user.findFirst({ where: { id } });
}
// async function getUserByEmail(email: string): Promise<void> {
// // return prisma.userItem.findUnique({
// // where: { email },
// // include: {
// // Token: true,
// // },
// // });
// }
// async function createNewUser(createForm: CreateUser): Promise<void> {
// // return prisma.userItem.create({
// // data: {
// // email: createForm.email,
// // name: createForm.name,
// // password: createForm.password,
// // role: createForm.role || 'USER',
// // isEmailVerified: createForm.isEmailVerified || false,
// // },
// // });
// }
// async function deleteUser(userId: number): Promise<void> {
// // return prisma.userItem.delete({ where: { id: userId } });
// }
export {
// getUser,
getUserById,
// isAdmin,
// listUsers,
// updateUser,
// deleteUser,
// changeToUser,
// createNewUser,
// changeToAdmin,
// getUserByEmail,
// type CreateUser,
// type UpdateUser,
};

View File

@@ -82,6 +82,10 @@ async function changeToUser(userIdToPromote: string, userIdOfApplicant: string)
return promoteResult;
}
async function getUserById1(id: string): Promise<UserItem | null> {
return prisma.userItem.findFirst({ where: { id } });
}
async function getUserByEmail(email: string): Promise<void> {
// return prisma.userItem.findUnique({
// where: { email },
@@ -113,6 +117,7 @@ export {
listUsers,
updateUser,
deleteUser,
getUserById,
changeToUser,
createNewUser,
changeToAdmin,

View File

@@ -0,0 +1,7 @@
const L_ERROR = 0;
const L_WARN = 1;
const L_INFO = 2;
const L_DEBUG = 3;
const L_TRACE = 4;
export { L_WARN, L_INFO, L_ERROR, L_DEBUG, L_TRACE };

View File

@@ -12,11 +12,7 @@ type Token = {
* SignJWT
* https://github.com/panva/jose/blob/main/docs/classes/jwt_sign.SignJWT.md
*/
export async function sign(
payload: Token,
secret: string,
options: { expiresIn: string | number }
): Promise<string> {
export async function sign(payload: Token, secret: string, options: { expiresIn: string | number }): Promise<string> {
const iat = Math.floor(Date.now() / 1000);
return new SignJWT({ ...payload })

16
03_source/docker/81_dc_down.sh Executable file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -ex
# -f docker-compose.db.yml
DOCKER_COMPOSE_FILES=" -f docker-compose.yml -f docker-compose.dev.yml"
# docker compose $DOCKER_COMPOSE_FILES build
docker compose $DOCKER_COMPOSE_FILES kill
docker compose $DOCKER_COMPOSE_FILES down
# cd ../api_server
# yarn docker:dev
# cd ..
# docker compose $DOCKER_COMPOSE_FILES logs -f

View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -ex
# -f docker-compose.db.yml
DOCKER_COMPOSE_FILES=" -f docker-compose.yml"
# docker compose $DOCKER_COMPOSE_FILES build
docker compose $DOCKER_COMPOSE_FILES kill
docker compose $DOCKER_COMPOSE_FILES down
# cd ../api_server
# yarn docker:dev
# cd ..
# docker compose $DOCKER_COMPOSE_FILES logs -f

17
03_source/docker/99_prod_up.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -ex
# -f docker-compose.db.yml
DOCKER_COMPOSE_FILES=" -f docker-compose.yml"
# docker compose $DOCKER_COMPOSE_FILES build
docker compose $DOCKER_COMPOSE_FILES up -d
docker compose $DOCKER_COMPOSE_FILES logs -f
# cd ../api_server
# yarn docker:dev
# cd ..
# docker compose $DOCKER_COMPOSE_FILES logs -f

View File

@@ -1,9 +1,14 @@
services:
frontend:
command: "sleep infinity"
command: 'sleep infinity'
mobile:
command: "sleep infinity"
command: 'sleep infinity'
cms_backend:
command: "sleep infinity"
command: 'sleep infinity'
postgres:
# container_name: postgres
ports:
- '5432:5432'

View File

@@ -8,22 +8,22 @@ services:
build: ../frontend
# user: 1000:1000
ports:
- 8080:8080
- 10001:8080
volumes:
- ../frontend:/app
working_dir: "/app"
command: "yarn dev"
working_dir: '/app'
command: './dev.sh'
mobile:
image: 192.168.10.61:5000/hksingleparty_mobile
build: ../mobile
# user: 1000:1000
ports:
- 8081:3000
- 10004:3000
volumes:
- ../mobile:/app
working_dir: "/app"
command: "npm run dev"
working_dir: '/app'
command: './dev.sh'
cms_backend:
image: 192.168.10.61:5000/demo_minimal_kit_backend
@@ -32,22 +32,19 @@ services:
env_file:
- .env
ports:
- 7272:7272
- 5555:5555
- 10002:7272
- 10003:5555
volumes:
- ../cms_backend:/app
working_dir: "/app"
command: "yarn dev"
working_dir: '/app'
command: './dev.sh'
postgres:
container_name: postgres
image: postgres:14.1-alpine
restart: unless-stopped
env_file:
- .env
expose:
- "5432"
ports:
- "5432:5432"
- '5432'
volumes:
- db:/var/lib/postgresql/data

View File

@@ -1,7 +1,11 @@
#!/usr/bin/env bash
yarn --dev
while true; do
yarn --dev
# yarn tsc:print
yarn lint:print
yarn dev --force --clearScreen

File diff suppressed because it is too large Load Diff

View File

@@ -105,6 +105,7 @@
"react-organizational-chart": "^2.2.1",
"react-phone-number-input": "^3.4.12",
"react-router": "^7.4.1",
"react-use": "^17.6.0",
"rehype-highlight": "^7.0.2",
"rehype-raw": "^7.0.0",
"remark-gfm": "^4.0.1",

View File

@@ -1,7 +1,7 @@
// src/actions/invoice.ts
import { useMemo } from 'react';
import axiosInstance, { endpoints, fetcher } from 'src/lib/axios';
import type { IInvoiceItem } from 'src/types/invoice';
import type { IInvoiceItem, SaveInvoiceData } from 'src/types/invoice';
import type { SWRConfiguration } from 'swr';
import useSWR from 'swr';
@@ -97,7 +97,7 @@ export function useSearchInvoices(query: string) {
// ----------------------------------------------------------------------
type SaveInvoiceData = IInvoiceItem;
// type SaveInvoiceData = IInvoiceItem;
export async function saveInvoice(invoiceId: string, saveInvoiceData: SaveInvoiceData) {
const url = endpoints.invoice.saveInvoice(invoiceId);

View File

@@ -99,6 +99,7 @@ export function useSearchProducts(query: string) {
type SaveProductData = {
// id: string;
sku: string;
name: string;
code: string;

View File

@@ -17,6 +17,8 @@ export type SignUpParams = {
lastName: string;
};
const ERR_ACCESS_TOKEN_NOT_FOUND = `Access token not found in response`;
/** **************************************
* Sign in
*************************************** */
@@ -29,7 +31,7 @@ export const signInWithPassword = async ({ email, password }: SignInParams): Pro
const { accessToken } = res.data;
if (!accessToken) {
throw new Error('Access token not found in response');
throw new Error(ERR_ACCESS_TOKEN_NOT_FOUND);
}
setSession(accessToken);

View File

@@ -69,6 +69,8 @@ export function tokenExpired(exp: number) {
// ----------------------------------------------------------------------
const INVALID_ACCESS_TOKEN = 'Invalid access token!';
export async function setSession(accessToken: string | null) {
try {
if (accessToken) {
@@ -81,7 +83,7 @@ export async function setSession(accessToken: string | null) {
if (decodedToken && 'exp' in decodedToken) {
tokenExpired(decodedToken.exp);
} else {
throw new Error('Invalid access token!');
throw new Error(INVALID_ACCESS_TOKEN);
}
} else {
sessionStorage.removeItem(JWT_STORAGE_KEY);

Some files were not shown because too many files have changed in this diff Show More