-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0035fba
commit bd636dd
Showing
88 changed files
with
5,437 additions
and
104 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,12 @@ | ||
import { INestApplication } from '@nestjs/common'; | ||
import { NestFactory } from '@nestjs/core'; | ||
import { greet } from 'shared/core/test'; | ||
import { nestjsMainApp } from 'vitnode-backend/main'; | ||
|
||
import { AppModule } from './app.module'; | ||
|
||
async function bootstrap() { | ||
const app: INestApplication = await NestFactory.create(AppModule); | ||
|
||
// eslint-disable-next-line no-console | ||
console.log(greet('test')); | ||
|
||
void nestjsMainApp(app, {}); | ||
} | ||
void bootstrap(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,15 @@ | ||
import { NextIntlClientProvider } from 'next-intl'; | ||
import { getLocale, getMessages } from 'next-intl/server'; | ||
import { GeistSans } from 'geist/font/sans'; | ||
import { | ||
generateMetadataRootLayout, | ||
RootLayout, | ||
} from 'vitnode-frontend/views/layout/root-layout'; | ||
|
||
import './global.css'; | ||
|
||
export default async function LocaleLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
const locale = await getLocale(); | ||
const messages = await getMessages(); | ||
export const generateMetadata = generateMetadataRootLayout; | ||
|
||
return ( | ||
<html lang={locale}> | ||
<body> | ||
<NextIntlClientProvider messages={messages}> | ||
{children} | ||
</NextIntlClientProvider> | ||
</body> | ||
</html> | ||
); | ||
export default function Layout( | ||
props: Omit<React.ComponentProps<typeof RootLayout>, 'className'>, | ||
) { | ||
return <RootLayout className={GeistSans.className} {...props} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,5 @@ | ||
import { greet } from 'shared/core/test'; | ||
import { getMiddlewareData } from 'vitnode-frontend/api/get-middleware-data'; | ||
|
||
export default async function Home() { | ||
const test = await getMiddlewareData(); | ||
|
||
// eslint-disable-next-line no-console | ||
console.log(test); | ||
|
||
export default function Home() { | ||
return <div>{greet('test')}</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default async function RootLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
return children; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use client'; | ||
|
||
import { NotFoundView } from 'vitnode-frontend/views/theme/views/not-found'; | ||
|
||
export default function NotFound() { | ||
return <NotFoundView />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
packages/backend/src/core/middleware/middleware.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
import { Controller, Get } from '@nestjs/common'; | ||
import { ApiResponse, ApiTags } from '@nestjs/swagger'; | ||
import { ShowMiddlewareObj } from 'vitnode-shared/middleware/get.middleware.dto'; | ||
import { ShowMiddlewareObj } from 'vitnode-shared/middleware.dto'; | ||
|
||
import { GetMiddlewareService } from './services/get.middleware.service'; | ||
import { ShowMiddlewareService } from './services/show.middleware.service'; | ||
|
||
@ApiTags('Core') | ||
@Controller('core/middleware') | ||
export class MiddlewareController { | ||
constructor(private readonly getService: GetMiddlewareService) {} | ||
constructor(private readonly showService: ShowMiddlewareService) {} | ||
|
||
@Get() | ||
@ApiResponse({ | ||
status: 200, | ||
type: ShowMiddlewareObj, | ||
}) | ||
async get(): Promise<ShowMiddlewareObj> { | ||
return this.getService.get(); | ||
async show(): Promise<ShowMiddlewareObj> { | ||
return this.showService.show(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { Module } from '@nestjs/common'; | ||
|
||
import { MiddlewareController } from './middleware.controller'; | ||
import { GetMiddlewareService } from './services/get.middleware.service'; | ||
import { ShowMiddlewareService } from './services/show.middleware.service'; | ||
|
||
@Module({ | ||
providers: [GetMiddlewareService], | ||
providers: [ShowMiddlewareService], | ||
controllers: [MiddlewareController], | ||
}) | ||
export class CoreMiddlewareModule {} |
28 changes: 0 additions & 28 deletions
28
packages/backend/src/core/middleware/services/get.middleware.service.ts
This file was deleted.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
packages/backend/src/core/middleware/services/show.middleware.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { ABSOLUTE_PATHS } from '@/app.module'; | ||
import { getConfigFile } from '@/providers/config'; | ||
import { Injectable } from '@nestjs/common'; | ||
import { readdir, readFile } from 'fs/promises'; | ||
import { join } from 'path'; | ||
import { ManifestWithLang } from 'vitnode-shared/manifest.dto'; | ||
import { ShowMiddlewareObj } from 'vitnode-shared/middleware.dto'; | ||
|
||
@Injectable() | ||
export class ShowMiddlewareService { | ||
protected async getManifest({ | ||
langCodes, | ||
}: { | ||
langCodes: string[]; | ||
}): Promise<ManifestWithLang[]> { | ||
return await Promise.all( | ||
langCodes.map(async lang => { | ||
const path = join( | ||
ABSOLUTE_PATHS.uploads.public, | ||
'assets', | ||
lang, | ||
'manifest.webmanifest', | ||
); | ||
const manifest = JSON.parse( | ||
await readFile(path, 'utf8'), | ||
) as ManifestWithLang; | ||
|
||
return manifest; | ||
}), | ||
); | ||
} | ||
|
||
async show(): Promise<ShowMiddlewareObj> { | ||
// TODO: Add cache | ||
const config = getConfigFile(); | ||
const plugins = await readdir(ABSOLUTE_PATHS.plugins); | ||
|
||
return { | ||
languages: config.langs, | ||
authorization: { | ||
force_login: config.settings.authorization.force_login, | ||
lock_register: config.settings.authorization.lock_register, | ||
}, | ||
plugins: [ | ||
'admin', | ||
...plugins.filter(plugin => !['plugins.module.ts'].includes(plugin)), | ||
], | ||
is_email_enabled: false, // TODO: Add email service | ||
is_ai_enabled: false, // TODO: Add AI service | ||
site_name: config.settings.main.site_name, | ||
site_short_name: config.settings.main.site_short_name, | ||
}; | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
packages/backend/src/utils/database/internal_database.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type core from '../../apps/frontend/src/plugins/core/langs/en.json'; | ||
import type admin from '../../apps/frontend/src/plugins/admin/langs/en.json'; | ||
import type welcome from '../../apps/frontend/src/plugins/welcome/langs/en.json'; | ||
|
||
type Messages = typeof core & typeof admin & typeof welcome; | ||
|
||
declare global { | ||
interface IntlMessages extends Messages {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import { NextConfig } from 'next'; | ||
export default function NextConfigDefault(config?: NextConfig): NextConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import createNextIntlPlugin from 'next-intl/plugin'; | ||
import * as dotenv from 'dotenv'; | ||
import { join } from 'path'; | ||
|
||
dotenv.config({ | ||
path: join(process.cwd(), '..', '..', '.env'), | ||
}); | ||
|
||
const withNextIntl = createNextIntlPlugin('./src/i18n.ts'); | ||
|
||
const nextConfig = config => { | ||
const ENVS = { | ||
backend_url: process.env.NEXT_PUBLIC_BACKEND_URL, | ||
frontend_url: process.env.NEXT_PUBLIC_FRONTEND_URL, | ||
}; | ||
|
||
const urls = { | ||
backend: new URL(ENVS.backend_url ?? 'http://localhost:8080'), | ||
frontend: new URL(ENVS.frontend_url ?? 'http://localhost:3000'), | ||
}; | ||
|
||
return { | ||
...config, | ||
devIndicators: { | ||
appIsrStatus: false, | ||
}, | ||
env: { | ||
NEXT_PUBLIC_BACKEND_URL: ENVS.backend_url, | ||
NEXT_PUBLIC_FRONTEND_URL: ENVS.frontend_url, | ||
}, | ||
transpilePackages: ['lucide-react', 'vitnode-frontend', 'vitnode-shared'], | ||
images: { | ||
remotePatterns: [ | ||
{ | ||
protocol: urls.backend.protocol === 'https:' ? 'https' : 'http', | ||
hostname: urls.backend.hostname, | ||
port: urls.backend.port, | ||
pathname: '/public/**', | ||
}, | ||
], | ||
}, | ||
}; | ||
}; | ||
|
||
export default function NextConfigDefault(config) { | ||
return withNextIntl(nextConfig(config || {})); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.