v0.1/code-improvements #53
			
				
			
		
		
		
	| 
						 | 
				
			
			@ -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:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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" },
 | 
			
		||||
        ]
 | 
			
		||||
      }
 | 
			
		||||
    ]
 | 
			
		||||
  }
 | 
			
		||||
})
 | 
			
		||||
| 
						 | 
				
			
			@ -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 })
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,5 @@
 | 
			
		|||
import { NextResponse } from 'next/server'
 | 
			
		||||
 
 | 
			
		||||
export async function GET(request: Request) {
 | 
			
		||||
  return NextResponse.json({ msg: 'OK' })
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,23 @@
 | 
			
		|||
import fs from 'fs/promises';
 | 
			
		||||
import path from 'path';
 | 
			
		||||
 | 
			
		||||
export const getAppVersion = async (): Promise<string> => {
 | 
			
		||||
 | 
			
		||||
    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
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue