added wpa needed files. WPA is still WIP.
This commit is contained in:
9
.gitignore
vendored
9
.gitignore
vendored
@ -19,6 +19,15 @@ next-env.d.ts
|
||||
.vercel
|
||||
.env*.local
|
||||
|
||||
# PWA files
|
||||
**/public/sw.js
|
||||
**/public/workbox-*.js
|
||||
**/public/worker-*.js
|
||||
**/public/sw.js.map
|
||||
**/public/workbox-*.js.map
|
||||
**/public/worker-*.js.map
|
||||
|
||||
|
||||
*.zip
|
||||
next-cart-app.zip
|
||||
|
||||
|
@ -1,14 +1,17 @@
|
||||
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
||||
const withPWA = require("next-pwa");
|
||||
const withPWA = require("next-pwa")({
|
||||
dest: 'public'
|
||||
});
|
||||
|
||||
|
||||
|
||||
module.exports = withPWA({
|
||||
pwa: {
|
||||
dest: "public",
|
||||
// register: true,
|
||||
// skipwaiting: true,
|
||||
// disable: process.env.NODE_ENV === "development",
|
||||
},
|
||||
// pwa: {
|
||||
// dest: "public",
|
||||
// // register: true,
|
||||
// // skipwaiting: true,
|
||||
// // disable: process.env.NODE_ENV === "development",
|
||||
// },
|
||||
typescript: {
|
||||
// !! WARN !!
|
||||
// Dangerously allow production builds to successfully complete even if
|
||||
|
30
package-lock.json
generated
30
package-lock.json
generated
@ -84,6 +84,7 @@
|
||||
"uuid": "^9.0.1",
|
||||
"webpack-bundle-analyzer": "^4.10.1",
|
||||
"winston": "^3.11.0",
|
||||
"workbox": "^0.0.0",
|
||||
"xlsx": "https://cdn.sheetjs.com/xlsx-0.19.1/xlsx-0.19.1.tgz",
|
||||
"xlsx-style": "^0.8.13",
|
||||
"xml-js": "^1.6.11",
|
||||
@ -5311,6 +5312,20 @@
|
||||
"@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/babel-runtime": {
|
||||
"version": "6.26.0",
|
||||
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz",
|
||||
"integrity": "sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g==",
|
||||
"dependencies": {
|
||||
"core-js": "^2.4.0",
|
||||
"regenerator-runtime": "^0.11.0"
|
||||
}
|
||||
},
|
||||
"node_modules/babel-runtime/node_modules/regenerator-runtime": {
|
||||
"version": "0.11.1",
|
||||
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
|
||||
"integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg=="
|
||||
},
|
||||
"node_modules/balanced-match": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||
@ -6418,6 +6433,13 @@
|
||||
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
|
||||
"integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ=="
|
||||
},
|
||||
"node_modules/core-js": {
|
||||
"version": "2.6.12",
|
||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz",
|
||||
"integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==",
|
||||
"deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.",
|
||||
"hasInstallScript": true
|
||||
},
|
||||
"node_modules/core-js-compat": {
|
||||
"version": "3.36.1",
|
||||
"resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.36.1.tgz",
|
||||
@ -16610,6 +16632,14 @@
|
||||
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
|
||||
"integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q=="
|
||||
},
|
||||
"node_modules/workbox": {
|
||||
"version": "0.0.0",
|
||||
"resolved": "https://registry.npmjs.org/workbox/-/workbox-0.0.0.tgz",
|
||||
"integrity": "sha512-/I5JIWHK18DDGGoXOZgOkOFLsiMQZlHLnwEzw328ZMU4TA21yFCw11YEnZ1CsOnSazl0DMbFmLJ6q5hpQhP/aQ==",
|
||||
"dependencies": {
|
||||
"babel-runtime": "6.x.x"
|
||||
}
|
||||
},
|
||||
"node_modules/workbox-background-sync": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/workbox-background-sync/-/workbox-background-sync-7.0.0.tgz",
|
||||
|
@ -102,6 +102,7 @@
|
||||
"uuid": "^9.0.1",
|
||||
"webpack-bundle-analyzer": "^4.10.1",
|
||||
"winston": "^3.11.0",
|
||||
"workbox": "^0.0.0",
|
||||
"xlsx": "https://cdn.sheetjs.com/xlsx-0.19.1/xlsx-0.19.1.tgz",
|
||||
"xlsx-style": "^0.8.13",
|
||||
"xml-js": "^1.6.11",
|
||||
|
@ -28,13 +28,6 @@ export default function App({
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
{/* Other tags */}
|
||||
<link
|
||||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
</Head>
|
||||
<SessionProvider session={session} >
|
||||
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
||||
<Component {...pageProps} />
|
||||
|
@ -7,6 +7,10 @@ class MyDocument extends Document {
|
||||
<Head>
|
||||
<link rel="manifest" href="/manifest.json" />
|
||||
<link rel="apple-touch-icon" href="/favicon.png"></link>
|
||||
<link
|
||||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<meta name="theme-color" content="#e36600" />
|
||||
</Head>
|
||||
<body>
|
||||
|
@ -290,6 +290,8 @@ export default async function handler(req, res) {
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case "sendNewAssignmentEmails":
|
||||
default:
|
||||
return res.status(400).json({ message: "Invalid action" });
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ export default function MySchedulePage({ assignments }) {
|
||||
Добави в календар
|
||||
</button>
|
||||
<button
|
||||
className="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
|
||||
className="mr-2 mb-2 inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-green-600 hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
|
||||
onClick={() => {
|
||||
setАssignment(assignment);
|
||||
setIsModalOpen(true)
|
||||
@ -122,7 +122,7 @@ export default function MySchedulePage({ assignments }) {
|
||||
Избери Заместник
|
||||
</button>
|
||||
<button
|
||||
className="inline-flex items-center px-3 mx-2 py-2 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
|
||||
className="mr-2 mb-2 inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
|
||||
onClick={() => searchReplacement(assignment.id)}
|
||||
>
|
||||
Търси заместник
|
||||
|
@ -20,7 +20,7 @@
|
||||
"dir": "auto",
|
||||
"lang": "en-US",
|
||||
"name": "Специално Свидетелстване София",
|
||||
"short_name": "ССС",
|
||||
"start_url": "https://sofia.mwitnessing.com/dash",
|
||||
"scope": "https://sofia.mwitnessing.com/cart"
|
||||
"short_name": "ССС"
|
||||
// "start_url": "https://sofia.mwitnessing.com/dash",
|
||||
// "scope": "https://sofia.mwitnessing.com/cart"
|
||||
}
|
47
server.js
47
server.js
@ -3,10 +3,13 @@ const multer = require('multer');
|
||||
const next = require("next");
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
// const { promises: fs } = require('fs');
|
||||
const dotenv = require("dotenv");
|
||||
const data = require("./src/helpers/data");
|
||||
const sharp = require('sharp');
|
||||
const https = require('https');
|
||||
const { parse } = require('url');
|
||||
const { join } = require('path');
|
||||
|
||||
//const getPort = require("get-port");
|
||||
|
||||
@ -18,7 +21,7 @@ import('get-port').then(module => {
|
||||
|
||||
process.env.TZ = 'Europe/Sofia';
|
||||
// Global variable to store the base URL
|
||||
let baseUrlGlobal;
|
||||
// let baseUrlGlobal;
|
||||
|
||||
console.log("initial process.env.APP_ENV = ", process.env.APP_ENV);
|
||||
console.log("initial process.env.NODE_ENV = ", process.env.NODE_ENV); //NODE_ENV can be passed as docker param
|
||||
@ -84,25 +87,43 @@ else {
|
||||
console.log(`> Ready on ${PROTOCOL}://${HOST}:${PORT}`);
|
||||
});
|
||||
}
|
||||
|
||||
// handlers
|
||||
nextApp
|
||||
.prepare()
|
||||
.then(() => {
|
||||
|
||||
// Add the middleware to set 'x-forwarded-host' header
|
||||
// Middleware to handle the 'x-forwarded-host' header
|
||||
server.use((req, res, next) => {
|
||||
req.headers['x-forwarded-host'] = req.headers['x-forwarded-host'] || req.headers.host;
|
||||
// ---------------
|
||||
if (!baseUrlGlobal) {
|
||||
const protocol = req.headers['x-forwarded-proto'] || 'http';
|
||||
const host = req.headers.host;
|
||||
const baseUrl = `${protocol}://${host}`;
|
||||
baseUrlGlobal = baseUrl;
|
||||
fs.writeFileSync(path.join(__dirname, 'baseUrl.txt'), baseUrlGlobal, 'utf8');
|
||||
console.log("baseUrlGlobal set to: " + baseUrlGlobal);
|
||||
}
|
||||
next();
|
||||
});
|
||||
// Middleware to handle service worker and specific js files
|
||||
server.use(async (req, res, next) => {
|
||||
const parsedUrl = parse(req.url, true);
|
||||
const { pathname } = parsedUrl;
|
||||
|
||||
// Check if the request is for a service worker or a specific js file
|
||||
// if (pathname === '/sw.js' || /^\/(workbox|worker|fallback)-\w+\.js$/.test(pathname)) {
|
||||
// const filePath =
|
||||
// join(__dirname, '.next', pathname);
|
||||
// // Use Next.js's serveStatic method to serve the file from the .next directory
|
||||
// try {
|
||||
// const fileContent = fs.readFileSync(filePath);
|
||||
// res.setHeader('Content-Type', 'application/javascript');
|
||||
// res.send(fileContent);
|
||||
// } catch (err) {
|
||||
// // If there's an error (file not found, etc.), pass to the next handler
|
||||
// next(err);
|
||||
// }
|
||||
// } else {
|
||||
// // For all other requests, proceed to the next middleware
|
||||
// next();
|
||||
// }
|
||||
|
||||
});
|
||||
|
||||
|
||||
server.use("/favicon.ico", express.static("styles/favicon_io/favicon.ico"));
|
||||
// server.use("/robots.txt", express.static("styles/favicon_io/robots.txt"));
|
||||
// server.use("/sitemap.xml", express.static("styles/favicon_io/sitemap.xml"));
|
||||
@ -659,5 +680,5 @@ async function Stat() {
|
||||
|
||||
Stat();
|
||||
|
||||
exports.baseUrlGlobal = baseUrlGlobal;
|
||||
exports.default = nextApp;
|
||||
// exports.baseUrlGlobal = baseUrlGlobal;
|
||||
// exports.default = nextApp;
|
||||
|
Reference in New Issue
Block a user