Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/adding dark light mode functionality #1167

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 77 additions & 77 deletions backend/src/handlers/errorHandlers.js
Original file line number Diff line number Diff line change
@@ -1,77 +1,77 @@
/*
Catch Errors Handler
With async/await, you need some way to catch errors
Instead of using try{} catch(e) {} in each controller, we wrap the function in
catchErrors(), catch any errors they throw, and pass it along to our express middleware with next()
*/
exports.catchErrors = (fn) => {
return function (req, res, next) {
return fn(req, res, next).catch((error) => {
if (error.name == 'ValidationError') {
return res.status(400).json({
success: false,
result: null,
message: 'Required fields are not supplied',
controller: fn.name,
error: error,
});
} else {
// Server Error
return res.status(500).json({
success: false,
result: null,
message: error.message,
controller: fn.name,
error: error,
});
}
});
};
};
/*
Not Found Error Handler
If we hit a route that is not found, we mark it as 404 and pass it along to the next error handler to display
*/
exports.notFound = (req, res, next) => {
return res.status(404).json({
success: false,
message: "Api url doesn't exist ",
});
};
/*
Development Error Handler
In development we show good error messages so if we hit a syntax error or any other previously un-handled error, we can show good info on what happened
*/
exports.developmentErrors = (error, req, res, next) => {
error.stack = error.stack || '';
const errorDetails = {
message: error.message,
status: error.status,
stackHighlighted: error.stack.replace(/[a-z_-\d]+.js:\d+:\d+/gi, '<mark>$&</mark>'),
};
return res.status(500).json({
success: false,
message: error.message,
error: error,
});
};
/*
Production Error Handler
No stacktraces are leaked to admin
*/
exports.productionErrors = (error, req, res, next) => {
return res.status(500).json({
success: false,
message: error.message,
error: error,
});
};
/*
Catch Errors Handler

With async/await, you need some way to catch errors
Instead of using try{} catch(e) {} in each controller, we wrap the function in
catchErrors(), catch any errors they throw, and pass it along to our express middleware with next()
*/

exports.catchErrors = (fn) => {
return function (req, res, next) {
return fn(req, res, next).catch((error) => {
if (error.name == 'ValidationError') {
return res.status(400).json({
success: false,
result: null,
message: 'Required fields are not supplied',
controller: fn.name,
error: error,
});
} else {
// Server Error
return res.status(500).json({
success: false,
result: null,
message: error.message,
controller: fn.name,
error: error,
});
}
});
};
};

/*
Not Found Error Handler

If we hit a route that is not found, we mark it as 404 and pass it along to the next error handler to display
*/
exports.notFound = (req, res, next) => {
return res.status(404).json({
success: false,
message: "Api url doesn't exist ",
});
};

/*
Development Error Handler

In development we show good error messages so if we hit a syntax error or any other previously un-handled error, we can show good info on what happened
*/
exports.developmentErrors = (error, req, res, next) => {
error.stack = error.stack || '';
const errorDetails = {
message: error.message,
status: error.status,
stackHighlighted: error.stack.replace(/[a-z_-\d]+.js:\d+:\d+/gi, '<mark>$&</mark>'),
};

return res.status(500).json({
success: false,
message: error.message,
error: error,
});
};

/*
Production Error Handler

No stacktraces are leaked to admin
*/
exports.productionErrors = (error, req, res, next) => {
return res.status(500).json({
success: false,
message: error.message,
error: error,
});
};
146 changes: 73 additions & 73 deletions backend/src/models/coreModels/Upload.js
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
const mongoose = require('mongoose');
const uploadSchema = new mongoose.Schema({
removed: {
type: Boolean,
default: false,
},
enabled: {
type: Boolean,
default: true,
},
modelName: {
type: String,
trim: true,
},
fieldId: {
type: String,
required: true,
},
fileName: {
type: String,
required: true,
},
fileType: {
type: String,
enum: [
'jpeg',
'jpg',
'png',
'gif',
'webp',
'doc',
'txt',
'csv',
'docx',
'xls',
'xlsx',
'pdf',
'zip',
'rar',
'mp4',
'mov',
'avi',
'mp3',
'm4a',
'webm',
],
required: true,
},
isPublic: {
type: Boolean,
required: true,
},
userID: {
type: mongoose.SchemaTypes.ObjectId,
required: true,
},
isSecure: {
type: Boolean,
required: true,
},
path: {
type: String,
required: true,
},
created: {
type: Date,
default: Date.now,
},
});
module.exports = mongoose.model('Upload ', uploadSchema);
const mongoose = require('mongoose');

const uploadSchema = new mongoose.Schema({
removed: {
type: Boolean,
default: false,
},
enabled: {
type: Boolean,
default: true,
},

modelName: {
type: String,
trim: true,
},
fieldId: {
type: String,
required: true,
},
fileName: {
type: String,
required: true,
},
fileType: {
type: String,
enum: [
'jpeg',
'jpg',
'png',
'gif',
'webp',
'doc',
'txt',
'csv',
'docx',
'xls',
'xlsx',
'pdf',
'zip',
'rar',
'mp4',
'mov',
'avi',
'mp3',
'm4a',
'webm',
],
required: true,
},
isPublic: {
type: Boolean,
required: true,
},
userID: {
type: mongoose.SchemaTypes.ObjectId,
required: true,
},
isSecure: {
type: Boolean,
required: true,
},
path: {
type: String,
required: true,
},
created: {
type: Date,
default: Date.now,
},
});

module.exports = mongoose.model('Upload ', uploadSchema);
48 changes: 24 additions & 24 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/dist
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/dist

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

19 changes: 12 additions & 7 deletions frontend/src/RootApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,22 @@ import { BrowserRouter } from 'react-router-dom';
import { Provider } from 'react-redux';
import store from '@/redux/store';
import PageLoader from '@/components/PageLoader';
import { ThemeProvider } from './components/Theme/ThemeContext'
import ThemeToggle from 'components/Theme/ThemeToggle'

const IdurarOs = lazy(() => import('./apps/IdurarOs'));

export default function RoutApp() {
return (
<BrowserRouter>
<Provider store={store}>
<Suspense fallback={<PageLoader />}>
<IdurarOs />
</Suspense>
</Provider>
</BrowserRouter>
<ThemeProvider>
<BrowserRouter>
<Provider store={store}>
<Suspense fallback={<PageLoader />}>
<IdurarOs />
<ThemeToggle />
</Suspense>
</Provider>
</BrowserRouter>
</ThemeProvider>
);
}
Loading
Loading