Skip to content

Commit 06951ad

Browse files
committed
Updated request logger feature to use new .bigint(), since .hrtime() is deprecated. Various improvements to QOL (including a few more comments). Updated Bootstrap version; MANY breaking changes (see: https://react-bootstrap.github.io/migrating/). Added Github CodeQL config. Built a couple more tests.
1 parent c9f023d commit 06951ad

File tree

106 files changed

+28055
-15755
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+28055
-15755
lines changed

.babelrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"presets": [
33
["@babel/preset-env", {"useBuiltIns": "usage", "corejs": 3}],
4-
"@babel/preset-react"
4+
["@babel/preset-react", {"runtime": "automatic"}]
55
]
66
}

.eslintignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
assets/dependencies/**/*.js
22
views/**/*.ejs
3-
3+
test/coverage/**/*

.eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"plugins": [
3636
"react"
3737
],
38-
"parser": "babel-eslint",
38+
"parser": "@babel/eslint-parser",
3939
"parserOptions": {
4040
"ecmaFeatures": {
4141
"jsx": true,

.github/workflows/codeql-analysis.yml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ release ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ release ]
20+
schedule:
21+
- cron: '38 4 * * 5'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'javascript' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
37+
# Learn more:
38+
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
39+
40+
steps:
41+
- name: Checkout repository
42+
uses: actions/checkout@v2
43+
44+
# Initializes the CodeQL tools for scanning.
45+
- name: Initialize CodeQL
46+
uses: github/codeql-action/init@v1
47+
with:
48+
languages: ${{ matrix.language }}
49+
# If you wish to specify custom queries, you can do so here or in a config file.
50+
# By default, queries listed here will override any specified in a config file.
51+
# Prefix the list here with "+" to use these queries and those in the config file.
52+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
53+
54+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55+
# If this step fails, then you should remove it and run the build manually (see below)
56+
- name: Autobuild
57+
uses: github/codeql-action/autobuild@v1
58+
59+
# ℹ️ Command-line programs to run using the OS shell.
60+
# 📚 https://git.io/JvXDl
61+
62+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
63+
# and modify them (or add more) to build your code if your project
64+
# uses a compiled language
65+
66+
#- run: |
67+
# make bootstrap
68+
# make release
69+
70+
- name: Perform CodeQL Analysis
71+
uses: github/codeql-action/analyze@v1

.idea/codeStyles/Project.xml

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

.idea/codeStyles/codeStyleConfig.xml

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

.idea/runConfigurations/Count_Lines.xml

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

.idea/runConfigurations/Lint.xml

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

.idea/runConfigurations/Start__Front_and_Back_.xml

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

CHANGELOG.md

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Changelog
2+
3+
This changelog is incomplete, as it was not started until **v2** (and rehashing that far back in the past is a lot of work for very little gain). I've gone as far back as this template became "popular" (people other than me began to clone it).
4+
5+
# [v2.0.0](https://github.com/neonexus/sails-react-bootstrap-webpack/compare/v1.9.0...v2.0.0) (2021-99-99)
6+
7+
### Features
8+
9+
* Updated to Bootstrap v5. There are several **breaking changes** between [Bootstrap v4](https://getbootstrap.com/docs/4.6) and [Bootstrap v5](https://getbootstrap.com/docs/5.1), see the [migration documentation](https://getbootstrap.com/docs/5.1/migration/) for the complete list of breaking changes.
10+
* Updated all dependencies to most recent versions.
11+
* Built out more tests to get better coverage.
12+
* Created this CHANGELOG.
13+
14+
# [v1.9.0](https://github.com/neonexus/sails-react-bootstrap-webpack/compare/v1.8.1...v1.9.0) (2020-08-30)
15+
16+
### Features
17+
18+
* Created a better handling of the custom API layer for React. Removed need for `<APIConsumer>` in favor of state.
19+
* Updated the React demo to use a navbar.
20+
21+
### Breaking Changes
22+
23+
* Removed `<APIConsumer>`. Must now pass around a state property (or some other form of variable).
24+
25+
# [v1.8.1](https://github.com/neonexus/sails-react-bootstrap-webpack/compare/v1.8.0...v1.8.1) (2020-08-30)
26+
27+
### Features
28+
29+
* Created API token handling (bearer tokens). Should only be used over HTTPs or for local testing tools.
30+
* Added a `<noscript>` message to the entry template.
31+
32+
# [v1.8.0](https://github.com/neonexus/sails-react-bootstrap-webpack/compare/v1.7.0...v1.8.0) (2020-08-26)
33+
34+
### Features
35+
36+
* Removed need for EJS to have Sails serve the different entry points (marketing vs admin).
37+
38+
# [v1.7.0](https://github.com/neonexus/sails-react-bootstrap-webpack/compare/v1.6.0...v1.7.0) (2020-08-25)
39+
40+
### Features
41+
42+
* Created pagination helpers; one for model queries, one for API output.
43+
* Created README in `.idea` (IntelliJ) folder.
44+
45+
# [v1.6.0](https://github.com/neonexus/sails-react-bootstrap-webpack/compare/v1.5.2...v1.6.0) (2020-08-16)
46+
47+
### Features
48+
49+
* Created `Dockerfile`.
50+
* Added a few more comments.
51+
* Updated NPM packages.
52+
* Built better testing for project hook.
53+
54+
# [v1.5.2](https://github.com/neonexus/sails-react-bootstrap-webpack/compare/v1.5.1...v1.5.2) (2020-08-10)
55+
56+
### Features
57+
58+
* Fixed webpack config.
59+
* Made `isLoggedIn` policy clear cookie if not logged in.

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:12.18
1+
FROM node:14.8
22
MAINTAINER NeoNexus DeMortis
33

44
RUN apt-get update && apt-get upgrade -y

README.md

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# sails-react-bootstrap-webpack
22

3-
This is an opinionated base [Sails v1](https://sailsjs.com) application, using Webpack to handle Bootstrap (SASS) and React builds. It is designed such that, one can build multiple React frontends (an admin panel, and a customer site maybe), that use the same API backend. This allows developers to easily share React components across different frontends / applications. Also, because the backend and frontend are in the same repo (and the frontend is compiled before it is handed to the end user), they can share NPM libraries, like [Moment.js](https://momentjs.com)
3+
This is an opinionated base [Sails v1](https://sailsjs.com) application, using [Webpack](https://webpack.js.org) to handle [Bootstrap](https://getbootstrap.com) (using [SASS](https://sass-lang.com)) and [React](https://reactjs.org) builds. It is designed such that, one can build multiple React frontends (an admin panel, and a customer site maybe), that use the same API backend. This allows developers to easily share React components across different frontends / applications. Also, because the backend and frontend are in the same repo (and the frontend is compiled before it is handed to the end user), they can share [NPM](http://npmjs.com) libraries, like [Moment.js](https://momentjs.com)
44

55
Need help? Want to hire me to build your next app or prototype? You can contact me any time via Gitter: [![Join the chat at https://gitter.im/sails-react-bootstrap-webpack/community](https://badges.gitter.im/sails-react-bootstrap-webpack/community.svg)](https://gitter.im/sails-react-bootstrap-webpack/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
66

@@ -13,7 +13,7 @@ The `master` branch is experimental, and the [release branch](https://github.com
1313

1414
## Main Features
1515

16-
+ Automatic (incoming) request logging, via Sails models / hooks.
16+
+ Automatic (incoming) request logging (manual outgoing), via Sails models / hooks.
1717
+ Setup for Webpack auto-reload dev server.
1818
+ Setup so Sails will serve Webpack-built bundles as separate apps (so, a marketing site, and an admin site can live side-by-side).
1919
+ Includes [react-bootstrap](https://www.npmjs.com/package/react-bootstrap) to make using Bootstrap styles / features with React easier.
@@ -62,25 +62,25 @@ Automatic incoming request logging, is a 2 part process. First, the [`request-lo
6262

6363
## Using Webpack
6464
#### Local Dev
65-
The script `npm run open:client` will start the auto-reloading Webpack development server, and open a browser window.
65+
The script `npm run open:client` will start the auto-reloading Webpack development server, and open a browser window. When you save changes to assets (React files mainly), it will auto-compile the update, then refresh the browser automatically.
6666

6767
#### Remote Builds
6868
The script `npm run build` will make Webpack build all the proper assets into the `.tmp/public` folder. Sails will serve assets from this folder.
6969

7070
If you want to build assets, but retain spaces / tabs for debugging, you can use `npm run build:dev`.
7171

7272
#### Configuration
73-
The webpack configuration can be found in the `webpack` folder. The majority of the configuration can be found in [`common.config.js`](webpack/common.config.js). Then, the other 3 files, such as [`dev.config.js`](webpack/dev.config.js) extend the `common.config.js` file.
73+
The webpack configuration can be found in the [`webpack`](webpack) folder. The majority of the configuration can be found in [`common.config.js`](webpack/common.config.js). Then, the other 3 files, such as [`dev.config.js`](webpack/dev.config.js) extend the `common.config.js` file.
7474

7575
## Building with React
7676
React source files live in the `assets/src` folder. It is structured in such a way, where the `index.jsx` is really only used for local development (to help Webpack serve up the correct "app"). Then, there are the individual "apps", [main](assets/src/main.jsx) and [admin](assets/src/admin.jsx). These files are used as Webpack "[entry points](https://webpack.js.org/concepts/entry-points/)", to create 2 separate application bundles.
7777

78-
In a remote environment, Sails will look at the first subdirectory requested, and use that to determine which `index.html` file it needs to actually return. So, in this case, the "main" application will get built in `.tmp/public/main`, where the CSS is `.tmp/public/main/bundle.css`, the JavaScript is `.tmp/public/main/bundle.js`, and the HTML is `.tmp/public/main/index.html`. To view the main application, one would just go to `http://mydomain/` which gets redirected to `/main` (because we need to know what application we are using, we need a subdirectory), and now Sails will serve the `main` application. Whereas, if one were to go to `http://mydomain/admin`, Sails would now serve the `admin` application bundle (aka `.tmp/public/admin/index.html`).
78+
In a remote environment, Sails will look at the first subdirectory requested, and use that to determine which `index.html` file it needs to actually return. So, in this case, the "main" application will get built in `.tmp/public/main`, where the CSS is `.tmp/public/main/bundle.css`, the JavaScript is `.tmp/public/main/bundle.js`, and the HTML is `.tmp/public/main/index.html`. To view the main application, one would just go to `http://mydomain/` which gets redirected to `/main` (because we need to know what application we are using, we need a subdirectory), and now Sails will serve the `main` application. Whereas, if one were to go to `http://mydomain/admin`, Sails would now serve the `admin` application bundle (aka `.tmp/public/admin/index.html`, `.tmp/public/admin/bundle.css`, etc...).
7979

8080
## Schema Validation and Enforcement
81-
Inside [`config/bootstrap.js`](config/bootstrap.js) is a bit of logic (**HEAVILY ROOTED IN NATIVE `MySQL` QUERIES**), which validates column types in the `PRODUCTION` database (aka `sails.config.models.migrate === 'safe'`), then will validate foreign key indexes. If there are too many columns, or there is a missing index, or incorrect column type, the logic will `console.error` any issues, then `process.exit(1)` (kill) the Sails server. The idea here, is that if anything is out of alignment, Sails will fail to lift, which will mean failure to deploy on AWS.
81+
Inside [`config/bootstrap.js`](config/bootstrap.js) is a bit of logic (**HEAVILY ROOTED IN NATIVE `MySQL` QUERIES**), which validates column types in the `PRODUCTION` database (aka `sails.config.models.migrate === 'safe'`), then will validate foreign key indexes. If there are too many columns, or there is a missing index, or incorrect column type, the logic will `console.error` any issues, then `process.exit(1)` (kill) the Sails server. The idea here, is that if anything is out of alignment, Sails will fail to lift, which will mean failure to deploy on PRODUCTION, preventing accidental, invalid live deployments; a final safety net if you will.
8282

83-
### If you do not want schema validation
83+
### If you DO NOT want schema validation
8484
... then you have 2 options:
8585
* Set `sails.config.models.validateOnBootstrap = false` at the bottom of [`config/models.js`](config/models.js).
8686
* OR replace the contents of `config/bootstrap.js` with the following:
@@ -102,7 +102,9 @@ middleware: {
102102
'cookieParser',
103103
'session',
104104
'bodyParser',
105-
'prerender', // reference our custom middleware found below
105+
'prerender', // reference our custom middleware found below;
106+
// we run this before compression and routing,
107+
// because it is a proxy, saving time a resources
106108
'compress',
107109
'router',
108110
'assetLog',
@@ -132,7 +134,9 @@ This app was originally generated on Fri Mar 20 2020 17:39:04 GMT-0500 (Central
132134

133135
<!-- Internally, Sails used [`sails-generate@1.16.13`](https://github.com/balderdashy/sails-generate/tree/v1.16.13/lib/core-generators/new). -->
134136

137+
#### Code Coverage
135138

139+
The current code coverage [can be viewed here](https://htmlpreview.github.io/?https://github.com/neonexus/sails-react-bootstrap-webpack/blob/release/test/coverage/index.html).
136140

137141
<!--
138142
Note: Generators are usually run using the globally-installed `sails` CLI (command-line interface). This CLI version is _environment-specific_ rather than app-specific, thus over time, as a project's dependencies are upgraded or the project is worked on by different developers on different computers using different versions of Node.js, the Sails dependency in its package.json file may differ from the globally-installed Sails CLI release it was originally generated with. (Be sure to always check out the relevant [upgrading guides](https://sailsjs.com/upgrading) before upgrading the version of Sails used by your app. If you're stuck, [get help here](https://sailsjs.com/support).)

0 commit comments

Comments
 (0)