Skip to content

Commit b6b0af6

Browse files
authored
Merge pull request #7 from neonexus/master
Added a few more comments. Updated NPM packages. Built better testing for project hook. Added Dockerfile.
2 parents 49936e8 + 37a2a30 commit b6b0af6

28 files changed

+980
-967
lines changed

.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules
2+
.git
3+
.gitignore
4+
config/local.js
5+
.tmp
6+
.idea
7+
8+
README.md
9+
LICENSE

.idea/dictionaries/neonexusdemortis.xml

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

.mocharc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ async-only: true # require use of "done" cb or an async function (a Promise)
33
require:
44
- 'test/hooks.js'
55
spec: 'test/**/*.test.js'
6-
timeout: 5000 # Give Sails some breathing room... We are building schemas / data fixtures.
6+
timeout: 10000 # Give Sails some breathing room... We are building schemas / data fixtures.
77
checkLeaks: true
88
global:
99
- '_'

.sailsrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"hooks": {
1010
"grunt": false,
1111
"session": false,
12-
"csrf": false
12+
"csrf": false,
13+
"blueprints": false
1314
}
1415
}

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM node:12.18
2+
MAINTAINER NeoNexus DeMortis
3+
4+
RUN apt-get update && apt-get upgrade -y
5+
RUN apt-get install -y curl ntp nano
6+
RUN mkdir /var/www && mkdir /var/www/myapp
7+
WORKDIR /var/www/myapp
8+
9+
EXPOSE 1337
10+
# REMEMBER! NEVER STORE SECRETS, DEK's, PASSWORDS, OR ANYTHING OF A SENSITIVE NATURE IN SOURCE CONTROL! USE ENVIRONMENT VARIABLES!
11+
ENV PORT=1337 DB_HOSTNAME=localhost DB_USERNAME=user DB_PASSWORD=pass DB_NAME=myappdb DB_PORT=3306 DB_SSL=true DATA_ENCRYPTION_KEY=1234abcd4321asdf0987lkjh SESSION_SECRET=0987poiuqwer1234zxcvmnbv
12+
13+
# This keeps builds more efficient, because we can use cache more effectively.
14+
COPY package.json /var/www/myapp/package.json
15+
RUN npm install
16+
17+
COPY . /var/www/myapp/
18+
RUN npm run build
19+
20+
# Expose the compiled public assets, so Nginx can route to them, instead of using Sails to do the file serving.
21+
VOLUME /var/www/myapp/.tmp/public
22+
23+
CMD NODE_ENV=production node app.js --max-stack-size 32000

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# sails-react-bootstrap-webpack
22

3-
[![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)
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)
44

5-
This is an opinionated base [Sails v1](https://sailsjs.com) application, using Webpack to handle Bootstrap (SASS) and React.
5+
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

77
# Branch Warning
88
The `master` branch is experimental, and the [release branch](https://github.com/neonexus/sails-react-bootstrap-webpack/tree/release) (or the [`releases section`](https://github.com/neonexus/sails-react-bootstrap-webpack/releases)) is where one should base their use of this template.
@@ -22,6 +22,9 @@ The `master` branch is experimental, and the [release branch](https://github.com
2222
## How to Use
2323
This repo is not installable via `npm`. Instead, Github provides a handy "Use this template" (green) button at the top of this page. That will create a special fork of this repo (so there is a single, init commit, instead of the commit history from this repo).
2424

25+
### Configuration
26+
In the `config` folder, there is `local.js.sample` file, which is meant to be copied to `local.js`. This file is ignored by Git, and intended for use in local development, not remote servers.
27+
2528
### Scripts built into [`package.json`](package.json):
2629

2730
| Command | Description

api/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,34 @@ This is where all API controllers, custom hooks, helpers, models, policies and r
66

77
Controllers handle API requests, and decide how to respond, using the custom responses, which track API requests in our datastore.
88

9+
See: [Actions and Controllers](https://sailsjs.com/documentation/concepts/actions-and-controllers)
10+
911
## Helpers
1012

1113
Helpers are generic, reusable functions used by multiple controllers (or hooks, policies, etc).
1214

15+
See: [Helpers](https://sailsjs.com/documentation/concepts/helpers)
16+
1317
## Hooks
1418

1519
Custom hooks (currently only the 1), are used to tap into different parts of a request. The custom hook setup in this repo, is designed to start recording an API request, while the custom responses finalize the record.
1620

21+
See: [Project Hooks](https://sailsjs.com/documentation/concepts/extending-sails/hooks/project-hooks)
22+
1723
## Models
1824

1925
The data models inform Sails (really Waterline) how to create / modify tables (if `sails.config.models.migrate === 'alter'`), or our custom [schema validation and enforcement](../README.md#schema-validation-and-enforcement) on how it should behave.
2026

27+
See: [Models](https://sailsjs.com/documentation/concepts/models-and-orm/models)
28+
2129
## Policies
2230

2331
Policies are simple functions, that determine if a request should continue, or fail. These are configured in [`config/policies.js`](../config/policies.js)
2432

33+
See: [Policies](https://sailsjs.com/documentation/concepts/policies)
34+
2535
## Responses
2636

2737
These custom responses handle the final leg of request logging. They are responsible for ensuring data isn't leaked, by utilizing the `customToJSON` functionality of models.
38+
39+
See: [Custom Responses](https://sailsjs.com/documentation/concepts/extending-sails/custom-responses)

api/controllers/admin/login.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ module.exports = {
6363
}).fetch();
6464

6565
return exits.ok({
66+
// Cookies are automatically handled in our custom response `ok`.
6667
cookies: [
6768
{
6869
name: sails.config.session.name,

api/helpers/generate-token.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = {
1111
inputs: {
1212
extra: {
1313
type: 'string',
14+
description: 'A bit of random, extra bits to change up the hash.',
1415
defaultsTo: 'Evil will always triumph, because good is dumb. -Lord Helmet'
1516
}
1617
},
@@ -23,7 +24,7 @@ module.exports = {
2324
.update(
2425
crypto.randomBytes(21)
2526
+ moment(new Date()).format()
26-
+ 'I am a little tea pot'
27+
+ 'I am a tea pot' // The best HTTP status code
2728
+ inputs.extra
2829
+ crypto.randomBytes(21)
2930
)

0 commit comments

Comments
 (0)