Skip to content
Merged
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
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,26 @@ server/ # Backend code
β”œβ”€β”€ __tests__/ # Backend tests
β”‚ β”œβ”€β”€ database.test.js
β”‚ └── server.test.js
β”œβ”€β”€ database/ # Database layer
β”‚ β”œβ”€β”€ connection/ # Mongoose connection for database
β”‚ β”‚ β”œβ”€β”€ __tests__/
β”‚ β”‚ β”‚ └── mongoose.test.ts
β”‚ β”‚ └── mongoose.ts
β”‚ β”œβ”€β”€ models/ # Mongoose models for database
β”‚ β”‚ β”œβ”€β”€ __tests__/
β”‚ β”‚ β”œβ”€β”€ seed.model.ts
β”‚ β”‚ β”œβ”€β”€ survey.model.ts
β”‚ β”‚ └── user.model.ts
β”‚ β”œβ”€β”€ controllers/ # Data access layer (i.e. CRUD operations)
β”‚ β”‚ β”œβ”€β”€ __tests__/
β”‚ β”‚ β”œβ”€β”€ seed.controller.ts
β”‚ β”‚ β”œβ”€β”€ survey.controller.ts
β”‚ β”‚ └── user.controller.ts
β”‚ β”œβ”€β”€ types/ # Database type definitions
β”‚ β”‚ β”œβ”€β”€ seed.type.ts
β”‚ β”‚ β”œβ”€β”€ survey.type.ts
β”‚ β”‚ └── user.type.ts
β”‚ └── index.ts # Database module exports
β”œβ”€β”€ models/ # Mongoose schemas
β”‚ └── __tests__/ # Models tests
β”‚ β”œβ”€β”€ Survey.test.js
Expand All @@ -127,8 +147,7 @@ server/ # Backend code
β”‚ β”œβ”€β”€ __tests__/ # Utils tests
β”‚ β”‚ └── generateReferralCode.test.js
β”‚ └── generateReferralCode.js # Utility to generate unique referral codes
β”œβ”€β”€ database.js # Mongoose DB connection init
β”œβ”€β”€ index.js # Main entry point for Express backend
β”œβ”€β”€ index.ts # Main entry point for Express backend
β”œβ”€β”€ .gitignore # Specifies files to ignore in Git
β”œβ”€β”€ package.json # Backend dependencies and scripts
└── package-lock.json # Lockfile for backend dependencies
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it, jest, beforeEach, afterEach } from '@jest/globals';
import mongoose from 'mongoose';
import connectDB from '../database';
import { connectDB } from '../../index';

// Mock mongoose
jest.mock('mongoose');
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions server/src/database/controllers/seed.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// TODO: Implement Seed repository
1 change: 1 addition & 0 deletions server/src/database/controllers/survey.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// TODO: Implement Survey repository
1 change: 1 addition & 0 deletions server/src/database/controllers/user.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// TODO: Implement User repository
12 changes: 12 additions & 0 deletions server/src/database/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Connection setup
export { default as connectDB } from './connection/mongoose';

// Type exports
// export * from './types/user.type';
// export * from './types/survey.type';
// export * from './types/seed.type';

// Repository exports
// export * from './repositories/user.repository';
// export * from './repositories/survey.repository';
// export * from './repositories/seed.repository';
1 change: 1 addition & 0 deletions server/src/database/models/seed.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// TODO: Implement Seed mongoose model
1 change: 1 addition & 0 deletions server/src/database/models/survey.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// TODO: Implement Survey mongoose model
1 change: 1 addition & 0 deletions server/src/database/models/user.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// TODO: Implement User mongoose model
1 change: 1 addition & 0 deletions server/src/database/types/seed.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// TODO: Implement Seed type interface + Zod validation
1 change: 1 addition & 0 deletions server/src/database/types/survey.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// TODO: Implement Survey type interface + Zod validation
1 change: 1 addition & 0 deletions server/src/database/types/user.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// TODO: Implement User type interface + Zod validation
2 changes: 1 addition & 1 deletion server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import helmet from 'helmet';
import nocache from 'nocache';

import connectDB from '@/database';
import { connectDB } from '@/database/index';
import authRoutes from '@/routes/auth';
import pageRoutes from '@/routes/pages';
import surveyRoutes from '@/routes/surveys';
Expand Down Expand Up @@ -208,12 +208,12 @@
res.status(500).json({ message: 'Something went wrong!' });
});

(async () => {

Check failure on line 211 in server/src/index.ts

View workflow job for this annotation

GitHub Actions / lint-and-type-check (server)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
try {
console.log('Starting DB connection...');
await connectDB();
console.log('DB connected successfully');
const PORT = parseInt(process.env.PORT || '1234', 10);

Check failure on line 216 in server/src/index.ts

View workflow job for this annotation

GitHub Actions / lint-and-type-check (server)

Prefer using nullish coalescing operator (`??`) instead of a logical or (`||`), as it is a safer operator
app.listen(PORT, '0.0.0.0', () => {
console.log(
`Server running with security headers at http://localhost:${PORT}`
Expand Down
Loading