mirror of
https://github.com/johndoe6345789/postgres.git
synced 2026-04-25 14:25:06 +00:00
Initial commit
This commit is contained in:
50
src/utils/AIAutomation.test.ts
Normal file
50
src/utils/AIAutomation.test.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
describe('AI Automation Validation', () => {
|
||||
const rootDir = path.resolve(__dirname, '..', '..');
|
||||
const configPath = path.join(rootDir, '.coderabbit.yaml');
|
||||
const readmePath = path.join(rootDir, 'README.md');
|
||||
|
||||
describe('CodeRabbit Configuration', () => {
|
||||
it('should have .coderabbit.yaml configuration file', () => {
|
||||
expect(fs.existsSync(configPath)).toBe(true);
|
||||
});
|
||||
|
||||
it('should have valid CodeRabbit YAML configuration', () => {
|
||||
const configContent = fs.readFileSync(configPath, 'utf-8');
|
||||
|
||||
// Validate required fields exist in the YAML content
|
||||
expect(configContent).toBeDefined();
|
||||
expect(configContent).toContain('language:');
|
||||
expect(configContent).toContain('reviews:');
|
||||
expect(configContent).toContain('CodeRabbit');
|
||||
});
|
||||
|
||||
it('should have reviews auto_review enabled', () => {
|
||||
const configContent = fs.readFileSync(configPath, 'utf-8');
|
||||
|
||||
// Check that auto_review section exists with enabled: true
|
||||
// Using a pattern that ensures we're checking the auto_review section specifically
|
||||
expect(configContent).toMatch(/auto_review:\s+enabled:\s+true/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('README Documentation', () => {
|
||||
it('should mention AI automation in README', () => {
|
||||
const readmeContent = fs.readFileSync(readmePath, 'utf-8');
|
||||
|
||||
// Check for AI-related mentions
|
||||
expect(readmeContent.toLowerCase()).toContain('ai');
|
||||
expect(readmeContent.toLowerCase()).toContain('coderabbit');
|
||||
});
|
||||
|
||||
it('should have AI-powered code reviews feature listed', () => {
|
||||
const readmeContent = fs.readFileSync(readmePath, 'utf-8');
|
||||
|
||||
// Check for specific feature mention
|
||||
expect(readmeContent).toContain('AI-powered code reviews');
|
||||
});
|
||||
});
|
||||
});
|
||||
23
src/utils/AppConfig.ts
Normal file
23
src/utils/AppConfig.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { LocalizationResource } from '@clerk/types';
|
||||
import type { LocalePrefixMode } from 'next-intl/routing';
|
||||
import { enUS, frFR } from '@clerk/localizations';
|
||||
|
||||
const localePrefix: LocalePrefixMode = 'as-needed';
|
||||
|
||||
// FIXME: Update this configuration file based on your project information
|
||||
export const AppConfig = {
|
||||
name: 'Nextjs Starter',
|
||||
locales: ['en', 'fr'],
|
||||
defaultLocale: 'en',
|
||||
localePrefix,
|
||||
};
|
||||
|
||||
const supportedLocales: Record<string, LocalizationResource> = {
|
||||
en: enUS,
|
||||
fr: frFR,
|
||||
};
|
||||
|
||||
export const ClerkLocalizations = {
|
||||
defaultLocale: enUS,
|
||||
supportedLocales,
|
||||
};
|
||||
18
src/utils/DBConnection.ts
Normal file
18
src/utils/DBConnection.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { drizzle } from 'drizzle-orm/node-postgres';
|
||||
import { Pool } from 'pg';
|
||||
import { Env } from '@/libs/Env';
|
||||
import * as schema from '@/models/Schema';
|
||||
|
||||
// Need a database for production? Just claim it by running `npm run neon:claim`.
|
||||
// Tested and compatible with Next.js Boilerplate
|
||||
export const createDbConnection = () => {
|
||||
const pool = new Pool({
|
||||
connectionString: Env.DATABASE_URL,
|
||||
max: 1,
|
||||
});
|
||||
|
||||
return drizzle({
|
||||
client: pool,
|
||||
schema,
|
||||
});
|
||||
};
|
||||
21
src/utils/Helpers.test.ts
Normal file
21
src/utils/Helpers.test.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { routing } from '@/libs/I18nRouting';
|
||||
import { getI18nPath } from './Helpers';
|
||||
|
||||
describe('Helpers', () => {
|
||||
describe('getI18nPath function', () => {
|
||||
it('should not change the path for default language', () => {
|
||||
const url = '/random-url';
|
||||
const locale = routing.defaultLocale;
|
||||
|
||||
expect(getI18nPath(url, locale)).toBe(url);
|
||||
});
|
||||
|
||||
it('should prepend the locale to the path for non-default language', () => {
|
||||
const url = '/random-url';
|
||||
const locale = 'fr';
|
||||
|
||||
expect(getI18nPath(url, locale)).toMatch(/^\/fr/);
|
||||
});
|
||||
});
|
||||
});
|
||||
32
src/utils/Helpers.ts
Normal file
32
src/utils/Helpers.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { routing } from '@/libs/I18nRouting';
|
||||
|
||||
export const getBaseUrl = () => {
|
||||
if (process.env.NEXT_PUBLIC_APP_URL) {
|
||||
return process.env.NEXT_PUBLIC_APP_URL;
|
||||
}
|
||||
|
||||
if (
|
||||
process.env.VERCEL_ENV === 'production'
|
||||
&& process.env.VERCEL_PROJECT_PRODUCTION_URL
|
||||
) {
|
||||
return `https://${process.env.VERCEL_PROJECT_PRODUCTION_URL}`;
|
||||
}
|
||||
|
||||
if (process.env.VERCEL_URL) {
|
||||
return `https://${process.env.VERCEL_URL}`;
|
||||
}
|
||||
|
||||
return 'http://localhost:3000';
|
||||
};
|
||||
|
||||
export const getI18nPath = (url: string, locale: string) => {
|
||||
if (locale === routing.defaultLocale) {
|
||||
return url;
|
||||
}
|
||||
|
||||
return `/${locale}${url}`;
|
||||
};
|
||||
|
||||
export const isServer = () => {
|
||||
return typeof window === 'undefined';
|
||||
};
|
||||
Reference in New Issue
Block a user