feat: Adds current App version Number in Footer.

This commit is contained in:
towfiqi 2023-03-05 19:23:07 +06:00
parent 3b6d034d6f
commit b83df5f3db
4 changed files with 14 additions and 2 deletions

View File

@ -1,8 +1,13 @@
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const { version } = require('./package.json');
const nextConfig = { const nextConfig = {
reactStrictMode: true, reactStrictMode: true,
swcMinify: false, swcMinify: false,
output: 'standalone', output: 'standalone',
publicRuntimeConfig: {
version,
},
}; };
module.exports = nextConfig; module.exports = nextConfig;

View File

@ -1,5 +1,6 @@
import type { NextApiRequest, NextApiResponse } from 'next'; import type { NextApiRequest, NextApiResponse } from 'next';
import Cryptr from 'cryptr'; import Cryptr from 'cryptr';
import getConfig from 'next/config';
import { writeFile, readFile } from 'fs/promises'; import { writeFile, readFile } from 'fs/promises';
import verifyUser from '../../utils/verifyUser'; import verifyUser from '../../utils/verifyUser';
import allScrapers from '../../scrapers/index'; import allScrapers from '../../scrapers/index';
@ -26,7 +27,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const getSettings = async (req: NextApiRequest, res: NextApiResponse<SettingsGetResponse>) => { const getSettings = async (req: NextApiRequest, res: NextApiResponse<SettingsGetResponse>) => {
const settings = await getAppSettings(); const settings = await getAppSettings();
if (settings) { if (settings) {
return res.status(200).json({ settings }); const { publicRuntimeConfig } = getConfig();
const version = publicRuntimeConfig?.version;
return res.status(200).json({ settings: { ...settings, version } });
} }
return res.status(400).json({ error: 'Error Loading Settings!' }); return res.status(400).json({ error: 'Error Loading Settings!' });
}; };

View File

@ -58,7 +58,7 @@ const SingleDomain: NextPage = () => {
}, [appSettings]); }, [appSettings]);
return ( return (
<div className="Domain "> <div className="Domain flex flex-col min-h-screen">
{noScrapprtError && ( {noScrapprtError && (
<div className=' p-3 bg-red-600 text-white text-sm text-center'> <div className=' p-3 bg-red-600 text-white text-sm text-center'>
A Scrapper/Proxy has not been set up Yet. Open Settings to set it up and start using the app. A Scrapper/Proxy has not been set up Yet. Open Settings to set it up and start using the app.
@ -112,6 +112,9 @@ const SingleDomain: NextPage = () => {
<CSSTransition in={showSettings} timeout={300} classNames="settings_anim" unmountOnExit mountOnEnter> <CSSTransition in={showSettings} timeout={300} classNames="settings_anim" unmountOnExit mountOnEnter>
<Settings closeSettings={() => setShowSettings(false)} /> <Settings closeSettings={() => setShowSettings(false)} />
</CSSTransition> </CSSTransition>
<footer className='text-center flex flex-1 justify-center pb-5 items-end'>
<span className='text-gray-500 text-xs'><a href='https://github.com/towfiqi/serpbear' target="_blank" rel='noreferrer'>SerpBear v{appSettings?.settings?.version || '0.0.0'}</a></span>
</footer>
</div> </div>
); );
}; };

1
types.d.ts vendored
View File

@ -80,6 +80,7 @@ type SettingsType = {
search_console_integrated?: boolean, search_console_integrated?: boolean,
available_scapers?: Array, available_scapers?: Array,
scrape_interval?: string scrape_interval?: string
version?: string
} }
type KeywordSCDataChild = { type KeywordSCDataChild = {