Ajout des variables d'environemment
This commit is contained in:
2
backend/.env
Normal file
2
backend/.env
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
PORT=3000
|
||||||
|
TEXTS_PATH=C:\src\patois\texts
|
||||||
13
backend/package-lock.json
generated
13
backend/package-lock.json
generated
@@ -10,6 +10,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
|
"dotenv": "^17.2.2",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"multer": "^1.4.5-lts.1"
|
"multer": "^1.4.5-lts.1"
|
||||||
},
|
},
|
||||||
@@ -309,6 +310,18 @@
|
|||||||
"npm": "1.2.8000 || >= 1.4.16"
|
"npm": "1.2.8000 || >= 1.4.16"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/dotenv": {
|
||||||
|
"version": "17.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.2.2.tgz",
|
||||||
|
"integrity": "sha512-Sf2LSQP+bOlhKWWyhFsn0UsfdK/kCWRv1iuA2gXAwt3dyNabr6QSj00I2V10pidqz69soatm9ZwZvpQMTIOd5Q==",
|
||||||
|
"license": "BSD-2-Clause",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://dotenvx.com"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/dunder-proto": {
|
"node_modules/dunder-proto": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
|
||||||
|
|||||||
@@ -8,16 +8,21 @@
|
|||||||
"start": "node server.js",
|
"start": "node server.js",
|
||||||
"dev": "nodemon server.js"
|
"dev": "nodemon server.js"
|
||||||
},
|
},
|
||||||
"keywords": ["patois", "franco-provençal", "api", "express"],
|
"keywords": [
|
||||||
|
"patois",
|
||||||
|
"franco-provençal",
|
||||||
|
"api",
|
||||||
|
"express"
|
||||||
|
],
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "^4.18.2",
|
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
|
"dotenv": "^17.2.2",
|
||||||
|
"express": "^4.18.2",
|
||||||
"multer": "^1.4.5-lts.1"
|
"multer": "^1.4.5-lts.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"nodemon": "^3.0.1"
|
"nodemon": "^3.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,18 @@ import cors from 'cors'
|
|||||||
import fs from 'fs/promises'
|
import fs from 'fs/promises'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { fileURLToPath } from 'url'
|
import { fileURLToPath } from 'url'
|
||||||
|
import dotenv from 'dotenv'
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url)
|
const __filename = fileURLToPath(import.meta.url)
|
||||||
const __dirname = path.dirname(__filename)
|
const __dirname = path.dirname(__filename)
|
||||||
|
|
||||||
|
/** Configuration dotenv
|
||||||
|
* Permet de charger les variables d'environnement depuis un fichier .env
|
||||||
|
* */
|
||||||
|
dotenv.config()
|
||||||
|
|
||||||
const app = express()
|
const app = express()
|
||||||
const PORT = process.env.PORT || 3001
|
const PORT = process.env.PORT
|
||||||
|
|
||||||
// Middleware
|
// Middleware
|
||||||
app.use(cors())
|
app.use(cors())
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* Service pour communiquer avec l'API backend des textes
|
* Service pour communiquer avec l'API backend des textes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:3001/api'
|
const API_BASE_URL = import.meta.env.TEXTS_API_URL
|
||||||
|
|
||||||
export class TextService {
|
export class TextService {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|||||||
@@ -19,9 +19,6 @@ start "Frontend Vue.js" cmd /k "npm run dev"
|
|||||||
echo.
|
echo.
|
||||||
echo ==============================================
|
echo ==============================================
|
||||||
echo Application demarree avec succes !
|
echo Application demarree avec succes !
|
||||||
echo.
|
|
||||||
echo Frontend: http://localhost:5173
|
|
||||||
echo API: http://localhost:3001
|
|
||||||
echo ==============================================
|
echo ==============================================
|
||||||
echo.
|
echo.
|
||||||
echo Fermez cette fenetre quand vous voulez arreter l'application.
|
echo Fermez cette fenetre quand vous voulez arreter l'application.
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
import { defineConfig } from 'vite'
|
import { defineConfig, loadEnv } from 'vite'
|
||||||
import vue from '@vitejs/plugin-vue'
|
import vue from '@vitejs/plugin-vue'
|
||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig(({ mode }) => {
|
||||||
plugins: [vue()],
|
const env = loadEnv(mode, process.cwd())
|
||||||
|
return {
|
||||||
|
plugins: [vue()],
|
||||||
|
server: {
|
||||||
|
port: parseInt(env.VITE_PORT) || 3001
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user