Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@
"@types/cors": "^2.8.17",
"@types/swagger-jsdoc": "^6.0.4",
"@types/swagger-ui-express": "^4.1.8",
"bcryptjs": "^3.0.3",
"cors": "^2.8.5",
"express": "^4.21.2",
"jsonwebtoken": "^9.0.3",
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.1"
},
"devDependencies": {
"@types/bcryptjs": "^2.4.6",
"@types/express": "^5.0.0",
"@types/jsonwebtoken": "^9.0.10",
"@types/node": "^22.12.0",
"@types/supertest": "6.0.2",
"@vitest/coverage-v8": "3.0.5",
Expand Down
2 changes: 2 additions & 0 deletions api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import express from 'express';
import swaggerJsdoc from 'swagger-jsdoc';
import swaggerUi from 'swagger-ui-express';
import cors from 'cors';
import authRoutes from './routes/auth';
import deliveryRoutes from './routes/delivery';
import orderDetailDeliveryRoutes from './routes/orderDetailDelivery';
import productRoutes from './routes/product';
Expand Down Expand Up @@ -66,6 +67,7 @@ app.get('/api-docs.json', (req, res) => {

app.use(express.json());

app.use('/api/auth', authRoutes);
app.use('/api/deliveries', deliveryRoutes);
app.use('/api/order-detail-deliveries', orderDetailDeliveryRoutes);
app.use('/api/products', productRoutes);
Expand Down
135 changes: 135 additions & 0 deletions api/src/models/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/**
* @swagger
* components:
* schemas:
* User:
* type: object
* required:
* - userId
* - email
* - passwordHash
* properties:
* userId:
* type: integer
* description: The unique identifier for the user
* email:
* type: string
* format: email
* description: User's email address (used for login)
* passwordHash:
* type: string
* description: Hashed password
* isAdmin:
* type: boolean
* description: Whether the user has admin privileges
* default: false
* createdAt:
* type: string
* format: date-time
* description: Account creation timestamp
* resetToken:
* type: string
* description: Password reset token (if active)
* resetTokenExpiry:
* type: string
* format: date-time
* description: Expiry time for reset token
*/
export interface User {
userId: number;
email: string;
passwordHash: string;
isAdmin: boolean;
createdAt: Date;
resetToken?: string;
resetTokenExpiry?: Date;
}

/**
* @swagger
* components:
* schemas:
* UserRegistration:
* type: object
* required:
* - email
* - password
* properties:
* email:
* type: string
* format: email
* description: User's email address
* password:
* type: string
* format: password
* description: User's password (minimum 8 characters)
*/
export interface UserRegistration {
email: string;
password: string;
}

/**
* @swagger
* components:
* schemas:
* UserLogin:
* type: object
* required:
* - email
* - password
* properties:
* email:
* type: string
* format: email
* description: User's email address
* password:
* type: string
* format: password
* description: User's password
*/
export interface UserLogin {
email: string;
password: string;
}

/**
* @swagger
* components:
* schemas:
* PasswordResetRequest:
* type: object
* required:
* - email
* properties:
* email:
* type: string
* format: email
* description: User's email address to send reset link
*/
export interface PasswordResetRequest {
email: string;
}

/**
* @swagger
* components:
* schemas:
* PasswordReset:
* type: object
* required:
* - resetToken
* - newPassword
* properties:
* resetToken:
* type: string
* description: Password reset token received via email
* newPassword:
* type: string
* format: password
* description: New password (minimum 8 characters)
*/
export interface PasswordReset {
resetToken: string;
newPassword: string;
}
Loading