Skip to content

Commit b0da59d

Browse files
committed
Readme update; added .idea run configuration demos.
1 parent 54b0671 commit b0da59d

File tree

4 files changed

+42
-18
lines changed

4 files changed

+42
-18
lines changed

.idea/runConfigurations/Start_API.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/Start_Frontend.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
This is an opinionated base [Sails v1](https://sailsjs.com) application, using Webpack to handle Bootstrap (SASS) and React.
44

5+
## Main Features
6+
7+
+ [Automatic (incoming) request logging, via Sails models / hooks.](#request-logging)
8+
+ [Setup for Webpack auto-reload dev server.](#local-dev)
9+
+ Setup so Sails will serve Webpack-built bundles as separate apps (so, a marketing site, and an admin site can live side-by-side).
10+
+ Includes [react-bootstrap](https://www.npmjs.com/package/react-bootstrap) to make using Bootstrap styles / features with React easier.
11+
12+
### Request Logging
13+
Automatic incoming request logging, is a 2 part process. First, the [`request-logger` hook](api/hooks/request-logger.js) gathers info from the quest, and creates a new [`RequestLog` record](api/models/RequestLog.js), making sure to mask anything that may be sensitive, such as passwords. Then, a custom response gathers information from the response, again, scrubbing sensitive data (using the [customToJSON](https://sailsjs.com/documentation/concepts/models-and-orm/model-settings?identity=#customtojson) feature of Sails models) to prevent leaking of password hashes, or anything else that should never be publicly accessible. The [`keepModelsSafe` helper](api/helpers/keep-models-safe.js) and the custom responses (such as [ok](api/responses/ok.js) or [serverError](api/responses/serverError.js)) are responsible for the final leg of request logs.
14+
15+
### Using Webpack
16+
#### Local Dev
17+
The script `npm run open:client` will start the auto-reloading Webpack development server, and open a browser window.
18+
19+
#### Remote Builds
20+
The script `npm run build` will make Webpack build all the proper assets into the `.tmp` folder. Sails will serve assets from this folder.
21+
22+
If you want to build assets, but retain spaces / tabs for debugging, you can use `npm run build:dev`.
523

624
### Links
725

api/hooks/request-logger.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ module.exports = (sails) => {
7474
body: body
7575
}).meta({fetch: true}).exec(async (err, newRequest) => {
7676
if (err) {
77-
//utils.createLog(req, err, 'Error creating request audit log');
7877
console.log(err);
7978

8079
return next(); // don't stop the traffic if there is a problem
@@ -83,23 +82,6 @@ module.exports = (sails) => {
8382
req.requestId = newRequest.id;
8483
req._customStartTime = process.hrtime();
8584

86-
// if (sails.config.requiredHosts && sails.config.requiredHosts.length) {
87-
// let isValid = false;
88-
//
89-
// for (let i = 0; i < sails.config.requiredHosts.length; ++i) {
90-
// if (req.hostname === sails.config.requiredHosts[i]) {
91-
// isValid = true;
92-
// i = sails.config.requiredHosts.length; // no need to continue
93-
// }
94-
// }
95-
//
96-
// if (!isValid) {
97-
// res.status(404);
98-
// res.view('404');
99-
// await sails.helpers.finalizeRequestLog(req, res, {body: '404 from logger'});
100-
// }
101-
// }
102-
10385
return next();
10486
});
10587
} else {

0 commit comments

Comments
 (0)