Skip to content

Commit

Permalink
frontend & backend setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ArslanKamchybekov committed Sep 12, 2024
1 parent 258fdaf commit 11ffef7
Show file tree
Hide file tree
Showing 19 changed files with 594 additions and 65 deletions.
454 changes: 452 additions & 2 deletions backend/package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
"dependencies": {
"@nestjs/common": "^10.0.0",
"@nestjs/core": "^10.0.0",
"@nestjs/mongoose": "^10.0.10",
"@nestjs/platform-express": "^10.0.0",
"dotenv": "^16.4.5",
"mongodb": "^6.8.1",
"moongoose": "^0.0.5",
"nodemon": "^3.1.4",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1"
Expand Down
22 changes: 0 additions & 22 deletions backend/src/app.controller.spec.ts

This file was deleted.

12 changes: 0 additions & 12 deletions backend/src/app.controller.ts

This file was deleted.

8 changes: 4 additions & 4 deletions backend/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { AuthController } from './auth/auth.controller';
import { AuthService } from './auth/auth.service';
import { InsuranceController } from './insurance/insurance.controller';
import { InsuranceService } from './insurance/insurance.service';
import { UserController } from './user/user.controller';
import { UserService } from './user/user.service';
import { ServiceController } from './services/service.controller';
import { ServiceService } from './services/service.service';

@Module({
imports: [],
controllers: [AppController, AuthController, InsuranceController, UserController],
providers: [AppService, AuthService, InsuranceService, UserService],
controllers: [AuthController, InsuranceController, UserController, ServiceController],
providers: [AuthService, InsuranceService, UserService, ServiceService],
})
export class AppModule {}
8 changes: 0 additions & 8 deletions backend/src/app.service.ts

This file was deleted.

4 changes: 0 additions & 4 deletions backend/src/insurance/insurance.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,4 @@ import { InsuranceService } from './insurance.service';
export class InsuranceController {
constructor(private readonly insuranceService: InsuranceService) {}

@Get()
get(): string {
return "Insurance is running!";
}
}
2 changes: 1 addition & 1 deletion backend/src/insurance/insurance.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ import { InsuranceService } from './insurance.service';
controllers: [InsuranceController],
providers: [InsuranceService],
})
export class AppModule {}
export class InsuranceModule{}
22 changes: 22 additions & 0 deletions backend/src/insurance/insurance.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import mongoose, { Schema, Document, Model } from 'mongoose';

export interface IInsurancePlan extends Document {
name: string;
description: string;
monthlyPremium: number;
coverageDetails: string;
eligibility: string;
}

const InsurancePlanSchema = new Schema<IInsurancePlan>(
{
name: { type: String, required: true },
description: { type: String, required: true },
monthlyPremium: { type: Number, required: true },
coverageDetails: { type: String, required: true },
eligibility: { type: String, required: true },
},
{ timestamps: true }
);

export const InsurancePlan: Model<IInsurancePlan> = mongoose.model('InsurancePlan', InsurancePlanSchema);
3 changes: 2 additions & 1 deletion backend/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import * as dotenv from 'dotenv';
import connectDB from './utils/database';

async function bootstrap() {
dotenv.config();
Expand All @@ -9,8 +10,8 @@ async function bootstrap() {
credentials: true,
methods: 'GET, POST, PUT, DELETE, OPTIONS, PATCH',
});

await app.listen(process.env.PORT || 5000);
console.log(`Application is running on: "http://localhost:${process.env.PORT || 5000}"`);
await connectDB();
}
bootstrap();
20 changes: 20 additions & 0 deletions backend/src/services/service.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Test, TestingModule } from '@nestjs/testing';
import { ServiceController } from './service.controller';
import { ServiceService } from './service.service';

describe('ServiceController', () => {
let serviceController: ServiceController;

beforeEach(async () => {
const app: TestingModule = await Test.createTestingModule({
controllers: [ServiceController],
providers: [ServiceService],
}).compile();

serviceController = app.get<ServiceController>(ServiceController);
});

it('should be defined', () => {
expect(serviceController).toBeDefined();
});
});
8 changes: 8 additions & 0 deletions backend/src/services/service.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Controller } from '@nestjs/common';
import { ServiceService } from './service.service';

@Controller('service')
export class ServiceController {
constructor(private readonly serviceService: ServiceService) {}

}
11 changes: 11 additions & 0 deletions backend/src/services/service.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Module } from '@nestjs/common';
import { ServiceService } from './service.service';
import { ServiceController } from './service.controller';


@Module({
imports: [],
controllers: [ServiceController],
providers: [ServiceService],
})
export class ServiceModule {}
24 changes: 24 additions & 0 deletions backend/src/services/service.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import mongoose, { Schema, Document, Model } from 'mongoose';

export interface IService extends Document {
name: string;
description: string;
cost: number;
location: string;
eligibility: string;
languagesSupported: string[];
}

const ServiceSchema = new Schema<IService>(
{
name: { type: String, required: true },
description: { type: String, required: true },
cost: { type: Number, required: true },
location: { type: String, required: true },
eligibility: { type: String, required: true },
languagesSupported: { type: [String], default: [] },
},
{ timestamps: true }
);

export const Service: Model<IService> = mongoose.model('Service', ServiceSchema);
6 changes: 6 additions & 0 deletions backend/src/services/service.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Injectable } from '@nestjs/common';

@Injectable()
export class ServiceService {

}
12 changes: 2 additions & 10 deletions backend/src/user/user.controller.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import { Controller, Delete, Get } from '@nestjs/common';
import { Controller, Req, Get, Post, Put, Delete, Param, Body, UseGuards } from '@nestjs/common';
import { UserService } from './user.service';

@Controller('user')
export class UserController {
constructor(private readonly userService: UserService) {}

@Get()
get(): string {
return "User is running!";
}

@Delete("delete")
delete(): string {
return "delete!";
}

}
23 changes: 23 additions & 0 deletions backend/src/user/user.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import mongoose, { Schema, Document, Model } from 'mongoose';

export interface IUser extends Document {
name: string;
email: string;
password: string;
role: string;
savedServices: string[];
language: string;
}

const UserSchema = new Schema<IUser>(
{
name: { type: String, required: true },
email: { type: String, required: true, unique: true },
password: { type: String, required: true },
role: { type: String, required: true },
savedServices: { type: [String], default: [] },
},
{ timestamps: true }
);

export const User: Model<IUser> = mongoose.model('User', UserSchema);
3 changes: 2 additions & 1 deletion backend/src/user/user.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Injectable } from '@nestjs/common';
import { User } from './user.schema';

@Injectable()
export class UserService {

}
14 changes: 14 additions & 0 deletions backend/src/utils/database.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import mongoose from 'mongoose';
require('dotenv').config();

const connectDB = async () => {
try {
await mongoose.connect(process.env.MONGO_URI || '')
console.log('MongoDB connected');
} catch (error: any) {
console.error(error.message);
setTimeout(connectDB, 5000);
}
};

export default connectDB;

0 comments on commit 11ffef7

Please sign in to comment.