diff --git a/docker-compose.yaml b/docker-compose.yaml index bcc6b79..c60fbcc 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -8,6 +8,13 @@ services: restart: always + healthcheck: + test: wget --no-verbose --tries=1 --spider http://localhost:3000/api/status || exit 1 + interval: 60s + retries: 5 + start_period: 20s + timeout: 10s + build: . ports: diff --git a/next.config.js b/next.config.js index bb0375e..6d722af 100644 --- a/next.config.js +++ b/next.config.js @@ -1,11 +1,25 @@ const createNextIntlPlugin = require('next-intl/plugin'); - + const withNextIntl = createNextIntlPlugin(); const path = require('path') - + module.exports = withNextIntl({ sassOptions: { includePaths: [path.join(__dirname, 'src/styles')], }, + async headers() { + return [ + { + // matching all API routes + source: "/api/:path*", + headers: [ + { key: "Access-Control-Allow-Credentials", value: "true" }, + { key: "Access-Control-Allow-Origin", value: "*" }, + { key: "Access-Control-Allow-Methods", value: "GET,DELETE,PATCH,POST,PUT" }, + { key: "Access-Control-Allow-Headers", value: "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version" }, + ] + } + ] + } }) \ No newline at end of file diff --git a/src/app/api/info/route.ts b/src/app/api/info/route.ts new file mode 100644 index 0000000..e5e92d3 --- /dev/null +++ b/src/app/api/info/route.ts @@ -0,0 +1,7 @@ +import { getAppVersion } from '@/utils/info/version' +import { NextResponse } from 'next/server' + +export async function GET() { + const version = await getAppVersion() + return NextResponse.json({ version }) +} \ No newline at end of file diff --git a/src/app/api/status/route.ts b/src/app/api/status/route.ts new file mode 100644 index 0000000..25695fe --- /dev/null +++ b/src/app/api/status/route.ts @@ -0,0 +1,5 @@ +import { NextResponse } from 'next/server' + +export async function GET(request: Request) { + return NextResponse.json({ msg: 'OK' }) +} \ No newline at end of file diff --git a/src/utils/info/version.ts b/src/utils/info/version.ts new file mode 100644 index 0000000..4f76523 --- /dev/null +++ b/src/utils/info/version.ts @@ -0,0 +1,23 @@ +import fs from 'fs/promises'; +import path from 'path'; + +export const getAppVersion = async (): Promise => { + + let version = '' + + try { + + const packageJsonPath = path.resolve(process.cwd(), 'package.json'); + + const data = await fs.readFile(packageJsonPath, 'utf8'); + + const packageJson = JSON.parse(data); + + version = packageJson.version + + } catch (error) { + // handle error + } + + return version +}