Skip to content

Commit e3e402e

Browse files
committed
feat: add workspace with vite project
1 parent 931942e commit e3e402e

22 files changed

+27741
-16359
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ node_modules/
33
bundles/
44
PIG/bundles/
55
Parse-Dashboard/public/bundles/
6+
Parse-Dashboard/v2/
67
Parse-Dashboard/parse-dashboard-config.json
78
npm-debug.log
89
.eslintcache
@@ -17,3 +18,6 @@ test_logs
1718

1819
# visual studio code
1920
.vscode
21+
22+
.history
23+
.turbo

Dockerfile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,25 @@ COPY . /src
2121
# Install remaining dev dependencies
2222
RUN npm ci
2323

24-
# Run all webpack build steps
25-
RUN npm run prepare && npm run build
24+
############################################################
25+
# Build stage v2
26+
############################################################
27+
FROM node:lts-alpine AS v2-build
28+
29+
RUN apk --no-cache add git
30+
WORKDIR /src
31+
32+
# Copy package.json first to benefit from layer caching
33+
COPY v2/package*.json ./
34+
35+
# Install dependencies
36+
RUN npm ci
37+
38+
# Copy src to have webpack config files ready for install
39+
COPY ./v2 ./
40+
41+
# Run build step
42+
RUN npm run build
2643

2744
############################################################
2845
# Release stage
@@ -36,6 +53,7 @@ COPY --from=build /src/package*.json /src/
3653

3754
# Copy compiled src dirs
3855
COPY --from=build /src/Parse-Dashboard/ /src/Parse-Dashboard/
56+
COPY --from=v2-build /Parse-Dashboard/v2 /src/Parse-Dashboard/v2
3957

4058
USER node
4159

Parse-Dashboard/app.js

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ function checkIfIconsExistForApps(apps, iconsFolder) {
3636
const iconName = currentApp.iconName;
3737
const path = iconsFolder + '/' + iconName;
3838

39-
fs.stat(path, function(err) {
39+
fs.stat(path, function (err) {
4040
if (err) {
41-
if ('ENOENT' == err.code) {// file does not exist
42-
console.warn('Icon with file name: ' + iconName + ' couldn\'t be found in icons folder!');
41+
if ('ENOENT' == err.code) {
42+
// file does not exist
43+
console.warn('Icon with file name: ' + iconName + " couldn't be found in icons folder!");
4344
} else {
44-
console.log(
45-
'An error occurd while checking for icons, please check permission!');
45+
console.log('An error occurd while checking for icons, please check permission!');
4646
}
4747
} else {
4848
//every thing was ok so for example you can read it and send it to client
@@ -51,37 +51,42 @@ function checkIfIconsExistForApps(apps, iconsFolder) {
5151
}
5252
}
5353

54-
module.exports = function(config, options) {
54+
module.exports = function (config, options) {
5555
options = options || {};
5656
const app = express();
5757
// Serve public files.
58-
app.use(express.static(path.join(__dirname,'public')));
58+
app.use(express.static(path.join(__dirname, 'public')));
5959

6060
// Allow setting via middleware
6161
if (config.trustProxy && app.disabled('trust proxy')) {
6262
app.enable('trust proxy');
6363
}
6464

6565
// wait for app to mount in order to get mountpath
66-
app.on('mount', function() {
66+
app.on('mount', function () {
6767
const mountPath = getMount(app.mountpath);
6868
const users = config.users;
6969
const useEncryptedPasswords = config.useEncryptedPasswords ? true : false;
7070
const authInstance = new Authentication(users, useEncryptedPasswords, mountPath);
71-
authInstance.initialize(app, { cookieSessionSecret: options.cookieSessionSecret, cookieSessionMaxAge: options.cookieSessionMaxAge });
71+
authInstance.initialize(app, {
72+
cookieSessionSecret: options.cookieSessionSecret,
73+
cookieSessionMaxAge: options.cookieSessionMaxAge,
74+
});
7275

7376
// CSRF error handler
7477
app.use(function (err, req, res, next) {
75-
if (err.code !== 'EBADCSRFTOKEN') {return next(err)}
78+
if (err.code !== 'EBADCSRFTOKEN') {
79+
return next(err);
80+
}
7681

7782
// handle CSRF token errors here
78-
res.status(403)
79-
res.send('form tampered with')
83+
res.status(403);
84+
res.send('form tampered with');
8085
});
8186

8287
// Serve the configuration.
83-
app.get('/parse-dashboard-config.json', function(req, res) {
84-
const apps = config.apps.map((app) => Object.assign({}, app)); // make a copy
88+
app.get('/parse-dashboard-config.json', function (req, res) {
89+
const apps = config.apps.map(app => Object.assign({}, app)); // make a copy
8590
const response = {
8691
apps: apps,
8792
newFeaturesInLatestVersion: newFeaturesInLatestVersion,
@@ -96,12 +101,18 @@ module.exports = function(config, options) {
96101
if (!options.dev && !requestIsLocal) {
97102
if (!req.secure && !options.allowInsecureHTTP) {
98103
//Disallow HTTP requests except on localhost, to prevent the master key from being transmitted in cleartext
99-
return res.send({ success: false, error: 'Parse Dashboard can only be remotely accessed via HTTPS' });
104+
return res.send({
105+
success: false,
106+
error: 'Parse Dashboard can only be remotely accessed via HTTPS',
107+
});
100108
}
101109

102110
if (!users) {
103111
//Accessing the dashboard over the internet can only be done with username and password
104-
return res.send({ success: false, error: 'Configure a user to access Parse Dashboard remotely' });
112+
return res.send({
113+
success: false,
114+
error: 'Configure a user to access Parse Dashboard remotely',
115+
});
105116
}
106117
}
107118
const authentication = req.user;
@@ -111,7 +122,7 @@ module.exports = function(config, options) {
111122
const isReadOnly = authentication && authentication.isReadOnly;
112123
// User is full read-only, replace the masterKey by the read-only one
113124
if (isReadOnly) {
114-
response.apps = response.apps.map((app) => {
125+
response.apps = response.apps.map(app => {
115126
app.masterKey = app.readOnlyMasterKey;
116127
if (!app.masterKey) {
117128
throw new Error('You need to provide a readOnlyMasterKey to use read-only features.');
@@ -131,7 +142,7 @@ module.exports = function(config, options) {
131142
app.masterKey = app.readOnlyMasterKey;
132143
}
133144
return isSame;
134-
})
145+
});
135146
});
136147
}
137148
// They provided correct auth
@@ -167,13 +178,15 @@ module.exports = function(config, options) {
167178
}
168179
} catch (e) {
169180
// Directory doesn't exist or something.
170-
console.warn('Iconsfolder at path: ' + config.iconsFolder +
171-
' not found!');
181+
console.warn('Iconsfolder at path: ' + config.iconsFolder + ' not found!');
172182
}
173183
}
174184

175-
app.get('/login', csrf(), function(req, res) {
176-
const redirectURL = req.url.includes('?redirect=') && req.url.split('?redirect=')[1].length > 1 && req.url.split('?redirect=')[1];
185+
app.get('/login', csrf(), function (req, res) {
186+
const redirectURL =
187+
req.url.includes('?redirect=') &&
188+
req.url.split('?redirect=')[1].length > 1 &&
189+
req.url.split('?redirect=')[1];
177190
if (!users || (req.user && req.user.isAuthenticated)) {
178191
return res.redirect(`${mountPath}${redirectURL || 'apps'}`);
179192
}
@@ -182,7 +195,7 @@ module.exports = function(config, options) {
182195
if (errors && errors.length) {
183196
errors = `<div id="login_errors" style="display: none;">
184197
${errors.join(' ')}
185-
</div>`
198+
</div>`;
186199
}
187200
res.send(`<!DOCTYPE html>
188201
<html>
@@ -205,7 +218,7 @@ module.exports = function(config, options) {
205218
});
206219

207220
// For every other request, go to index.html. Let client-side handle the rest.
208-
app.get('/*', function(req, res) {
221+
app.get('/*', function (req, res, next) {
209222
if (users && (!req.user || !req.user.isAuthenticated)) {
210223
const redirect = req.url.replace('/login', '');
211224
if (redirect.length > 1) {
@@ -216,7 +229,8 @@ module.exports = function(config, options) {
216229
if (users && req.user && req.user.matchingUsername) {
217230
res.append('username', req.user.matchingUsername);
218231
}
219-
res.send(`<!DOCTYPE html>
232+
if (!req.path.startsWith('/v2')) {
233+
res.send(`<!DOCTYPE html>
220234
<html>
221235
<head>
222236
<link rel="shortcut icon" type="image/x-icon" href="${mountPath}favicon.ico" />
@@ -232,8 +246,11 @@ module.exports = function(config, options) {
232246
</body>
233247
</html>
234248
`);
249+
} else {
250+
next();
251+
}
235252
});
236253
});
237254

238255
return app;
239-
}
256+
};

0 commit comments

Comments
 (0)