Skip to content

Commit 71e46f9

Browse files
authored
Merge pull request #116 from neonexus/master (v5.0.0)
Fixed the Ngrok script to use Sails' internal configuration loader. Updated deps. Made interactive things.
2 parents 0b0c00a + 82ab95f commit 71e46f9

29 files changed

+1671
-1140
lines changed

.idea/dictionaries/neonexus.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/Start_Frontend.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.travis.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,4 @@ services: mysql
88
before_install:
99
- mysql -e 'CREATE DATABASE IF NOT EXISTS testing;'
1010
- mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'mypass'"
11-
after_success: npm run codecov
12-
deploy:
13-
skip_cleanup: true
11+
script: npm run codecov

CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog
22

3+
## [v5.0.0](https://github.com/neonexus/sails-react-bootstrap-webpack/compare/v4.3.1...v5.0.0) (2023-12-05)
4+
### Features
5+
6+
* Made [`app.js`](app.js) executable, so now you can run `./app.js` directly.
7+
* Rewrote how the Ngrok script reads Sails' config files (now uses Sails' internal config loader).
8+
* Fixed Travis / Codecov integration (so now it's not running the test suite twice).
9+
* Created the `enforceForeignKeys` config option, to make testing PRODUCTION locally easier.
10+
* Changed the configuration for PRODUCTION's `DATA_ENCRYPTION_KEY`. Will now throw an error on boot if not supplied.
11+
* Made [`bootstrap.js`](config/bootstrap.js) enforce use of either `app.js` or `ngrok.js` through detection of `NOT_FROM_SAILS_LIFT` environment variable.
12+
* Created a new configuration file ([`config/ngrok.js`](config/ngrok.js)) for [ngrok.js](ngrok.js).
13+
* Fixed relative links in README.
14+
* Created the [`setup.js`](setup.js) script for easy interactive configuration.
15+
* Made `npm run create:admin` interactive.
16+
* Updated dependencies.
17+
318
## [v4.3.1](https://github.com/neonexus/sails-react-bootstrap-webpack/compare/v4.3.0...v4.3.1) (2023-11-05)
419
### Features
520

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ MAINTAINER NeoNexus DeMortis
44
RUN mkdir /var/www && mkdir /var/www/myapp
55
WORKDIR /var/www/myapp
66

7-
# If you change the exposed port, you need to also change the environment variable PORT below to the same port, or nothing will work
7+
# If you change the exposed port, you need to also change the environment variable PORT below to the same port, or nothing will work.
88
EXPOSE 1337
99
# REMEMBER! NEVER STORE SECRETS, DEK's, PASSWORDS, OR ANYTHING OF A SENSITIVE NATURE IN SOURCE CONTROL (INCLUDING THIS FILE)! USE ENVIRONMENT VARIABLES!
10-
ENV PORT=1337 DB_HOSTNAME=dockerdb DB_USERNAME=dockeruser DB_PASSWORD=dockerpass DB_NAME=docker DB_PORT=3306 DB_SSL=true DATA_ENCRYPTION_KEY=1234abcd4321asdf0987lkjh SESSION_SECRET=0987poiuqwer1234zxcvmnbv
10+
ENV PORT=1337 DB_HOSTNAME=dockerdb DB_USERNAME=dockeruser DB_PASSWORD=dockerpass DB_NAME=docker DB_PORT=3306 DB_SSL=true DATA_ENCRYPTION_KEY=null SESSION_SECRET=null
1111

1212
# This keeps builds more efficient, because we can use Docker cache more effectively.
1313
COPY package.json package.json

README.md

+161-105
Large diffs are not rendered by default.

api/helpers/generate-token.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const moment = require('moment-timezone');
77
* @function sails.helpers.generateToken
88
* @param {String} [extra='Evil will always triumph, because good is dumb. -Lord Helmet'] - A bit of random, extra bits to change up the hash.
99
*
10-
* @returns {String} A SHA256 hash of a cryptographically-secure, randomly generated string of characters.
10+
* @returns {String} A SHA512 hash of a cryptographically-secure, randomly generated string of characters.
1111
*/
1212
module.exports = {
1313
friendlyName: 'Generate Token',

api/helpers/is-password-valid.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module.exports = {
3737
isPassPhrase = false;
3838

3939
if (inputs.password.length < 7) {
40-
errors.push('Password must be at least 7 characters');
40+
errors.push('Password must be at least 7 characters.');
4141
}
4242

4343
if (inputs.password.length > 70) {
@@ -52,37 +52,37 @@ module.exports = {
5252

5353
if (inputs.user) {
5454
if (inputs.user.email && inputs.password.indexOf(inputs.user.email) >= 0) {
55-
errors.push('Password can not contain your email address');
55+
errors.push('Password can not contain your email address.');
5656
}
5757

5858
if (inputs.user.firstName && inputs.password.indexOf(inputs.user.firstName) >= 0) {
59-
errors.push('Password can not contain your first name');
59+
errors.push('Password can not contain your first name.');
6060
}
6161

6262
if (inputs.user.lastName && inputs.password.indexOf(inputs.user.lastName) >= 0) {
63-
errors.push('Password can not contain your last name');
63+
errors.push('Password can not contain your last name.');
6464
}
6565
}
6666

6767
if (/(.)\1{2,}/.test(inputs.password)) {
68-
errors.push('Password can not contain 3 or more repeated characters');
68+
errors.push('Password can not contain 3 or more repeated characters.');
6969
}
7070

7171
if (!isPassPhrase) {
7272
if (!/(?=[a-z])/.test(inputs.password)) {
73-
errors.push('Password must have at least 1 lowercase character');
73+
errors.push('Password must have at least 1 lowercase character.');
7474
}
7575

7676
if (!/(?=[A-Z])/.test(inputs.password)) {
77-
errors.push('Password must have at least 1 uppercase character');
77+
errors.push('Password must have at least 1 uppercase character.');
7878
}
7979

8080
if (!/(?=[0-9])/.test(inputs.password)) {
81-
errors.push('Password must have at least 1 digit');
81+
errors.push('Password must have at least 1 digit.');
8282
}
8383

8484
if (!/(?=[^a-zA-Z0-9])/.test(inputs.password)) {
85-
errors.push('Password must have at least 1 special character');
85+
errors.push('Password must have at least 1 special character.');
8686
}
8787
}
8888

@@ -120,7 +120,7 @@ module.exports = {
120120
}
121121

122122
/* istanbul ignore next */
123-
return exits.success(['Unknown internal error']);
123+
return exits.success(['Unknown internal error when talking with PwnedPasswords.com.']);
124124
});
125125
} else {
126126
return exits.success(true);

app.js

100644100755
+17-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
#!/usr/bin/env node
2+
13
/**
24
* app.js
35
*
46
* Use `app.js` to run your app without `sails lift`.
57
* To start the server, run: `node app.js`.
8+
* Or directly: `./app.js`.
69
*
710
* This is handy in situations where the sails CLI is not relevant or useful,
811
* such as when you deploy to a server, or a PaaS like Heroku.
@@ -38,22 +41,26 @@ try {
3841
console.error('Encountered an error when attempting to require(\'sails\'):');
3942
console.error(err.stack);
4043
console.error('--');
41-
console.error('To run an app using `node app.js`, you need to have Sails installed');
42-
console.error('locally (`./node_modules/sails`). To do that, just make sure you\'re');
43-
console.error('in the same directory as your app and run `npm install`.');
44-
console.error();
45-
console.error('If Sails is installed globally (i.e. `npm install -g sails`) you can');
46-
console.error('also run this app with `sails lift`. Running with `sails lift` will');
47-
console.error('not run this file (`app.js`), but it will do exactly the same thing.');
48-
console.error('(It even uses your app directory\'s local Sails install, if possible.)');
49-
return;
44+
console.error('Did you run `npm install`?');
5045
}//-•
5146

47+
// Small safety trigger, to help prevent use of `sails lift`, as that circumvents our custom error handlers / configuration overrides.
48+
process.env.NOT_FROM_SAILS_LIFT = 'true'; // Can't use booleans with environment variables... That's just silly!
5249

5350
// Start server
5451
sails.lift(rc('sails'), (err, server) => {
5552
if (err) {
56-
return console.error(err);
53+
switch (err.code) {
54+
case 'E_INVALID_DATA_ENCRYPTION_KEYS':
55+
return console.error(
56+
'\nSails is complaining about bad DEK\'s (Data Encryption Keys).'
57+
+ '\nThis is likely caused by running as PRODUCTION without a DATA_ENCRYPTION_KEY environment variable set.'
58+
+ '\n\nThe DEK ID that is being reported as invalid: ' + err.dekId
59+
+ '\n\nTo generate a new DEK: npm run generate:dek\n'
60+
);
61+
default:
62+
return console.error(err);
63+
}
5764
}
5865

5966
console.log('');

assets/styles/common/common.scss

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
$bootstrap-icons-font-dir: "~bootstrap-icons/font/fonts";
22
@import "~bootstrap-icons/font/bootstrap-icons";
33

4-
body {
5-
transition: all ease .5s;
6-
}
7-
84
// fixes a flashing issue when changing themes
95
.nav-item .nav-link.active, table {
10-
transition: all ease .5s;
6+
//transition: all ease .5s;
117
}
128

139
// .prevent-validation class

config/autoreload.js

+21-15
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,28 @@
77
* For more info, see: https://www.npmjs.com/package/sails-hook-autoreload
88
*/
99

10-
module.exports.autoreload = {
11-
active: true,
10+
module.exports = {
11+
autoreload: {
12+
active: true,
1213

13-
dirs: [
14-
'api/controllers',
15-
'api/helpers',
16-
'api/hooks',
17-
'api/models',
18-
'api/policies',
19-
'api/responses',
20-
'config'
21-
],
14+
dirs: [
15+
'api/controllers',
16+
'api/helpers',
17+
'api/hooks',
18+
'api/models',
19+
'api/policies',
20+
'api/responses',
21+
'config'
22+
],
2223

23-
ignored: [
24-
'**.md'
25-
],
24+
ignored: [
25+
'**.md'
26+
],
2627

27-
overrideMigrateSetting: false
28+
overrideMigrateSetting: false
29+
},
30+
31+
models: {
32+
archiveModelIdentity: false
33+
}
2834
};

0 commit comments

Comments
 (0)