changed imports
This commit is contained in:
parent
bb26972377
commit
178f2b4810
|
|
@ -1,4 +1,4 @@
|
|||
import { createParamDecorator, ExecutionContext, MiddlewareConsumer, Module } from '@nestjs/common';
|
||||
import { MiddlewareConsumer, Module } from '@nestjs/common';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { PassportModule } from '@nestjs/passport';
|
||||
import { utilities as nestWinstonModuleUtilities, WinstonModule } from 'nest-winston';
|
||||
|
|
@ -18,45 +18,11 @@ import dotenvFlow from 'dotenv-flow';
|
|||
import { EventModule } from './event/event.module';
|
||||
import { JwtStrategy } from './jwt.strategy';
|
||||
import { MailModule } from './mail/mail.module';
|
||||
import { RealIpInfo } from './models/main.model';
|
||||
|
||||
import { PaymentModule } from './payment/payment.module';
|
||||
import { RequestDurationMiddleware } from './request-duration/request-duration.middleware';
|
||||
import { SelectOptionsModule } from './select-options/select-options.module';
|
||||
import { UserModule } from './user/user.module';
|
||||
export const RealIp = createParamDecorator((data: unknown, ctx: ExecutionContext): RealIpInfo => {
|
||||
const request = ctx.switchToHttp().getRequest();
|
||||
const ip = request.headers['cf-connecting-ip'] || request.headers['x-real-ip'] || request.headers['x-forwarded-for']?.split(',')[0] || request.connection.remoteAddress;
|
||||
const countryCode = request.headers['cf-ipcountry'];
|
||||
return { ip, countryCode };
|
||||
});
|
||||
// function loadEnvFiles() {
|
||||
// // Determine which additional env file to load
|
||||
// let envFilePath = '';
|
||||
// const host = process.env.HOST_NAME || '';
|
||||
|
||||
// if (host.includes('localhost')) {
|
||||
// envFilePath = '.env.local';
|
||||
// } else if (host.includes('dev.bizmatch.net')) {
|
||||
// envFilePath = '.env.dev';
|
||||
// } else if (host.includes('www.bizmatch.net') || host.includes('bizmatch.net')) {
|
||||
// envFilePath = '.env.prod';
|
||||
// }
|
||||
|
||||
// // Load the additional env file if it exists
|
||||
// if (fs.existsSync(envFilePath)) {
|
||||
// dotenv.config({ path: envFilePath });
|
||||
// console.log(`Loaded ${envFilePath} file`);
|
||||
// } else {
|
||||
// console.log(`No additional .env file found for HOST_NAME: ${host}`);
|
||||
// }
|
||||
|
||||
// // Load the .env file
|
||||
// dotenv.config();
|
||||
// console.log('Loaded .env file');
|
||||
// // Output all loaded environment variables
|
||||
// console.log('Loaded environment variables:');
|
||||
// console.log(JSON.stringify(process.env, null, 2));
|
||||
// }
|
||||
|
||||
//loadEnvFiles();
|
||||
dotenvFlow.config();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { createParamDecorator, ExecutionContext, Injectable } from '@nestjs/common';
|
||||
import { RealIpInfo } from './models/main.model';
|
||||
export const RealIp = createParamDecorator((data: unknown, ctx: ExecutionContext): RealIpInfo => {
|
||||
const request = ctx.switchToHttp().getRequest();
|
||||
const ip = request.headers['cf-connecting-ip'] || request.headers['x-real-ip'] || request.headers['x-forwarded-for']?.split(',')[0] || request.connection.remoteAddress;
|
||||
const countryCode = request.headers['cf-ipcountry'];
|
||||
return { ip, countryCode };
|
||||
});
|
||||
@Injectable()
|
||||
export class AppService {
|
||||
getHello(): string {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { Body, Controller, Headers, Post } from '@nestjs/common';
|
||||
import { RealIp } from 'src/app.module';
|
||||
import { RealIp } from 'src/app.service';
|
||||
import { ListingEvent } from 'src/models/db.model';
|
||||
import { RealIpInfo } from 'src/models/main.model';
|
||||
import { EventService } from './event.service';
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
|
||||
import { RealIp } from 'src/app.module';
|
||||
import { RealIp } from 'src/app.service';
|
||||
import { RealIpInfo } from 'src/models/main.model';
|
||||
import { CountyRequest } from 'src/models/server.model';
|
||||
import { GeoService } from './geo.service';
|
||||
|
|
|
|||
Loading…
Reference in New Issue