mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 15:05:35 +00:00
add env var SITE_NAME + npm update + add env checker
This commit is contained in:
@@ -5,6 +5,8 @@ import MessageManager from './MessageManager';
|
||||
|
||||
import styles from '../styles/create.module.scss';
|
||||
|
||||
import { config } from '../config';
|
||||
|
||||
interface FormProps {
|
||||
title: string;
|
||||
errorMessage?: string;
|
||||
@@ -32,7 +34,7 @@ export default function Form({
|
||||
}: FormProps) {
|
||||
return (<>
|
||||
<Head>
|
||||
<title>Superpipo — {title}</title>
|
||||
<title>{config.siteName} — {title}</title>
|
||||
</Head>
|
||||
<div className={`App ${styles['create-app']}`}>
|
||||
<h2>{title}</h2>
|
||||
|
||||
33
config.ts
Normal file
33
config.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
// const NEXT_PUBLIC_PREFIX = 'NEXT_PUBLIC_';
|
||||
|
||||
// const getEnvironmentVariable = (environmentVariable: string = ''): string => {
|
||||
// if (!environmentVariable.startsWith(NEXT_PUBLIC_PREFIX)) {
|
||||
// throw new Error(
|
||||
// `Env var must start with "${NEXT_PUBLIC_PREFIX}": ${environmentVariable}`
|
||||
// );
|
||||
// }
|
||||
|
||||
// const envVarObject = Object
|
||||
// .entries(process.env)
|
||||
// .map(([key, value]) => ({ name: key, value }))
|
||||
// .find((env) => {
|
||||
// console.log(env.name === environmentVariable);
|
||||
// return env.name === environmentVariable;
|
||||
// });
|
||||
|
||||
// console.log('envVarObject', envVarObject, process.env.NEXT_PUBLIC_SITE_NAME)
|
||||
|
||||
// if (!envVarObject) {
|
||||
// throw new Error(
|
||||
// `Couldn't find environment variable: ${environmentVariable}`
|
||||
// );
|
||||
// } else {
|
||||
// return envVarObject.value;
|
||||
// }
|
||||
// };
|
||||
|
||||
export const config = {
|
||||
siteName: process.env.NEXT_PUBLIC_SITE_NAME // getEnvironmentVariable(NEXT_PUBLIC_PREFIX + 'SITE_NAME'),
|
||||
};
|
||||
|
||||
console.log('config', config)
|
||||
@@ -1,4 +1,4 @@
|
||||
DATABASE_URL="mysql://root:root@127.0.0.1:3306/MyDatabase"
|
||||
DATABASE_URL="mysql://root:root@127.0.0.1:3306/MyLinks"
|
||||
|
||||
NEXTAUTH_URL=http://localhost:3000
|
||||
NEXTAUTH_URL_INTERNAL=http://localhost:3000
|
||||
@@ -7,3 +7,5 @@ NEXTAUTH_SECRET=
|
||||
|
||||
GOOGLE_CLIENT_ID=
|
||||
GOOGLE_CLIENT_SECRET=
|
||||
|
||||
NEXT_PUBLIC_SITE_NAME=
|
||||
@@ -10,6 +10,5 @@ module.exports = {
|
||||
});
|
||||
|
||||
return config;
|
||||
},
|
||||
optimizeFonts: false
|
||||
}
|
||||
}
|
||||
|
||||
5043
package-lock.json
generated
5043
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "superpipo-v2",
|
||||
"name": "my-links",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
@@ -11,16 +11,16 @@
|
||||
"@dnd-kit/core": "^5.0.3",
|
||||
"@dnd-kit/sortable": "^6.0.1",
|
||||
"@dnd-kit/utilities": "^3.1.0",
|
||||
"@prisma/client": "^3.13.0",
|
||||
"@prisma/client": "^4.3.1",
|
||||
"@svgr/webpack": "^6.2.1",
|
||||
"axios": "^0.27.2",
|
||||
"next": "^12.1.6",
|
||||
"next": "^12.3.0",
|
||||
"next-auth": "^4.0.6",
|
||||
"next-connect": "^0.12.2",
|
||||
"nprogress": "^0.2.0",
|
||||
"react": "^18.1.0",
|
||||
"react": "^18.2.0",
|
||||
"react-confirm-alert": "^2.8.0",
|
||||
"react-dom": "^18.1.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-select": "^5.3.1",
|
||||
"sass": "^1.46.0",
|
||||
"sharp": "^0.30.4",
|
||||
@@ -32,6 +32,6 @@
|
||||
"@types/react": "^18.0.8",
|
||||
"eslint": "7",
|
||||
"eslint-config-next": "12.0.7",
|
||||
"prisma": "^3.13.0"
|
||||
"prisma": "^4.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import Head from 'next/head';
|
||||
import styles from '../styles/error-page.module.scss';
|
||||
|
||||
import { config } from '../config';
|
||||
|
||||
export default function Custom404() {
|
||||
return (<>
|
||||
<Head>
|
||||
<title>Superpipo — Page introuvable</title>
|
||||
<title>{config.siteName} — Page introuvable</title>
|
||||
</Head>
|
||||
<div className={styles['App']}>
|
||||
<h1>404</h1>
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import Head from 'next/head';
|
||||
import styles from '../styles/error-page.module.scss';
|
||||
|
||||
import { config } from '../config';
|
||||
|
||||
export default function Custom500() {
|
||||
return (<>
|
||||
<Head>
|
||||
<title>Superpipo — Une erreur côté serveur est survenue</title>
|
||||
<title>{config.siteName} — Une erreur côté serveur est survenue</title>
|
||||
</Head>
|
||||
<div className={styles['App']}>
|
||||
<h1>500</h1>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { Html, Head, Main, NextScript } from 'next/document';
|
||||
|
||||
import { config } from '../config';
|
||||
|
||||
const Document = () => (
|
||||
<Html lang='fr'>
|
||||
<Head>
|
||||
@@ -7,8 +9,9 @@ const Document = () => (
|
||||
href='https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&family=Rubik:ital,wght@0,400;0,700;1,400;1,700&display=swap'
|
||||
rel='stylesheet'
|
||||
/>
|
||||
<meta charSet='UTF-8' />
|
||||
</Head>
|
||||
<title>Superpipo</title>
|
||||
<title>{config.siteName}</title>
|
||||
<body>
|
||||
<noscript>
|
||||
Vous devez activer JavaScript pour utiliser ce site
|
||||
|
||||
@@ -10,6 +10,7 @@ import { Category, Link } from '../types';
|
||||
import { BuildCategory } from '../utils/front';
|
||||
import { prisma } from '../utils/back';
|
||||
|
||||
import { config } from '../config';
|
||||
|
||||
interface HomeProps {
|
||||
categories: Category[];
|
||||
@@ -24,7 +25,7 @@ function Home({ categories, favorites }: HomeProps) {
|
||||
|
||||
return (<>
|
||||
<Head>
|
||||
<title>Superpipo</title>
|
||||
<title>{config.siteName}</title>
|
||||
</Head>
|
||||
<div className='App'>
|
||||
<Menu
|
||||
|
||||
@@ -7,7 +7,10 @@ import Head from 'next/head';
|
||||
import styles from '../styles/login.module.scss';
|
||||
import MessageManager from '../components/MessageManager';
|
||||
|
||||
export default function SignIn({ providers }) {
|
||||
import { config } from '../config';
|
||||
import { Provider } from 'next-auth/providers';
|
||||
|
||||
export default function SignIn({ providers }: { providers: Provider[]; }) {
|
||||
const { data: session, status } = useSession();
|
||||
const info = useRouter().query?.info as string;
|
||||
const error = useRouter().query?.error as string;
|
||||
@@ -22,7 +25,7 @@ export default function SignIn({ providers }) {
|
||||
|
||||
return (<>
|
||||
<Head>
|
||||
<title>Superpipo — Authentification</title>
|
||||
<title>{config.siteName} — Authentification</title>
|
||||
</Head>
|
||||
<div className='App'>
|
||||
<div className={styles['wrapper']}>
|
||||
|
||||
Reference in New Issue
Block a user