Skip to content

Commit

Permalink
style: minor code quality changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ozgurg committed Mar 17, 2024
1 parent 17bbec1 commit feef1b2
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 42 deletions.
10 changes: 5 additions & 5 deletions .env
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# YOU MUST RESTART THE APP IF YOU MAKE CHANGES IN THIS FILE
SERVER_HOST="localhost"
SERVER_PORT=3000

HOST="localhost"
PORT=3000
EMULATOR_PORT=8026

APP_URL="https://vergihesaplayici.com"
APP_NAME="Vergi Hesaplayıcı"
APP_PRIMARY_COLOR="#88df95"
APP_SECONDARY_COLOR="#00262c"

# Source: https://www.csgb.gov.tr/asgari-ucret
# https://www.csgb.gov.tr/asgari-ucret
MINIMUM_WAGE=17002.12

# These are not sensitive. So, it's OK to show it publicly.
FIREBASE_API_KEY="AIzaSyD6VJhwtSsEpkLx2a-WsnhfU1rjUKz2DtA"
FIREBASE_AUTH_DOMAIN="vergihesaplayici.firebaseapp.com"
FIREBASE_DATABASE_URL="https://vergihesaplayici.firebaseio.com"
Expand All @@ -20,4 +19,5 @@ FIREBASE_STORAGE_BUCKET="vergihesaplayici.appspot.com"
FIREBASE_MESSAGING_SENDER_ID="779771263802"
FIREBASE_APP_ID="1:779771263802:web:3786e5cc27855757536e03"
FIREBASE_MEASUREMENT_ID="G-2HW9TT5V7E"

RECAPTCHA_V3_PUBLIC_KEY="6Ld-dw0eAAAAAAJU0zFz1OrzbgRPbx66kwp9BCHl"
5 changes: 2 additions & 3 deletions create-firebase-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ const redirections301 = [
]
];

// create-csp-nonce-txt.js
const cspNonce = fs.readFileSync(path.join(__dirname, "csp-nonce.txt"), { encoding: "utf-8" });

const firebaseJson = {
Expand Down Expand Up @@ -117,7 +116,7 @@ const firebaseJson = {
"https://www.google.com/recaptcha/",
"https://www.gstatic.com/recaptcha/",
"https://www.googletagmanager.com",
"https://cdn.jsdelivr.net" // For Workbox in static/sw.js
"https://cdn.jsdelivr.net" // For Workbox in `static/sw.js`
],
"frame-src": [
"'self'",
Expand Down Expand Up @@ -180,7 +179,7 @@ const firebaseJson = {
},
emulators: {
hosting: {
port: 8026
port: process.env.EMULATOR_PORT
},
ui: {
enabled: true
Expand Down
22 changes: 11 additions & 11 deletions nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from "fs";
import path from "path";
import tr from "vuetify/es5/locale/tr";

const cspNonceTxtPath = path.join(__dirname, "csp-nonce.txt");
const cspNonceTxtPath = path.resolve(__dirname, "csp-nonce.txt");
const isCspNonceTxtExists = fs.existsSync(cspNonceTxtPath);
const cspNonce = isCspNonceTxtExists ?
fs.readFileSync(cspNonceTxtPath, { encoding: "utf-8" }) :
Expand All @@ -15,8 +15,8 @@ export default {
fallback: "404.html"
},
server: {
host: process.env.HOST,
port: process.env.PORT
host: process.env.SERVER_HOST,
port: process.env.SERVER_PORT
},
head: {
titleTemplate: `%s - ${process.env.APP_NAME}`,
Expand Down Expand Up @@ -54,7 +54,7 @@ export default {
],
link: [
{
hid: "shortcut-icon", // Override @nuxtjs/pwa
hid: "shortcut-icon", // Overriding `@nuxtjs/pwa`
rel: "icon",
href: "/favicon.svg",
type: "image/svg+xml"
Expand Down Expand Up @@ -91,8 +91,8 @@ export default {
"@nuxtjs/svg",
"@nuxtjs/pwa",
"@/modules/append-canonical-to-head.js",
"@/modules/append-calculator-presets-to-sitemap.js", // Must be before "@nuxtjs/sitemap"
"@/modules/append-articles-to-sitemap.js", // Must be before "@nuxtjs/sitemap"
"@/modules/append-calculator-presets-to-sitemap.js", // It must be before `@nuxtjs/sitemap`
"@/modules/append-articles-to-sitemap.js", // It must be before `@nuxtjs/sitemap`
"@nuxtjs/sitemap"
],
router: {
Expand All @@ -105,8 +105,7 @@ export default {
ignoreOrder: true
},
html: {
minify: {
// https://stackoverflow.com/a/64739284/7841581
minify: { // https://stackoverflow.com/a/64739284/7841581
collapseBooleanAttributes: true,
decodeEntities: true,
minifyCSS: true,
Expand All @@ -117,7 +116,7 @@ export default {
trimCustomFragments: true,
useShortDoctype: true,
preserveLineBreaks: false,
collapseWhitespace: false // "true" makes v-main's padding-left twice the width of v-navigation-drawer when it's builded
collapseWhitespace: true
}
}
},
Expand All @@ -130,7 +129,7 @@ export default {
]
},
plugins: [
"@/plugins/firebase.client.js",
process.env.NODE_ENV ? "@/plugins/firebase.client.js" : null,
"@/plugins/vue-clipboard2.client.js",
"@/plugins/vue-html2canvas.client.js",
"@/plugins/number-directive.client.js"
Expand Down Expand Up @@ -198,7 +197,8 @@ export default {
}
},

// Disable unused Nuxt features
// Disable unused Nuxt features for a small bundle size.
// This is not documented by Nuxt.
loadingIndicator: false,
fetch: {
client: false
Expand Down
37 changes: 16 additions & 21 deletions plugins/firebase.client.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
/* eslint-disable import/no-mutable-exports */
import { initializeApp } from "firebase/app";
import { initializeAnalytics } from "firebase/analytics";
import { initializePerformance } from "firebase/performance";
import { initializeAppCheck, ReCaptchaV3Provider } from "firebase/app-check";

let firebaseApp = null;
const firebaseApp = initializeApp({
apiKey: process.env.FIREBASE_API_KEY,
authDomain: process.env.FIREBASE_AUTH_DOMAIN,
databaseURL: process.env.FIREBASE_DATABASE_URL,
projectId: process.env.FIREBASE_PROJECT_ID,
storageBucket: process.env.FIREBASE_STORAGE_BUCKET,
messagingSenderId: process.env.FIREBASE_MESSAGING_SENDER_ID,
appId: process.env.FIREBASE_APP_ID,
measurementId: process.env.FIREBASE_MEASUREMENT_ID
});

if (process.env.NODE_ENV === "production") {
firebaseApp = initializeApp({
apiKey: process.env.FIREBASE_API_KEY,
authDomain: process.env.FIREBASE_AUTH_DOMAIN,
databaseURL: process.env.FIREBASE_DATABASE_URL,
projectId: process.env.FIREBASE_PROJECT_ID,
storageBucket: process.env.FIREBASE_STORAGE_BUCKET,
messagingSenderId: process.env.FIREBASE_MESSAGING_SENDER_ID,
appId: process.env.FIREBASE_APP_ID,
measurementId: process.env.FIREBASE_MEASUREMENT_ID
});
initializeAnalytics(firebaseApp);

initializeAnalytics(firebaseApp);
initializePerformance(firebaseApp);

initializePerformance(firebaseApp);

initializeAppCheck(firebaseApp, {
provider: new ReCaptchaV3Provider(process.env.RECAPTCHA_V3_PUBLIC_KEY),
isTokenAutoRefreshEnabled: true
});
}
initializeAppCheck(firebaseApp, {
provider: new ReCaptchaV3Provider(process.env.RECAPTCHA_V3_PUBLIC_KEY),
isTokenAutoRefreshEnabled: true
});

export default firebaseApp;
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"include": [
"domain/**/db/*.js",
"domain/**/*.page-def.js",
"types/*.d.js",
"page-def/*.page-def.js"
"types/*.d.js"
]
}

0 comments on commit feef1b2

Please sign in to comment.