parent
5d6e061e1c
commit
3bb34d5d18
|
@ -0,0 +1,3 @@
|
||||||
|
assets/dependencies/**/*.js
|
||||||
|
views/**/*.ejs
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
{
|
||||||
|
// ╔═╗╔═╗╦ ╦╔╗╔╔╦╗┬─┐┌─┐
|
||||||
|
// ║╣ ╚═╗║ ║║║║ ║ ├┬┘│
|
||||||
|
// o╚═╝╚═╝╩═╝╩╝╚╝ ╩ ┴└─└─┘
|
||||||
|
// A set of basic code conventions (similar to a .jshintrc file) designed to
|
||||||
|
// encourage quality and consistency across your Sails app's code base.
|
||||||
|
// These rules are checked against automatically any time you run `npm test`.
|
||||||
|
//
|
||||||
|
// > An additional eslintrc override file is included in the `assets/` folder
|
||||||
|
// > right out of the box. This is specifically to allow for variations in acceptable
|
||||||
|
// > global variables between front-end JavaScript code designed to run in the browser
|
||||||
|
// > vs. backend code designed to run in a Node.js/Sails process.
|
||||||
|
//
|
||||||
|
// > Note: If you're using mocha, you'll want to add an extra override file to your
|
||||||
|
// > `test/` folder so that eslint will tolerate mocha-specific globals like `before`
|
||||||
|
// > and `describe`.
|
||||||
|
// Designed for ESLint v4.
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
// For more information about any of the rules below, check out the relevant
|
||||||
|
// reference page on eslint.org. For example, to get details on "no-sequences",
|
||||||
|
// you would visit `http://eslint.org/docs/rules/no-sequences`. If you're unsure
|
||||||
|
// or could use some advice, come by https://sailsjs.com/support.
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
|
"env": {
|
||||||
|
"node": true
|
||||||
|
},
|
||||||
|
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 8,
|
||||||
|
"ecmaFeatures": {
|
||||||
|
"experimentalObjectRestSpread": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"globals": {
|
||||||
|
// If "no-undef" is enabled below, be sure to list all global variables that
|
||||||
|
// are used in this app's backend code (including the globalIds of models):
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
"Promise": true,
|
||||||
|
"sails": true,
|
||||||
|
"_": true,
|
||||||
|
"async": true
|
||||||
|
// …and any others (e.g. `"Organization": true`)
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
},
|
||||||
|
|
||||||
|
"rules": {
|
||||||
|
"callback-return": ["error", ["done", "proceed", "next", "onwards", "callback", "cb"]],
|
||||||
|
"camelcase": ["warn", {"properties":"always"}],
|
||||||
|
"comma-style": ["warn", "last"],
|
||||||
|
"curly": ["error"],
|
||||||
|
"eqeqeq": ["error", "always"],
|
||||||
|
"eol-last": ["warn"],
|
||||||
|
"handle-callback-err": ["error"],
|
||||||
|
"indent": ["warn", 2, {
|
||||||
|
"SwitchCase": 1,
|
||||||
|
"MemberExpression": "off",
|
||||||
|
"FunctionDeclaration": {"body":1, "parameters":"off"},
|
||||||
|
"FunctionExpression": {"body":1, "parameters":"off"},
|
||||||
|
"CallExpression": {"arguments":"off"},
|
||||||
|
"ArrayExpression": 1,
|
||||||
|
"ObjectExpression": 1,
|
||||||
|
"ignoredNodes": ["ConditionalExpression"]
|
||||||
|
}],
|
||||||
|
"linebreak-style": ["error", "unix"],
|
||||||
|
"no-dupe-keys": ["error"],
|
||||||
|
"no-duplicate-case": ["error"],
|
||||||
|
"no-extra-semi": ["warn"],
|
||||||
|
"no-labels": ["error"],
|
||||||
|
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
|
||||||
|
"no-redeclare": ["warn"],
|
||||||
|
"no-return-assign": ["error", "always"],
|
||||||
|
"no-sequences": ["error"],
|
||||||
|
"no-trailing-spaces": ["warn"],
|
||||||
|
"no-undef": ["off"],
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
// ^^Note: If this "no-undef" rule is enabled (set to `["error"]`), then all model globals
|
||||||
|
// (e.g. `"Organization": true`) should be included above under "globals".
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
"no-unexpected-multiline": ["warn"],
|
||||||
|
"no-unreachable": ["warn"],
|
||||||
|
"no-unused-vars": ["warn", {"caughtErrors":"all", "caughtErrorsIgnorePattern": "^unused($|[A-Z].*$)", "argsIgnorePattern": "^unused($|[A-Z].*$)", "varsIgnorePattern": "^unused($|[A-Z].*$)" }],
|
||||||
|
"no-use-before-define": ["error", {"functions":false}],
|
||||||
|
"one-var": ["warn", "never"],
|
||||||
|
"prefer-arrow-callback": ["warn", {"allowNamedFunctions":true}],
|
||||||
|
"quotes": ["warn", "single", {"avoidEscape":false, "allowTemplateLiterals":true}],
|
||||||
|
"semi": ["error", "always"],
|
||||||
|
"semi-spacing": ["warn", {"before":false, "after":true}],
|
||||||
|
"semi-style": ["warn", "last"]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
language: node_js
|
language: node_js
|
||||||
warnings_are_errors: false
|
|
||||||
node_js:
|
node_js:
|
||||||
- "node"
|
- "node"
|
||||||
deploy:
|
deploy:
|
||||||
|
@ -12,7 +11,4 @@ deploy:
|
||||||
env: "example-app-environment"
|
env: "example-app-environment"
|
||||||
bucket_name: "the-target-S3-bucket"
|
bucket_name: "the-target-S3-bucket"
|
||||||
|
|
||||||
before_script:
|
#script: node testfile
|
||||||
- npm install
|
|
||||||
|
|
||||||
script: npm test
|
|
||||||
|
|
10
Gruntfile.js
10
Gruntfile.js
|
@ -12,10 +12,12 @@
|
||||||
* For more information see:
|
* For more information see:
|
||||||
* https://sailsjs.com/anatomy/Gruntfile.js
|
* https://sailsjs.com/anatomy/Gruntfile.js
|
||||||
*/
|
*/
|
||||||
module.exports = function (grunt) {
|
module.exports = function(grunt) {
|
||||||
var loadGruntTasks = require('sails-hook-grunt/accessible/load-grunt-tasks')
|
|
||||||
|
var loadGruntTasks = require('sails-hook-grunt/accessible/load-grunt-tasks');
|
||||||
|
|
||||||
// Load Grunt task configurations (from `tasks/config/`) and Grunt
|
// Load Grunt task configurations (from `tasks/config/`) and Grunt
|
||||||
// task registrations (from `tasks/register/`).
|
// task registrations (from `tasks/register/`).
|
||||||
loadGruntTasks(__dirname, grunt)
|
loadGruntTasks(__dirname, grunt);
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
|
@ -26,3 +26,4 @@ Note: Generators are usually run using the globally-installed `sails` CLI (comm
|
||||||
-->
|
-->
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/miacona96/RoE-pipe.svg?branch=master)](https://travis-ci.org/miacona96/RoE-pipe)
|
[![Build Status](https://travis-ci.org/miacona96/RoE-pipe.svg?branch=master)](https://travis-ci.org/miacona96/RoE-pipe)
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ module.exports = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
passportHelper.callback(req, res, (err, user, info, status) => {
|
passportHelper.callback(req, res, function (err, user, info, status) {
|
||||||
if (err || !user) {
|
if (err || !user) {
|
||||||
sails.log.warn(user, err, info, status)
|
sails.log.warn(user, err, info, status)
|
||||||
if (!err && info) {
|
if (!err && info) {
|
||||||
|
@ -123,7 +123,7 @@ module.exports = {
|
||||||
return negotiateError(err)
|
return negotiateError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
req.login(user, (err) => {
|
req.login(user, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
sails.log.warn(err)
|
sails.log.warn(err)
|
||||||
return negotiateError(err)
|
return negotiateError(err)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
'use strict'
|
|
||||||
/**
|
/**
|
||||||
* BooksController
|
* BooksController
|
||||||
*
|
*
|
||||||
|
@ -6,8 +5,6 @@
|
||||||
* @help :: See https://sailsjs.com/docs/concepts/actions
|
* @help :: See https://sailsjs.com/docs/concepts/actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const HttpError = require('../errors/HttpError')
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
publish: async function (req, res) {
|
publish: async function (req, res) {
|
||||||
try {
|
try {
|
||||||
|
@ -15,36 +12,21 @@ module.exports = {
|
||||||
const host = req.hostname
|
const host = req.hostname
|
||||||
let result
|
let result
|
||||||
|
|
||||||
if (!host) throw new HttpError(400, 'Missing hostname')
|
if (!host) throw new Error('Missing hostname')
|
||||||
if (!body) throw new HttpError(400, 'Missing body')
|
if (!body) throw new Error('Missing body')
|
||||||
if (!body.title || !body.author || !body.version || !req.file('opds')) throw new Error('Body is not formatted correctly')
|
|
||||||
const data = {
|
const bookExists = await Book.findOne(body)
|
||||||
source: host,
|
|
||||||
title: body.title,
|
|
||||||
author: body.author,
|
|
||||||
version: body.version
|
|
||||||
}
|
|
||||||
if (body.isbn) data.isbn = body.isbn
|
|
||||||
const bookExists = await Book.findOne(data)
|
|
||||||
|
|
||||||
if (bookExists) {
|
if (bookExists) {
|
||||||
throw new HttpError(400, 'Version already exists')
|
throw new Error('Version already exists')
|
||||||
} else {
|
} else {
|
||||||
result = await Book.create(data).fetch()
|
result = await Book.create(body)
|
||||||
}
|
}
|
||||||
|
|
||||||
req.file('opds').upload(sails.config.skipperConfig, async function (err, uploaded) {
|
return res.json({
|
||||||
if (err) {
|
...result
|
||||||
await Book.destroy({ id: result.id })
|
|
||||||
throw new HttpError(500, err.message)
|
|
||||||
}
|
|
||||||
await Book.update({ id: result.id }, { storage: uploaded[0].fd })
|
|
||||||
return res.json({
|
|
||||||
...result
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof HttpError) return e.send(res)
|
|
||||||
return res.status(400).json({
|
return res.status(400).json({
|
||||||
error: e.message
|
error: e.message
|
||||||
})
|
})
|
||||||
|
@ -54,16 +36,17 @@ module.exports = {
|
||||||
list: async function (req, res) {
|
list: async function (req, res) {
|
||||||
try {
|
try {
|
||||||
const body = req.allParams()
|
const body = req.allParams()
|
||||||
if (!body) throw new HttpError(400, 'Missing parameters')
|
if (!body) throw new Error('Missing parameters')
|
||||||
const numPerPage = 50
|
|
||||||
const page = body.page || 1
|
|
||||||
|
|
||||||
const books = await Book.find(body).sort('createdAt DESC').skip(page * numPerPage - numPerPage).limit(numPerPage)
|
const books = await Book.find(body)
|
||||||
if (!books.length) throw new HttpError(404, 'No books matching those parameters were found.')
|
|
||||||
|
|
||||||
|
if (!books.length) {
|
||||||
|
return res.status(404).json({
|
||||||
|
error: 'No books matching those parameters were found.'
|
||||||
|
})
|
||||||
|
}
|
||||||
return res.json(books)
|
return res.json(books)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof HttpError) return e.send(res)
|
|
||||||
return res.status(500).json({
|
return res.status(500).json({
|
||||||
error: e.message
|
error: e.message
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,7 +2,6 @@ module.exports = {
|
||||||
show: function (req, res) {
|
show: function (req, res) {
|
||||||
res.view('pages/temp', {
|
res.view('pages/temp', {
|
||||||
email: req.user.email
|
email: req.user.email
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,23 +11,22 @@ module.exports = {
|
||||||
*/
|
*/
|
||||||
create: async function (req, res, next) {
|
create: async function (req, res, next) {
|
||||||
const passportHelper = await sails.helpers.passport()
|
const passportHelper = await sails.helpers.passport()
|
||||||
passportHelper.protocols.local.register(req.body, (err, user) => {
|
passportHelper.protocols.local.register(req.body, function (err, user) {
|
||||||
if (err) {
|
if (err) return res.status(500).json({
|
||||||
return res.status(500).json({
|
error: err.toString()
|
||||||
error: err.toString() })
|
})
|
||||||
}
|
|
||||||
res.json(user)
|
res.json(user)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
update: async function (req, res, next) {
|
update: async function (req, res, next) {
|
||||||
const passportHelper = await sails.helpers.passport()
|
const passportHelper = await sails.helpers.passport()
|
||||||
passportHelper.protocols.local.update(req.body, (err, user) => {
|
passportHelper.protocols.local.update(req.body, function (err, user) {
|
||||||
if (err) {
|
if (err) return res.status(500).json({
|
||||||
return res.status(500).json({
|
error: err.toString()
|
||||||
error: err.toString()
|
})
|
||||||
})
|
|
||||||
}
|
|
||||||
res.json(user)
|
res.json(user)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
class HttpError extends Error {
|
|
||||||
constructor (status, message, hint) {
|
|
||||||
super(message)
|
|
||||||
if (typeof status !== 'number') throw new Error('HttpError status must be an integer')
|
|
||||||
this.status = status
|
|
||||||
this.hint = hint || 'none'
|
|
||||||
}
|
|
||||||
send (res) {
|
|
||||||
return res.status(this.status).json({
|
|
||||||
error: this.message,
|
|
||||||
hint: this.hint
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = HttpError
|
|
|
@ -19,12 +19,12 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const passport = require('passport')
|
const passport = require('passport')
|
||||||
passport.serializeUser((user, next) => {
|
passport.serializeUser(function (user, next) {
|
||||||
next(null, user.id)
|
next(null, user.id)
|
||||||
})
|
})
|
||||||
passport.deserializeUser((id, next) => {
|
passport.deserializeUser(function (id, next) {
|
||||||
return User.findOne({ id: id })
|
return User.findOne({id: id})
|
||||||
.then((user) => {
|
.then(function (user) {
|
||||||
next(null, user)
|
next(null, user)
|
||||||
return user
|
return user
|
||||||
}).catch(next)
|
}).catch(next)
|
||||||
|
@ -37,7 +37,7 @@ function PassportHelper () {
|
||||||
const strategies = sails.config.passport
|
const strategies = sails.config.passport
|
||||||
|
|
||||||
for (const key in strategies) {
|
for (const key in strategies) {
|
||||||
let options = { passReqToCallback: true }
|
let options = {passReqToCallback: true}
|
||||||
let Strategy = strategies[key].strategy
|
let Strategy = strategies[key].strategy
|
||||||
if (key === 'local') {
|
if (key === 'local') {
|
||||||
_.extend(options, {
|
_.extend(options, {
|
||||||
|
@ -72,7 +72,7 @@ function PassportHelper () {
|
||||||
const strategies = sails.config.passport
|
const strategies = sails.config.passport
|
||||||
const provider = req.param('provider')
|
const provider = req.param('provider')
|
||||||
|
|
||||||
if (!_.has(strategies, provider)) { return res.redirect('/login') }
|
if (!_.has(strategies, provider)) return res.redirect('/login')
|
||||||
|
|
||||||
passport.authenticate(provider, {})(req, res, req.next)
|
passport.authenticate(provider, {})(req, res, req.next)
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ function PassportHelper () {
|
||||||
} else if (action === 'disconnect' && req.user) {
|
} else if (action === 'disconnect' && req.user) {
|
||||||
this.protocols.local.disconnect(req, res, next)
|
this.protocols.local.disconnect(req, res, next)
|
||||||
} else {
|
} else {
|
||||||
return next(new Error('Invalid action'))
|
next(new Error('Invalid action'))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (action === 'disconnect' && req.user) {
|
if (action === 'disconnect' && req.user) {
|
||||||
|
@ -111,10 +111,10 @@ function PassportHelper () {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the profile object from passport has an email, use it
|
// if the profile object from passport has an email, use it
|
||||||
if (profile.emails && profile.emails[0]) { userAttrs.email = profile.emails[0].value }
|
if (profile.emails && profile.emails[0]) userAttrs.email = profile.emails[0].value
|
||||||
if (!userAttrs.email) { return next(new Error('No email available')) }
|
if (!userAttrs.email) return next(new Error('No email available'))
|
||||||
|
|
||||||
const passport = await Passport.findOne({
|
const pass = await Passport.findOne({
|
||||||
provider,
|
provider,
|
||||||
identifier: q.identifier.toString()
|
identifier: q.identifier.toString()
|
||||||
})
|
})
|
||||||
|
@ -128,24 +128,25 @@ function PassportHelper () {
|
||||||
...q,
|
...q,
|
||||||
user: user.id
|
user: user.id
|
||||||
})
|
})
|
||||||
|
next(null, user)
|
||||||
} else { // existing user logging in
|
} else { // existing user logging in
|
||||||
if (_.has(q, 'tokens') && q.tokens !== passport.tokens) {
|
if (_.has(q, 'tokens') && q.tokens !== passport.tokens) {
|
||||||
passport.tokens = q.tokens
|
passport.tokens = q.tokens
|
||||||
}
|
}
|
||||||
await passport.save()
|
await passport.save()
|
||||||
user = User.findOne(passport.user)
|
user = User.findOne(passport.user)
|
||||||
|
next(null, user)
|
||||||
}
|
}
|
||||||
return next(null, user)
|
|
||||||
} else { // user logged in and trying to add new Passport
|
} else { // user logged in and trying to add new Passport
|
||||||
if (!passport) {
|
if (!passport) {
|
||||||
await Passport.create({
|
await Passport.create({
|
||||||
...q,
|
...q,
|
||||||
user: req.user.id
|
user: req.user.id
|
||||||
})
|
})
|
||||||
|
next(null, req.user)
|
||||||
} else { // no action, user already logged in and passport exists
|
} else { // no action, user already logged in and passport exists
|
||||||
|
next(null, user)
|
||||||
}
|
}
|
||||||
return next(null, req.user)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.disconnect = async function (req, res, next) {
|
this.disconnect = async function (req, res, next) {
|
||||||
|
@ -161,7 +162,7 @@ function PassportHelper () {
|
||||||
next(null, user)
|
next(null, user)
|
||||||
return user
|
return user
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return next(e)
|
next(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.getPassport = function () {
|
this.getPassport = function () {
|
||||||
|
|
|
@ -15,23 +15,23 @@ module.exports = {
|
||||||
id: {
|
id: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
unique: true,
|
unique: true,
|
||||||
autoIncrement: true
|
autoIncrement: true,
|
||||||
|
columnName: '_id'
|
||||||
},
|
},
|
||||||
source: { type: 'string' },
|
title: {type: 'string', required: true},
|
||||||
storage: { type: 'string' },
|
author: {type: 'string'},
|
||||||
title: { type: 'string', required: true },
|
isbn: {type: 'string'},
|
||||||
author: { type: 'string' },
|
version: {type: 'string'},
|
||||||
version: { type: 'string' },
|
|
||||||
isbn: { type: 'string' }
|
|
||||||
|
|
||||||
// ╔═╗╔╦╗╔╗ ╔═╗╔╦╗╔═╗
|
// ╔═╗╔╦╗╔╗ ╔═╗╔╦╗╔═╗
|
||||||
// ║╣ ║║║╠╩╗║╣ ║║╚═╗
|
// ║╣ ║║║╠╩╗║╣ ║║╚═╗
|
||||||
// ╚═╝╩ ╩╚═╝╚═╝═╩╝╚═╝
|
// ╚═╝╩ ╩╚═╝╚═╝═╩╝╚═╝
|
||||||
|
|
||||||
|
|
||||||
// ╔═╗╔═╗╔═╗╔═╗╔═╗╦╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
|
// ╔═╗╔═╗╔═╗╔═╗╔═╗╦╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
|
||||||
// ╠═╣╚═╗╚═╗║ ║║ ║╠═╣ ║ ║║ ║║║║╚═╗
|
// ╠═╣╚═╗╚═╗║ ║║ ║╠═╣ ║ ║║ ║║║║╚═╗
|
||||||
// ╩ ╩╚═╝╚═╝╚═╝╚═╝╩╩ ╩ ╩ ╩╚═╝╝╚╝╚═╝
|
// ╩ ╩╚═╝╚═╝╚═╝╚═╝╩╩ ╩ ╩ ╩╚═╝╝╚╝╚═╝
|
||||||
|
|
||||||
}
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,8 @@ module.exports = {
|
||||||
id: {
|
id: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
unique: true,
|
unique: true,
|
||||||
autoIncrement: true
|
autoIncrement: true,
|
||||||
|
columnName: '_id'
|
||||||
},
|
},
|
||||||
// local, oauth2, etc
|
// local, oauth2, etc
|
||||||
protocol: {
|
protocol: {
|
||||||
|
|
|
@ -14,7 +14,8 @@ module.exports = {
|
||||||
id: {
|
id: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
unique: true,
|
unique: true,
|
||||||
autoIncrement: true
|
autoIncrement: true,
|
||||||
|
columnName: '_id'
|
||||||
},
|
},
|
||||||
email: {
|
email: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
|
42
app.js
42
app.js
|
@ -20,31 +20,35 @@
|
||||||
* https://sailsjs.com/anatomy/app.js
|
* https://sailsjs.com/anatomy/app.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// Ensure we're in the project directory, so cwd-relative paths work as expected
|
// Ensure we're in the project directory, so cwd-relative paths work as expected
|
||||||
// no matter where we actually lift from.
|
// no matter where we actually lift from.
|
||||||
// > Note: This is not required in order to lift, but it is a convenient default.
|
// > Note: This is not required in order to lift, but it is a convenient default.
|
||||||
process.chdir(__dirname)
|
process.chdir(__dirname);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Attempt to import `sails` dependency, as well as `rc` (for loading `.sailsrc` files).
|
// Attempt to import `sails` dependency, as well as `rc` (for loading `.sailsrc` files).
|
||||||
var sails
|
var sails;
|
||||||
var rc
|
var rc;
|
||||||
try {
|
try {
|
||||||
sails = require('sails')
|
sails = require('sails');
|
||||||
rc = require('sails/accessible/rc')
|
rc = require('sails/accessible/rc');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Encountered an error when attempting to require(\'sails\'):')
|
console.error('Encountered an error when attempting to require(\'sails\'):');
|
||||||
console.error(err.stack)
|
console.error(err.stack);
|
||||||
console.error('--')
|
console.error('--');
|
||||||
console.error('To run an app using `node app.js`, you need to have Sails installed')
|
console.error('To run an app using `node app.js`, you need to have Sails installed');
|
||||||
console.error('locally (`./node_modules/sails`). To do that, just make sure you\'re')
|
console.error('locally (`./node_modules/sails`). To do that, just make sure you\'re');
|
||||||
console.error('in the same directory as your app and run `npm install`.')
|
console.error('in the same directory as your app and run `npm install`.');
|
||||||
console.error()
|
console.error();
|
||||||
console.error('If Sails is installed globally (i.e. `npm install -g sails`) you can')
|
console.error('If Sails is installed globally (i.e. `npm install -g sails`) you can');
|
||||||
console.error('also run this app with `sails lift`. Running with `sails lift` will')
|
console.error('also run this app with `sails lift`. Running with `sails lift` will');
|
||||||
console.error('not run this file (`app.js`), but it will do exactly the same thing.')
|
console.error('not run this file (`app.js`), but it will do exactly the same thing.');
|
||||||
console.error('(It even uses your app directory\'s local Sails install, if possible.)')
|
console.error('(It even uses your app directory\'s local Sails install, if possible.)');
|
||||||
return
|
return;
|
||||||
}// -•
|
}//-•
|
||||||
|
|
||||||
|
|
||||||
// Start server
|
// Start server
|
||||||
sails.lift(rc('sails'))
|
sails.lift(rc('sails'));
|
||||||
|
|
|
@ -53,9 +53,9 @@ export const setLoggedIn = (data) => (dispatch, getState) => {
|
||||||
export const checkEmail = email => async (dispatch, getState) => {
|
export const checkEmail = email => async (dispatch, getState) => {
|
||||||
dispatch(setWorking(true))
|
dispatch(setWorking(true))
|
||||||
dispatch(clearError())
|
dispatch(clearError())
|
||||||
if (/^([a-zA-Z0-9_\-.]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,5})$/.test(email)) {
|
if (/^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/.test(email)) {
|
||||||
try {
|
try {
|
||||||
await Ajax.post({
|
const res = await Ajax.post({
|
||||||
url: '/auth/email_exists',
|
url: '/auth/email_exists',
|
||||||
data: {
|
data: {
|
||||||
email
|
email
|
||||||
|
@ -103,7 +103,7 @@ export const checkPassword = (email, password) => async (dispatch, getState) =>
|
||||||
export const signup = (email, password) => async (dispatch, getState) => {
|
export const signup = (email, password) => async (dispatch, getState) => {
|
||||||
dispatch(setWorking(true))
|
dispatch(setWorking(true))
|
||||||
dispatch(clearError())
|
dispatch(clearError())
|
||||||
if (/^([a-zA-Z0-9_\-.]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,5})$/.test(email)) {
|
if (/^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/.test(email)) {
|
||||||
try {
|
try {
|
||||||
await Ajax.post({
|
await Ajax.post({
|
||||||
url: '/auth/email_available',
|
url: '/auth/email_available',
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
import '../../styles/shared/underlineinput.scss'
|
import STYLE from '../../styles/shared/underlineinput.scss'
|
||||||
|
|
||||||
const UnderlineInput = props => (
|
const UnderlineInput = props => (
|
||||||
<div className='underlined-input'>
|
<div className='underlined-input'>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import '../../styles/shared/carousel.scss'
|
import STYLE from '../../styles/shared/carousel.scss'
|
||||||
|
|
||||||
class Carousel extends React.Component {
|
class Carousel extends React.Component {
|
||||||
constructor () {
|
constructor () {
|
||||||
|
@ -18,7 +18,7 @@ class Carousel extends React.Component {
|
||||||
render () {
|
render () {
|
||||||
return (
|
return (
|
||||||
<section className='carousel-container'>
|
<section className='carousel-container'>
|
||||||
<div className='carousel' style={{ width: this.getWidth(), left: this.getOffset() }}>
|
<div className='carousel' style={{width: this.getWidth(), left: this.getOffset()}}>
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -13,52 +13,45 @@ class AjaxError extends Error {
|
||||||
|
|
||||||
export default class Ajax {
|
export default class Ajax {
|
||||||
static async get (opts) {
|
static async get (opts) {
|
||||||
return Ajax.ajax({
|
if (!opts) opts = {}
|
||||||
...(opts || {}),
|
opts.method = 'get'
|
||||||
method: 'get'
|
return Ajax.ajax(opts)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
static async post (opts) {
|
static async post (opts) {
|
||||||
return Ajax.ajax({
|
if (!opts) opts = {}
|
||||||
...(opts || {}),
|
opts.method = 'post'
|
||||||
method: 'post'
|
return Ajax.ajax(opts)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
static async put (opts) {
|
static async put (opts) {
|
||||||
return Ajax.ajax({
|
if (!opts) opts = {}
|
||||||
...(opts || {}),
|
opts.method = 'put'
|
||||||
method: 'put'
|
return Ajax.ajax(opts)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
static async patch (opts) {
|
static async patch (opts) {
|
||||||
return Ajax.ajax({
|
if (!opts) opts = {}
|
||||||
...(opts || {}),
|
opts.method = 'patch'
|
||||||
method: 'patch'
|
return Ajax.ajax(opts)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
static async delete (opts) {
|
static async delete (opts) {
|
||||||
return Ajax.ajax({
|
if (!opts) opts = {}
|
||||||
...(opts || {}),
|
opts.method = 'delete'
|
||||||
method: 'delete'
|
return Ajax.ajax(opts)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
static async head (opts) {
|
static async head (opts) {
|
||||||
return Ajax.ajax({
|
if (!opts) opts = {}
|
||||||
...(opts || {}),
|
opts.method = 'head'
|
||||||
method: 'head'
|
return Ajax.ajax(opts)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
static async options (opts) {
|
static async options (opts) {
|
||||||
return Ajax.ajax({
|
if (!opts) opts = {}
|
||||||
...(opts || {}),
|
opts.method = 'options'
|
||||||
method: 'options'
|
return Ajax.ajax(opts)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
static ajax (opts) {
|
static ajax (opts) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!opts) { reject(new Error('Missing required options parameter.')) }
|
if (!opts) reject(new Error('Missing required options parameter.'))
|
||||||
if (opts.method) {
|
if (opts.method) {
|
||||||
if (!['get', 'post', 'put', 'patch', 'delete', 'head', 'options'].includes(opts.method.toLowerCase())) { reject(new Error('opts.method must be one of: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS.')) }
|
if (!['get', 'post', 'put', 'patch', 'delete', 'head', 'options'].includes(opts.method.toLowerCase())) reject(new Error('opts.method must be one of: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS.'))
|
||||||
opts.method = opts.method.toUpperCase()
|
opts.method = opts.method.toUpperCase()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +74,7 @@ export default class Ajax {
|
||||||
}
|
}
|
||||||
|
|
||||||
xhr.onload = () => {
|
xhr.onload = () => {
|
||||||
if (xhr.status !== 200) { return xhr.onerror() }
|
if (xhr.status !== 200) return xhr.onerror()
|
||||||
var data = xhr.response
|
var data = xhr.response
|
||||||
resolve({
|
resolve({
|
||||||
data,
|
data,
|
||||||
|
@ -117,9 +110,9 @@ export default class Ajax {
|
||||||
|
|
||||||
xhr.open(opts.method || 'GET', opts.url + qs || window.location.href)
|
xhr.open(opts.method || 'GET', opts.url + qs || window.location.href)
|
||||||
if (opts.headers) {
|
if (opts.headers) {
|
||||||
for (let key in opts.headers) { xhr.setRequestHeader(key, opts.headers[key]) }
|
for (let key in opts.headers) xhr.setRequestHeader(key, opts.headers[key])
|
||||||
}
|
}
|
||||||
if (ajaxcfg.access_token && !(opts.headers || {}).Authorization) { xhr.setRequestHeader('Authorization', 'Bearer ' + ajaxcfg.access_token) }
|
if (ajaxcfg.access_token && !(opts.headers || {}).Authorization) xhr.setRequestHeader('Authorization', 'Bearer ' + ajaxcfg.access_token)
|
||||||
xhr.send(fd)
|
xhr.send(fd)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -139,8 +132,8 @@ export default class Ajax {
|
||||||
}
|
}
|
||||||
// try original request
|
// try original request
|
||||||
xhr.onload = () => {
|
xhr.onload = () => {
|
||||||
if (xhr.status !== 200) { return xhr.onerror() }
|
if (xhr.status !== 200) return xhr.onerror()
|
||||||
if (ajaxcfg.refresh) { ajaxcfg.refresh(xhr.response) }
|
if (ajaxcfg.refresh) ajaxcfg.refresh(xhr.response)
|
||||||
var json = JSON.parse(xhr.response)
|
var json = JSON.parse(xhr.response)
|
||||||
ajaxcfg.access_token = json.access_token
|
ajaxcfg.access_token = json.access_token
|
||||||
ajaxcfg.refresh_token = json.refresh_token
|
ajaxcfg.refresh_token = json.refresh_token
|
||||||
|
@ -156,11 +149,11 @@ export default class Ajax {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
static setTokenData (tokens) {
|
static setTokenData (tokens) {
|
||||||
if (!tokens) { throw new Error('Missing tokens.') }
|
if (!tokens) throw new Error('Missing tokens.')
|
||||||
if (!tokens.access_token && !tokens.refresh_token && !tokens.refresh_url) { throw new Error('Missing at least one of: access_token, refresh_token, refresh_url.') }
|
if (!tokens.access_token && !tokens.refresh_token && !tokens.refresh_url) throw new Error('Missing at least one of: access_token, refresh_token, refresh_url.')
|
||||||
if (tokens.access_token) { ajaxcfg.access_token = tokens.access_token }
|
if (tokens.access_token) ajaxcfg.access_token = tokens.access_token
|
||||||
if (tokens.refresh_token) { ajaxcfg.refresh_token = tokens.refresh_token }
|
if (tokens.refresh_token) ajaxcfg.refresh_token = tokens.refresh_token
|
||||||
if (tokens.refresh_url) { ajaxcfg.refresh_url = tokens.refresh_url }
|
if (tokens.refresh_url) ajaxcfg.refresh_url = tokens.refresh_url
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
static onRefresh (func) {
|
static onRefresh (func) {
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import ReactDOM from 'react-dom'
|
import ReactDOM from 'react-dom'
|
||||||
import Progress from './components/Progress'
|
import Progress from './components/Progress'
|
||||||
import Carousel, { CarouselItem } from './containers/Carousel'
|
import Carousel, {CarouselItem} from './containers/Carousel'
|
||||||
import UnderlineInput from './components/UnderlineInput'
|
import UnderlineInput from './components/UnderlineInput'
|
||||||
import reducer from './reducers/login'
|
import reducer from './reducers/login'
|
||||||
import { setEmail, setPassword, setCarousel, checkEmail, checkPassword, signup } from './actions/login'
|
import {setEmail, setPassword, setCarousel, checkEmail, checkPassword, signup} from './actions/login'
|
||||||
|
|
||||||
import '../styles/login.scss'
|
import STYLE from '../styles/login.scss'
|
||||||
|
|
||||||
class App extends React.Component {
|
class App extends React.Component {
|
||||||
constructor () {
|
constructor () {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import Actions from '../actions/login'
|
import Actions from '../actions/login'
|
||||||
|
|
||||||
const reducer = (state = {}, action) => {
|
const reducer = (state = {}, action) => {
|
||||||
const { type, data } = action
|
const {type, data} = action
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Actions.set_user:
|
case Actions.set_user:
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -19,6 +19,7 @@ module.exports.blueprints = {
|
||||||
|
|
||||||
// actions: false,
|
// actions: false,
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* *
|
* *
|
||||||
* Automatically expose RESTful routes for your models? *
|
* Automatically expose RESTful routes for your models? *
|
||||||
|
@ -27,6 +28,7 @@ module.exports.blueprints = {
|
||||||
|
|
||||||
// rest: true,
|
// rest: true,
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* *
|
* *
|
||||||
* Automatically expose CRUD "shortcut" routes to GET requests? *
|
* Automatically expose CRUD "shortcut" routes to GET requests? *
|
||||||
|
@ -36,4 +38,4 @@ module.exports.blueprints = {
|
||||||
|
|
||||||
// shortcuts: true,
|
// shortcuts: true,
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
* https://sailsjs.com/config/bootstrap
|
* https://sailsjs.com/config/bootstrap
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports.bootstrap = async function (done) {
|
module.exports.bootstrap = async function(done) {
|
||||||
|
|
||||||
// By convention, this is a good place to set up fake data during development.
|
// By convention, this is a good place to set up fake data during development.
|
||||||
//
|
//
|
||||||
// For example:
|
// For example:
|
||||||
|
@ -28,5 +29,6 @@ module.exports.bootstrap = async function (done) {
|
||||||
|
|
||||||
// Don't forget to trigger `done()` when this bootstrap function's logic is finished.
|
// Don't forget to trigger `done()` when this bootstrap function's logic is finished.
|
||||||
// (otherwise your server will never lift, since it's waiting on the bootstrap)
|
// (otherwise your server will never lift, since it's waiting on the bootstrap)
|
||||||
return done()
|
return done();
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
|
@ -20,4 +20,4 @@ module.exports.custom = {
|
||||||
// stripeSecret: 'sk_test_Zzd814nldl91104qor5911gjald',
|
// stripeSecret: 'sk_test_Zzd814nldl91104qor5911gjald',
|
||||||
// …
|
// …
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
module.exports.datastores = {
|
module.exports.datastores = {
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* *
|
* *
|
||||||
* Your app's default datastore. *
|
* Your app's default datastore. *
|
||||||
|
@ -50,6 +51,7 @@ module.exports.datastores = {
|
||||||
// adapter: 'sails-mysql',
|
// adapter: 'sails-mysql',
|
||||||
// url: 'mysql://user:password@host:port/database',
|
// url: 'mysql://user:password@host:port/database',
|
||||||
|
|
||||||
}
|
},
|
||||||
|
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
|
@ -59,15 +59,15 @@ module.exports = {
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* *
|
* *
|
||||||
* More adapter-specific options *
|
* More adapter-specific options *
|
||||||
* *
|
* *
|
||||||
* > For example, for some hosted PostgreSQL providers (like Heroku), the *
|
* > For example, for some hosted PostgreSQL providers (like Heroku), the *
|
||||||
* > extra `ssl: true` option is mandatory and must be provided. *
|
* > extra `ssl: true` option is mandatory and must be provided. *
|
||||||
* *
|
* *
|
||||||
* More info: *
|
* More info: *
|
||||||
* https://sailsjs.com/config/datastores *
|
* https://sailsjs.com/config/datastores *
|
||||||
* *
|
* *
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
// ssl: true,
|
// ssl: true,
|
||||||
|
|
||||||
|
|
|
@ -57,19 +57,17 @@ module.exports = {
|
||||||
// sails_datastores__default__url=mysql://admin:myc00lpAssw2D@db.example.com:3306/my_prod_db
|
// sails_datastores__default__url=mysql://admin:myc00lpAssw2D@db.example.com:3306/my_prod_db
|
||||||
// ```
|
// ```
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
adapter: 'sails-postgresql',
|
|
||||||
url: sails.config.DATASTORE_URL
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* *
|
* *
|
||||||
* More adapter-specific options *
|
* More adapter-specific options *
|
||||||
* *
|
* *
|
||||||
* > For example, for some hosted PostgreSQL providers (like Heroku), the *
|
* > For example, for some hosted PostgreSQL providers (like Heroku), the *
|
||||||
* > extra `ssl: true` option is mandatory and must be provided. *
|
* > extra `ssl: true` option is mandatory and must be provided. *
|
||||||
* *
|
* *
|
||||||
* More info: *
|
* More info: *
|
||||||
* https://sailsjs.com/config/datastores *
|
* https://sailsjs.com/config/datastores *
|
||||||
* *
|
* *
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
// ssl: true,
|
// ssl: true,
|
||||||
|
|
||||||
|
@ -240,8 +238,8 @@ module.exports = {
|
||||||
* *
|
* *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
onlyAllowOrigins: [
|
onlyAllowOrigins: [
|
||||||
'https://ec2-18-219-76-43.us-east-2.compute.amazonaws.com'
|
'https://ec2-18-219-76-43.us-east-2.compute.amazonaws.com',
|
||||||
]
|
],
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* *
|
* *
|
||||||
|
|
|
@ -47,6 +47,6 @@ module.exports.globals = {
|
||||||
* *
|
* *
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
sails: true
|
sails: true,
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
|
@ -63,10 +63,10 @@ module.exports.http = {
|
||||||
* *
|
* *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
bodyParser: (function _configureBodyParser () {
|
// bodyParser: (function _configureBodyParser(){
|
||||||
var skipper = require('skipper')
|
// var skipper = require('skipper');
|
||||||
var middlewareFn = skipper({ strict: true })
|
// var middlewareFn = skipper({ strict: true });
|
||||||
return middlewareFn
|
// return middlewareFn;
|
||||||
})()
|
// })(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ module.exports.i18n = {
|
||||||
* *
|
* *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
locales: ['en', 'es', 'fr', 'de']
|
locales: ['en', 'es', 'fr', 'de'],
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* *
|
* *
|
||||||
|
@ -42,4 +42,4 @@ module.exports.i18n = {
|
||||||
|
|
||||||
// localesDirectory: 'config/locales'
|
// localesDirectory: 'config/locales'
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
|
@ -26,4 +26,4 @@ module.exports.log = {
|
||||||
|
|
||||||
// level: 'info'
|
// level: 'info'
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
module.exports.models = {
|
module.exports.models = {
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* *
|
* *
|
||||||
* Whether the `.create()` and `.update()` model methods should ignore *
|
* Whether the `.create()` and `.update()` model methods should ignore *
|
||||||
|
@ -36,6 +37,7 @@ module.exports.models = {
|
||||||
|
|
||||||
// schema: true,
|
// schema: true,
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* *
|
* *
|
||||||
* How and whether Sails will attempt to automatically rebuild the *
|
* How and whether Sails will attempt to automatically rebuild the *
|
||||||
|
@ -53,6 +55,7 @@ module.exports.models = {
|
||||||
|
|
||||||
// migrate: 'alter',
|
// migrate: 'alter',
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* *
|
* *
|
||||||
* Base attributes that are included in all of your models by default. *
|
* Base attributes that are included in all of your models by default. *
|
||||||
|
@ -66,10 +69,10 @@ module.exports.models = {
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
attributes: {
|
attributes: {
|
||||||
createdAt: { type: 'number', autoCreatedAt: true },
|
createdAt: { type: 'number', autoCreatedAt: true, },
|
||||||
updatedAt: { type: 'number', autoUpdatedAt: true },
|
updatedAt: { type: 'number', autoUpdatedAt: true, },
|
||||||
id: { type: 'number', autoIncrement: true }
|
id: { type: 'number', autoIncrement: true, },
|
||||||
// --------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
// /\ Using MongoDB?
|
// /\ Using MongoDB?
|
||||||
// || Replace `id` above with this instead:
|
// || Replace `id` above with this instead:
|
||||||
//
|
//
|
||||||
|
@ -79,9 +82,10 @@ module.exports.models = {
|
||||||
//
|
//
|
||||||
// Plus, don't forget to configure MongoDB as your default datastore:
|
// Plus, don't forget to configure MongoDB as your default datastore:
|
||||||
// https://sailsjs.com/docs/tutorials/using-mongo-db
|
// https://sailsjs.com/docs/tutorials/using-mongo-db
|
||||||
// --------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* *
|
* *
|
||||||
* The set of DEKs (data encryption keys) for at-rest encryption. *
|
* The set of DEKs (data encryption keys) for at-rest encryption. *
|
||||||
|
@ -100,6 +104,7 @@ module.exports.models = {
|
||||||
default: 'nuF29j3StsGhRTut9dIrCxCNyYegcwH30FxnZ3kkdiA='
|
default: 'nuF29j3StsGhRTut9dIrCxCNyYegcwH30FxnZ3kkdiA='
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* *
|
* *
|
||||||
* Whether or not implicit records for associations should be cleaned up *
|
* Whether or not implicit records for associations should be cleaned up *
|
||||||
|
@ -115,4 +120,5 @@ module.exports.models = {
|
||||||
|
|
||||||
cascadeOnDestroy: true
|
cascadeOnDestroy: true
|
||||||
|
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
|
@ -24,7 +24,7 @@ module.exports.protocols = {
|
||||||
const user = await User.findOne({
|
const user = await User.findOne({
|
||||||
email: identifier
|
email: identifier
|
||||||
})
|
})
|
||||||
if (!user) { throw new Error('an account with that email was not found') }
|
if (!user) throw new Error('an account with that email was not found')
|
||||||
|
|
||||||
const passport = await Passport.findOne({
|
const passport = await Passport.findOne({
|
||||||
protocol: 'local',
|
protocol: 'local',
|
||||||
|
@ -32,7 +32,7 @@ module.exports.protocols = {
|
||||||
})
|
})
|
||||||
if (passport) {
|
if (passport) {
|
||||||
const res = await Passport.validatePassword(password, passport)
|
const res = await Passport.validatePassword(password, passport)
|
||||||
if (!res) { throw new Error('incorrect password') }
|
if (!res) throw new Error('incorrect password')
|
||||||
return next(null, user)
|
return next(null, user)
|
||||||
} else {
|
} else {
|
||||||
throw new Error('that account does not have password login enabled')
|
throw new Error('that account does not have password login enabled')
|
||||||
|
@ -45,7 +45,7 @@ module.exports.protocols = {
|
||||||
try {
|
try {
|
||||||
const token = generateToken()
|
const token = generateToken()
|
||||||
const password = user.password
|
const password = user.password
|
||||||
if (!password.length) { throw new Error('password cannot be blank') }
|
if (!password.length) throw new Error('password cannot be blank')
|
||||||
delete user.password
|
delete user.password
|
||||||
|
|
||||||
const newUser = await User.create(user).fetch()
|
const newUser = await User.create(user).fetch()
|
||||||
|
@ -93,7 +93,7 @@ module.exports.protocols = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const EMAIL_REGEX = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{2,})$/i
|
const EMAIL_REGEX = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i
|
||||||
|
|
||||||
function validateEmail (email) {
|
function validateEmail (email) {
|
||||||
return EMAIL_REGEX.test(email)
|
return EMAIL_REGEX.test(email)
|
||||||
|
|
|
@ -66,14 +66,17 @@ module.exports.routes = {
|
||||||
'POST /api/publish': 'BooksController.publish',
|
'POST /api/publish': 'BooksController.publish',
|
||||||
|
|
||||||
'GET /api/books': 'BooksController.list',
|
'GET /api/books': 'BooksController.list',
|
||||||
'GET /api/me': 'UserController.me'
|
'GET /api/me': 'UserController.me',
|
||||||
|
|
||||||
|
|
||||||
// ╦ ╦╔═╗╔╗ ╦ ╦╔═╗╔═╗╦╔═╔═╗
|
// ╦ ╦╔═╗╔╗ ╦ ╦╔═╗╔═╗╦╔═╔═╗
|
||||||
// ║║║║╣ ╠╩╗╠═╣║ ║║ ║╠╩╗╚═╗
|
// ║║║║╣ ╠╩╗╠═╣║ ║║ ║╠╩╗╚═╗
|
||||||
// ╚╩╝╚═╝╚═╝╩ ╩╚═╝╚═╝╩ ╩╚═╝
|
// ╚╩╝╚═╝╚═╝╩ ╩╚═╝╚═╝╩ ╩╚═╝
|
||||||
|
|
||||||
|
|
||||||
// ╔╦╗╦╔═╗╔═╗
|
// ╔╦╗╦╔═╗╔═╗
|
||||||
// ║║║║╚═╗║
|
// ║║║║╚═╗║
|
||||||
// ╩ ╩╩╚═╝╚═╝
|
// ╩ ╩╩╚═╝╚═╝
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ module.exports.security = {
|
||||||
// allowCredentials: false,
|
// allowCredentials: false,
|
||||||
// },
|
// },
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* *
|
* *
|
||||||
* By default, Sails' built-in CSRF protection is disabled to facilitate *
|
* By default, Sails' built-in CSRF protection is disabled to facilitate *
|
||||||
|
@ -50,4 +51,4 @@ module.exports.security = {
|
||||||
|
|
||||||
// csrf: false
|
// csrf: false
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
|
@ -18,7 +18,8 @@ module.exports.session = {
|
||||||
* of your users, forcing them to log in again. *
|
* of your users, forcing them to log in again. *
|
||||||
* *
|
* *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
secret: 'b7f0374251c4d79227067c286fe97ea5'
|
secret: 'b7f0374251c4d79227067c286fe97ea5',
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* *
|
* *
|
||||||
|
@ -35,4 +36,4 @@ module.exports.session = {
|
||||||
// return !!req.path.match(req._sails.LOOKS_LIKE_ASSET_RX);
|
// return !!req.path.match(req._sails.LOOKS_LIKE_ASSET_RX);
|
||||||
// },
|
// },
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
|
@ -29,6 +29,7 @@ module.exports.sockets = {
|
||||||
|
|
||||||
// transports: [ 'websocket' ],
|
// transports: [ 'websocket' ],
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* *
|
* *
|
||||||
* `beforeConnect` *
|
* `beforeConnect` *
|
||||||
|
@ -49,6 +50,7 @@ module.exports.sockets = {
|
||||||
//
|
//
|
||||||
// },
|
// },
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* *
|
* *
|
||||||
* `afterDisconnect` *
|
* `afterDisconnect` *
|
||||||
|
@ -66,6 +68,7 @@ module.exports.sockets = {
|
||||||
//
|
//
|
||||||
// },
|
// },
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* *
|
* *
|
||||||
* Whether to expose a 'GET /__getcookie' route that sets an HTTP-only *
|
* Whether to expose a 'GET /__getcookie' route that sets an HTTP-only *
|
||||||
|
@ -75,4 +78,5 @@ module.exports.sockets = {
|
||||||
|
|
||||||
// grant3rdPartyCookie: true,
|
// grant3rdPartyCookie: true,
|
||||||
|
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
|
@ -38,4 +38,4 @@ module.exports.views = {
|
||||||
|
|
||||||
layout: 'layouts/layout'
|
layout: 'layouts/layout'
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
22
package.json
22
package.json
|
@ -11,7 +11,6 @@
|
||||||
"async": "2.0.1",
|
"async": "2.0.1",
|
||||||
"base64url": "^3.0.0",
|
"base64url": "^3.0.0",
|
||||||
"bcrypt": "^3.0.2",
|
"bcrypt": "^3.0.2",
|
||||||
"eslint-plugin-react": "^7.11.1",
|
|
||||||
"express-rate-limit": "^3.2.1",
|
"express-rate-limit": "^3.2.1",
|
||||||
"forever": "^0.15.3",
|
"forever": "^0.15.3",
|
||||||
"grunt": "^1.0.3",
|
"grunt": "^1.0.3",
|
||||||
|
@ -24,26 +23,23 @@
|
||||||
"sails": "^1.0.2",
|
"sails": "^1.0.2",
|
||||||
"sails-hook-grunt": "^3.0.2",
|
"sails-hook-grunt": "^3.0.2",
|
||||||
"sails-hook-orm": "^2.1.1",
|
"sails-hook-orm": "^2.1.1",
|
||||||
"sails-hook-sockets": "^1.4.0",
|
"sails-hook-sockets": "^1.4.0"
|
||||||
"sails-postgresql": "^1.0.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@sailshq/eslint": "^4.19.3",
|
||||||
"@babel/core": "^7.1.2",
|
"@babel/core": "^7.1.2",
|
||||||
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
|
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
|
||||||
"@babel/polyfill": "^7.0.0",
|
"@babel/polyfill": "^7.0.0",
|
||||||
"@babel/preset-env": "^7.1.0",
|
"@babel/preset-env": "^7.1.0",
|
||||||
"@babel/preset-react": "^7.0.0",
|
"@babel/preset-react": "^7.0.0",
|
||||||
"babel-eslint": "^10.0.1",
|
|
||||||
"babel-loader": "^8.0.4",
|
"babel-loader": "^8.0.4",
|
||||||
"css-loader": "^1.0.1",
|
"css-loader": "^1.0.1",
|
||||||
"eslint": "^5.8.0",
|
|
||||||
"html-webpack-plugin": "^3.2.0",
|
"html-webpack-plugin": "^3.2.0",
|
||||||
"mini-css-extract-plugin": "^0.4.4",
|
"mini-css-extract-plugin": "^0.4.4",
|
||||||
"node-sass": "^4.9.4",
|
"node-sass": "^4.9.4",
|
||||||
"npm-run-all": "^4.1.3",
|
"npm-run-all": "^4.1.3",
|
||||||
"rimraf": "^2.6.2",
|
"rimraf": "^2.6.2",
|
||||||
"sass-loader": "^7.1.0",
|
"sass-loader": "^7.1.0",
|
||||||
"standard": "^12.0.1",
|
|
||||||
"style-loader": "^0.23.1",
|
"style-loader": "^0.23.1",
|
||||||
"webpack": "^4.23.1",
|
"webpack": "^4.23.1",
|
||||||
"webpack-cli": "^3.1.2",
|
"webpack-cli": "^3.1.2",
|
||||||
|
@ -62,9 +58,8 @@
|
||||||
"forever": "sudo NODE_ENV='production' ./node_modules/.bin/forever start app.js",
|
"forever": "sudo NODE_ENV='production' ./node_modules/.bin/forever start app.js",
|
||||||
"stop": "sudo ./node_modules/.bin/forever stopall",
|
"stop": "sudo ./node_modules/.bin/forever stopall",
|
||||||
"test": "npm run lint && npm run custom-tests && echo 'Done.'",
|
"test": "npm run lint && npm run custom-tests && echo 'Done.'",
|
||||||
"lint": "standard && echo '✔ Your .js files look good.'",
|
"lint": "eslint . --max-warnings=0 --report-unused-disable-directives && echo '✔ Your .js files look good.'",
|
||||||
"debug": "node --inspect app.js",
|
"debug": "node --inspect app.js"
|
||||||
"custom-tests": "echo 'Nothing yet'"
|
|
||||||
},
|
},
|
||||||
"main": "app.js",
|
"main": "app.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -78,12 +73,7 @@
|
||||||
},
|
},
|
||||||
"standard": {
|
"standard": {
|
||||||
"globals": [
|
"globals": [
|
||||||
"sails",
|
"sails"
|
||||||
"User",
|
]
|
||||||
"Book",
|
|
||||||
"Passport",
|
|
||||||
"_"
|
|
||||||
],
|
|
||||||
"parser": "babel-eslint"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
* https://sailsjs.com/anatomy/tasks/config/babel.js
|
* https://sailsjs.com/anatomy/tasks/config/babel.js
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = function (grunt) {
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
grunt.config.set('babel', {
|
grunt.config.set('babel', {
|
||||||
dist: {
|
dist: {
|
||||||
options: {
|
options: {
|
||||||
|
@ -24,7 +25,7 @@ module.exports = function (grunt) {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||||
|
@ -49,4 +50,5 @@ module.exports = function (grunt) {
|
||||||
// grunt.loadNpmTasks('grunt-babel');
|
// grunt.loadNpmTasks('grunt-babel');
|
||||||
// ```
|
// ```
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
* https://sailsjs.com/anatomy/tasks/config/clean.js
|
* https://sailsjs.com/anatomy/tasks/config/clean.js
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = function (grunt) {
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
grunt.config.set('clean', {
|
grunt.config.set('clean', {
|
||||||
dev: ['.tmp/public/**'],
|
dev: ['.tmp/public/**'],
|
||||||
build: ['www'],
|
build: ['www'],
|
||||||
|
@ -22,7 +23,7 @@ module.exports = function (grunt) {
|
||||||
'www/templates',
|
'www/templates',
|
||||||
'www/dependencies'
|
'www/dependencies'
|
||||||
]
|
]
|
||||||
})
|
});
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||||
|
@ -47,4 +48,5 @@ module.exports = function (grunt) {
|
||||||
// grunt.loadNpmTasks('grunt-contrib-clean');
|
// grunt.loadNpmTasks('grunt-contrib-clean');
|
||||||
// ```
|
// ```
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
* https://sailsjs.com/anatomy/tasks/config/coffee.js
|
* https://sailsjs.com/anatomy/tasks/config/coffee.js
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = function (grunt) {
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
grunt.config.set('coffee', {
|
grunt.config.set('coffee', {
|
||||||
dev: {
|
dev: {
|
||||||
options: {
|
options: {
|
||||||
|
@ -26,7 +27,7 @@ module.exports = function (grunt) {
|
||||||
ext: '.js'
|
ext: '.js'
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||||
|
@ -51,4 +52,5 @@ module.exports = function (grunt) {
|
||||||
// grunt.loadNpmTasks('grunt-contrib-coffee');
|
// grunt.loadNpmTasks('grunt-contrib-coffee');
|
||||||
// ```
|
// ```
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
* https://sailsjs.com/anatomy/tasks/config/concat.js
|
* https://sailsjs.com/anatomy/tasks/config/concat.js
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = function (grunt) {
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
grunt.config.set('concat', {
|
grunt.config.set('concat', {
|
||||||
js: {
|
js: {
|
||||||
src: require('../pipeline').jsFilesToInject,
|
src: require('../pipeline').jsFilesToInject,
|
||||||
|
@ -20,7 +21,7 @@ module.exports = function (grunt) {
|
||||||
src: require('../pipeline').cssFilesToInject,
|
src: require('../pipeline').cssFilesToInject,
|
||||||
dest: '.tmp/public/concat/production.css'
|
dest: '.tmp/public/concat/production.css'
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||||
|
@ -45,4 +46,5 @@ module.exports = function (grunt) {
|
||||||
// grunt.loadNpmTasks('grunt-contrib-concat');
|
// grunt.loadNpmTasks('grunt-contrib-concat');
|
||||||
// ```
|
// ```
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
* https://sailsjs.com/anatomy/tasks/config/copy.js
|
* https://sailsjs.com/anatomy/tasks/config/copy.js
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = function (grunt) {
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
grunt.config.set('copy', {
|
grunt.config.set('copy', {
|
||||||
dev: {
|
dev: {
|
||||||
files: [{
|
files: [{
|
||||||
|
@ -34,8 +35,8 @@ module.exports = function (grunt) {
|
||||||
src: ['**/*'],
|
src: ['**/*'],
|
||||||
dest: '.tmp/public/dist'
|
dest: '.tmp/public/dist'
|
||||||
}]
|
}]
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||||
|
@ -60,4 +61,5 @@ module.exports = function (grunt) {
|
||||||
// grunt.loadNpmTasks('grunt-contrib-copy');
|
// grunt.loadNpmTasks('grunt-contrib-copy');
|
||||||
// ```
|
// ```
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
|
@ -11,13 +11,14 @@
|
||||||
* https://sailsjs.com/anatomy/tasks/config/cssmin.js
|
* https://sailsjs.com/anatomy/tasks/config/cssmin.js
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = function (grunt) {
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
grunt.config.set('cssmin', {
|
grunt.config.set('cssmin', {
|
||||||
dist: {
|
dist: {
|
||||||
src: ['.tmp/public/concat/production.css'],
|
src: ['.tmp/public/concat/production.css'],
|
||||||
dest: '.tmp/public/min/production.min.css'
|
dest: '.tmp/public/min/production.min.css'
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||||
|
@ -42,4 +43,5 @@ module.exports = function (grunt) {
|
||||||
// grunt.loadNpmTasks('grunt-contrib-cssmin');
|
// grunt.loadNpmTasks('grunt-contrib-cssmin');
|
||||||
// ```
|
// ```
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
* https://sailsjs.com/anatomy/tasks/config/hash.js
|
* https://sailsjs.com/anatomy/tasks/config/hash.js
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = function (grunt) {
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
grunt.config.set('hash', {
|
grunt.config.set('hash', {
|
||||||
options: {
|
options: {
|
||||||
mapping: '',
|
mapping: '',
|
||||||
|
@ -17,11 +18,11 @@ module.exports = function (grunt) {
|
||||||
destBasePath: '',
|
destBasePath: '',
|
||||||
flatten: false,
|
flatten: false,
|
||||||
hashLength: 8,
|
hashLength: 8,
|
||||||
hashFunction: function (source, encoding) {
|
hashFunction: function(source, encoding){
|
||||||
if (!source || !encoding) {
|
if (!source || !encoding) {
|
||||||
throw new Error('Consistency violation: Cannot compute unique hash for production .css/.js cache-busting suffix, because `source` and/or `encoding` are falsey-- but they should be truthy strings! Here they are, respectively:\nsource: ' + require('util').inspect(source, { depth: null }) + '\nencoding: ' + require('util').inspect(encoding, { depth: null }))
|
throw new Error('Consistency violation: Cannot compute unique hash for production .css/.js cache-busting suffix, because `source` and/or `encoding` are falsey-- but they should be truthy strings! Here they are, respectively:\nsource: '+require('util').inspect(source, {depth:null})+'\nencoding: '+require('util').inspect(encoding, {depth:null}));
|
||||||
}
|
}
|
||||||
return require('crypto').createHash('sha1').update(source, encoding).digest('hex')
|
return require('crypto').createHash('sha1').update(source, encoding).digest('hex');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
js: {
|
js: {
|
||||||
|
@ -32,7 +33,7 @@ module.exports = function (grunt) {
|
||||||
src: '.tmp/public/min/*.css',
|
src: '.tmp/public/min/*.css',
|
||||||
dest: '.tmp/public/hash/'
|
dest: '.tmp/public/hash/'
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||||
|
@ -57,4 +58,5 @@ module.exports = function (grunt) {
|
||||||
// grunt.loadNpmTasks('grunt-hash');
|
// grunt.loadNpmTasks('grunt-hash');
|
||||||
// ```
|
// ```
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = function (grunt) {
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
grunt.config.set('jst', {
|
grunt.config.set('jst', {
|
||||||
dev: {
|
dev: {
|
||||||
|
|
||||||
|
@ -25,13 +26,14 @@ module.exports = function (grunt) {
|
||||||
// default interpolation. If you want to parse templates with the default _.template behavior
|
// default interpolation. If you want to parse templates with the default _.template behavior
|
||||||
// (i.e. using <div><%= this.id %></div>), there's no need to overwrite `templateSettings.interpolate`.
|
// (i.e. using <div><%= this.id %></div>), there's no need to overwrite `templateSettings.interpolate`.
|
||||||
|
|
||||||
|
|
||||||
files: {
|
files: {
|
||||||
// e.g.
|
// e.g.
|
||||||
// 'relative/path/from/gruntfile/to/compiled/template/destination' : ['relative/path/to/sourcefiles/**/*.html']
|
// 'relative/path/from/gruntfile/to/compiled/template/destination' : ['relative/path/to/sourcefiles/**/*.html']
|
||||||
'.tmp/public/jst.js': require('../pipeline').templateFilesToInject
|
'.tmp/public/jst.js': require('../pipeline').templateFilesToInject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||||
|
@ -56,4 +58,5 @@ module.exports = function (grunt) {
|
||||||
// grunt.loadNpmTasks('grunt-contrib-jst');
|
// grunt.loadNpmTasks('grunt-contrib-jst');
|
||||||
// ```
|
// ```
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
* https://sailsjs.com/anatomy/tasks/config/less.js
|
* https://sailsjs.com/anatomy/tasks/config/less.js
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = function (grunt) {
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
grunt.config.set('less', {
|
grunt.config.set('less', {
|
||||||
dev: {
|
dev: {
|
||||||
files: [{
|
files: [{
|
||||||
|
@ -20,7 +21,7 @@ module.exports = function (grunt) {
|
||||||
ext: '.css'
|
ext: '.css'
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||||
|
@ -45,4 +46,5 @@ module.exports = function (grunt) {
|
||||||
// grunt.loadNpmTasks('grunt-contrib-less');
|
// grunt.loadNpmTasks('grunt-contrib-less');
|
||||||
// ```
|
// ```
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
|
@ -11,9 +11,11 @@
|
||||||
* https://sailsjs.com/anatomy/tasks/config/sails-linker.js
|
* https://sailsjs.com/anatomy/tasks/config/sails-linker.js
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = function (grunt) {
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
grunt.config.set('sails-linker', {
|
grunt.config.set('sails-linker', {
|
||||||
|
|
||||||
|
|
||||||
// ╦╔═╗╦ ╦╔═╗╔═╗╔═╗╦═╗╦╔═╗╔╦╗
|
// ╦╔═╗╦ ╦╔═╗╔═╗╔═╗╦═╗╦╔═╗╔╦╗
|
||||||
// ║╠═╣╚╗╔╝╠═╣╚═╗║ ╠╦╝║╠═╝ ║
|
// ║╠═╣╚╗╔╝╠═╣╚═╗║ ╠╦╝║╠═╝ ║
|
||||||
// ╚╝╩ ╩ ╚╝ ╩ ╩╚═╝╚═╝╩╚═╩╩ ╩
|
// ╚╝╩ ╩ ╚╝ ╩ ╩╚═╝╚═╝╩╚═╩╩ ╩
|
||||||
|
@ -39,7 +41,7 @@ module.exports = function (grunt) {
|
||||||
startTag: '<!--SCRIPTS-->',
|
startTag: '<!--SCRIPTS-->',
|
||||||
endTag: '<!--SCRIPTS END-->',
|
endTag: '<!--SCRIPTS END-->',
|
||||||
fileTmpl: '<script src="%s"></script>',
|
fileTmpl: '<script src="%s"></script>',
|
||||||
appRoot: '.tmp/public'
|
appRoot: '.tmp/public',
|
||||||
// relative: true
|
// relative: true
|
||||||
// ^^ Uncomment this if compiling assets for use in PhoneGap, CDN, etc.
|
// ^^ Uncomment this if compiling assets for use in PhoneGap, CDN, etc.
|
||||||
// (but be note that this can break custom font URLs)
|
// (but be note that this can break custom font URLs)
|
||||||
|
@ -70,7 +72,7 @@ module.exports = function (grunt) {
|
||||||
startTag: '<!--SCRIPTS-->',
|
startTag: '<!--SCRIPTS-->',
|
||||||
endTag: '<!--SCRIPTS END-->',
|
endTag: '<!--SCRIPTS END-->',
|
||||||
fileTmpl: '<script src="%s"></script>',
|
fileTmpl: '<script src="%s"></script>',
|
||||||
appRoot: '.tmp/public'
|
appRoot: '.tmp/public',
|
||||||
// relative: true
|
// relative: true
|
||||||
// ^^ Uncomment this if compiling assets for use in PhoneGap, CDN, etc.
|
// ^^ Uncomment this if compiling assets for use in PhoneGap, CDN, etc.
|
||||||
// (but be note that this can break custom font URLs)
|
// (but be note that this can break custom font URLs)
|
||||||
|
@ -82,6 +84,7 @@ module.exports = function (grunt) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
// ╔═╗╔╦╗╦ ╦╦ ╔═╗╔═╗╦ ╦╔═╗╔═╗╔╦╗╔═╗
|
// ╔═╗╔╦╗╦ ╦╦ ╔═╗╔═╗╦ ╦╔═╗╔═╗╔╦╗╔═╗
|
||||||
// ╚═╗ ║ ╚╦╝║ ║╣ ╚═╗╠═╣║╣ ║╣ ║ ╚═╗
|
// ╚═╗ ║ ╚╦╝║ ║╣ ╚═╗╠═╣║╣ ║╣ ║ ╚═╗
|
||||||
// ╚═╝ ╩ ╩ ╩═╝╚═╝╚═╝╩ ╩╚═╝╚═╝ ╩ ╚═╝
|
// ╚═╝ ╩ ╩ ╩═╝╚═╝╚═╝╩ ╩╚═╝╚═╝ ╩ ╚═╝
|
||||||
|
@ -108,7 +111,7 @@ module.exports = function (grunt) {
|
||||||
startTag: '<!--STYLES-->',
|
startTag: '<!--STYLES-->',
|
||||||
endTag: '<!--STYLES END-->',
|
endTag: '<!--STYLES END-->',
|
||||||
fileTmpl: '<link rel="stylesheet" href="%s">',
|
fileTmpl: '<link rel="stylesheet" href="%s">',
|
||||||
appRoot: '.tmp/public'
|
appRoot: '.tmp/public',
|
||||||
// relative: true
|
// relative: true
|
||||||
// ^^ Uncomment this if compiling assets for use in PhoneGap, CDN, etc.
|
// ^^ Uncomment this if compiling assets for use in PhoneGap, CDN, etc.
|
||||||
// (but be note that this can break custom font URLs)
|
// (but be note that this can break custom font URLs)
|
||||||
|
@ -140,7 +143,7 @@ module.exports = function (grunt) {
|
||||||
startTag: '<!--STYLES-->',
|
startTag: '<!--STYLES-->',
|
||||||
endTag: '<!--STYLES END-->',
|
endTag: '<!--STYLES END-->',
|
||||||
fileTmpl: '<link rel="stylesheet" href="%s">',
|
fileTmpl: '<link rel="stylesheet" href="%s">',
|
||||||
appRoot: '.tmp/public'
|
appRoot: '.tmp/public',
|
||||||
// relative: true
|
// relative: true
|
||||||
// ^^ Uncomment this if compiling assets for use in PhoneGap, CDN, etc.
|
// ^^ Uncomment this if compiling assets for use in PhoneGap, CDN, etc.
|
||||||
// (but be note that this can break custom font URLs)
|
// (but be note that this can break custom font URLs)
|
||||||
|
@ -152,6 +155,7 @@ module.exports = function (grunt) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
// ╔═╗╦═╗╔═╗╔═╗╔═╗╔╦╗╔═╗╦╦ ╔═╗╔╦╗ ╦ ╦╔╦╗╔╦╗╦ ╔╦╗╔═╗╔╦╗╔═╗╦ ╔═╗╔╦╗╔═╗╔═╗
|
// ╔═╗╦═╗╔═╗╔═╗╔═╗╔╦╗╔═╗╦╦ ╔═╗╔╦╗ ╦ ╦╔╦╗╔╦╗╦ ╔╦╗╔═╗╔╦╗╔═╗╦ ╔═╗╔╦╗╔═╗╔═╗
|
||||||
// ╠═╝╠╦╝║╣ ║ ║ ║║║║╠═╝║║ ║╣ ║║ ╠═╣ ║ ║║║║ ║ ║╣ ║║║╠═╝║ ╠═╣ ║ ║╣ ╚═╗
|
// ╠═╝╠╦╝║╣ ║ ║ ║║║║╠═╝║║ ║╣ ║║ ╠═╣ ║ ║║║║ ║ ║╣ ║║║╠═╝║ ╠═╣ ║ ║╣ ╚═╗
|
||||||
// ╩ ╩╚═╚═╝╚═╝╚═╝╩ ╩╩ ╩╩═╝╚═╝═╩╝ ╩ ╩ ╩ ╩ ╩╩═╝ ╩ ╚═╝╩ ╩╩ ╩═╝╩ ╩ ╩ ╚═╝╚═╝
|
// ╩ ╩╚═╚═╝╚═╝╚═╝╩ ╩╩ ╩╩═╝╚═╝═╩╝ ╩ ╩ ╩ ╩ ╩╩═╝ ╩ ╚═╝╩ ╩╩ ╩═╝╩ ╩ ╩ ╚═╝╚═╝
|
||||||
|
@ -176,7 +180,7 @@ module.exports = function (grunt) {
|
||||||
startTag: '<!--TEMPLATES-->',
|
startTag: '<!--TEMPLATES-->',
|
||||||
endTag: '<!--TEMPLATES END-->',
|
endTag: '<!--TEMPLATES END-->',
|
||||||
fileTmpl: '<script type="text/javascript" src="%s"></script>',
|
fileTmpl: '<script type="text/javascript" src="%s"></script>',
|
||||||
appRoot: '.tmp/public'
|
appRoot: '.tmp/public',
|
||||||
// relative: true
|
// relative: true
|
||||||
// ^^ Uncomment this if compiling assets for use in PhoneGap, CDN, etc.
|
// ^^ Uncomment this if compiling assets for use in PhoneGap, CDN, etc.
|
||||||
// (but be note that this can break custom font URLs)
|
// (but be note that this can break custom font URLs)
|
||||||
|
@ -186,9 +190,9 @@ module.exports = function (grunt) {
|
||||||
'views/**/*.html': ['.tmp/public/jst.js'],
|
'views/**/*.html': ['.tmp/public/jst.js'],
|
||||||
'views/**/*.ejs': ['.tmp/public/jst.js']
|
'views/**/*.ejs': ['.tmp/public/jst.js']
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
})// </ grunt.config.set() >
|
});//</ grunt.config.set() >
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||||
|
@ -213,4 +217,5 @@ module.exports = function (grunt) {
|
||||||
// grunt.loadNpmTasks('grunt-sails-linker');
|
// grunt.loadNpmTasks('grunt-sails-linker');
|
||||||
// ```
|
// ```
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
* https://sailsjs.com/anatomy/tasks/config/sync.js
|
* https://sailsjs.com/anatomy/tasks/config/sync.js
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = function (grunt) {
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
grunt.config.set('sync', {
|
grunt.config.set('sync', {
|
||||||
dev: {
|
dev: {
|
||||||
files: [{
|
files: [{
|
||||||
|
@ -19,7 +20,7 @@ module.exports = function (grunt) {
|
||||||
dest: '.tmp/public'
|
dest: '.tmp/public'
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||||
|
@ -44,4 +45,5 @@ module.exports = function (grunt) {
|
||||||
// grunt.loadNpmTasks('grunt-sync');
|
// grunt.loadNpmTasks('grunt-sync');
|
||||||
// ```
|
// ```
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
* https://sailsjs.com/anatomy/tasks/config/uglify.js
|
* https://sailsjs.com/anatomy/tasks/config/uglify.js
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = function (grunt) {
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
grunt.config.set('uglify', {
|
grunt.config.set('uglify', {
|
||||||
dist: {
|
dist: {
|
||||||
src: ['.tmp/public/concat/production.js'],
|
src: ['.tmp/public/concat/production.js'],
|
||||||
|
@ -23,7 +24,7 @@ module.exports = function (grunt) {
|
||||||
'Promise',
|
'Promise',
|
||||||
'File',
|
'File',
|
||||||
'Location',
|
'Location',
|
||||||
'RttcRefPlaceholder'
|
'RttcRefPlaceholder',
|
||||||
],
|
],
|
||||||
keep_fnames: true//eslint-disable-line
|
keep_fnames: true//eslint-disable-line
|
||||||
},
|
},
|
||||||
|
@ -31,7 +32,7 @@ module.exports = function (grunt) {
|
||||||
keep_fnames: true//eslint-disable-line
|
keep_fnames: true//eslint-disable-line
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||||
|
@ -56,4 +57,6 @@ module.exports = function (grunt) {
|
||||||
// grunt.loadNpmTasks('grunt-contrib-uglify');
|
// grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||||
// ```
|
// ```
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
* https://sailsjs.com/anatomy/tasks/config/watch.js
|
* https://sailsjs.com/anatomy/tasks/config/watch.js
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = function (grunt) {
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
grunt.config.set('watch', {
|
grunt.config.set('watch', {
|
||||||
assets: {
|
assets: {
|
||||||
|
|
||||||
|
@ -26,7 +27,7 @@ module.exports = function (grunt) {
|
||||||
'linkAssets'
|
'linkAssets'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// This Grunt plugin is part of the default asset pipeline in Sails,
|
// This Grunt plugin is part of the default asset pipeline in Sails,
|
||||||
|
@ -51,4 +52,5 @@ module.exports = function (grunt) {
|
||||||
// grunt.loadNpmTasks('grunt-contrib-watch');
|
// grunt.loadNpmTasks('grunt-contrib-watch');
|
||||||
// ```
|
// ```
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
* https://sailsjs.com/anatomy/tasks/pipeline.js
|
* https://sailsjs.com/anatomy/tasks/pipeline.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ██████╗ ██╗ █████╗ ██╗███╗ ██╗ ██████╗███████╗███████╗
|
// ██████╗ ██╗ █████╗ ██╗███╗ ██╗ ██████╗███████╗███████╗
|
||||||
// ██╔══██╗██║ ██╔══██╗██║████╗ ██║ ██╔════╝██╔════╝██╔════╝
|
// ██╔══██╗██║ ██╔══██╗██║████╗ ██║ ██╔════╝██╔════╝██╔════╝
|
||||||
// ██████╔╝██║ ███████║██║██╔██╗ ██║ ██║ ███████╗███████╗
|
// ██████╔╝██║ ███████║██║██╔██╗ ██║ ██║ ███████╗███████╗
|
||||||
|
@ -38,7 +40,8 @@ var cssFilesToInject = [
|
||||||
// in no particular order. To customize the ordering, add additional
|
// in no particular order. To customize the ordering, add additional
|
||||||
// items here, _above_ this one.
|
// items here, _above_ this one.
|
||||||
'styles/**/*.css'
|
'styles/**/*.css'
|
||||||
]
|
];
|
||||||
|
|
||||||
|
|
||||||
// ██████╗██╗ ██╗███████╗███╗ ██╗████████╗ ███████╗██╗██████╗ ███████╗
|
// ██████╗██╗ ██╗███████╗███╗ ██╗████████╗ ███████╗██╗██████╗ ███████╗
|
||||||
// ██╔════╝██║ ██║██╔════╝████╗ ██║╚══██╔══╝ ██╔════╝██║██╔══██╗██╔════╝
|
// ██╔════╝██║ ██║██╔════╝████╗ ██║╚══██╔══╝ ██╔════╝██║██╔══██╗██╔════╝
|
||||||
|
@ -70,7 +73,8 @@ var jsFilesToInject = [
|
||||||
// in no particular order. To customize the ordering, add additional items
|
// in no particular order. To customize the ordering, add additional items
|
||||||
// here, _above_ this one.
|
// here, _above_ this one.
|
||||||
'js/**/*.js'
|
'js/**/*.js'
|
||||||
]
|
];
|
||||||
|
|
||||||
|
|
||||||
// ██████╗██╗ ██╗███████╗███╗ ██╗████████╗ ███████╗██╗██████╗ ███████╗
|
// ██████╗██╗ ██╗███████╗███╗ ██╗████████╗ ███████╗██╗██████╗ ███████╗
|
||||||
// ██╔════╝██║ ██║██╔════╝████╗ ██║╚══██╔══╝ ██╔════╝██║██╔══██╗██╔════╝
|
// ██╔════╝██║ ██║██╔════╝████╗ ██║╚══██╔══╝ ██╔════╝██║██╔══██╗██╔════╝
|
||||||
|
@ -99,7 +103,9 @@ var jsFilesToInject = [
|
||||||
//
|
//
|
||||||
var templateFilesToInject = [
|
var templateFilesToInject = [
|
||||||
'templates/**/*.html'
|
'templates/**/*.html'
|
||||||
]
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ███╗ ███╗██╗███████╗ ██████╗ ███████╗███████╗████████╗██╗ ██╗██████╗
|
// ███╗ ███╗██╗███████╗ ██████╗ ███████╗███████╗████████╗██╗ ██╗██████╗
|
||||||
// ████╗ ████║██║██╔════╝██╔════╝ ██╔════╝██╔════╝╚══██╔══╝██║ ██║██╔══██╗
|
// ████╗ ████║██║██╔════╝██╔════╝ ██╔════╝██╔════╝╚══██╔══╝██║ ██║██╔══██╗
|
||||||
|
@ -113,29 +119,29 @@ var templateFilesToInject = [
|
||||||
// the code below, unless you are modifying the default asset pipeline.**
|
// the code below, unless you are modifying the default asset pipeline.**
|
||||||
|
|
||||||
// Default path for public folder (see documentation on sailsjs.com for more information)
|
// Default path for public folder (see documentation on sailsjs.com for more information)
|
||||||
var tmpPath = '.tmp/public/'
|
var tmpPath = '.tmp/public/';
|
||||||
|
|
||||||
// Prefix relative paths to source files so they point to the proper locations
|
// Prefix relative paths to source files so they point to the proper locations
|
||||||
// (i.e. where the other Grunt tasks spit them out, or in some cases, where
|
// (i.e. where the other Grunt tasks spit them out, or in some cases, where
|
||||||
// they reside in the first place)
|
// they reside in the first place)
|
||||||
module.exports.cssFilesToInject = cssFilesToInject.map((cssPath) => {
|
module.exports.cssFilesToInject = cssFilesToInject.map((cssPath)=>{
|
||||||
// If we're ignoring the file, make sure the ! is at the beginning of the path
|
// If we're ignoring the file, make sure the ! is at the beginning of the path
|
||||||
if (cssPath[0] === '!') {
|
if (cssPath[0] === '!') {
|
||||||
return require('path').join('!' + tmpPath, cssPath.substr(1))
|
return require('path').join('!' + tmpPath, cssPath.substr(1));
|
||||||
}
|
}
|
||||||
return require('path').join(tmpPath, cssPath)
|
return require('path').join(tmpPath, cssPath);
|
||||||
})
|
});
|
||||||
module.exports.jsFilesToInject = jsFilesToInject.map((jsPath) => {
|
module.exports.jsFilesToInject = jsFilesToInject.map((jsPath)=>{
|
||||||
// If we're ignoring the file, make sure the ! is at the beginning of the path
|
// If we're ignoring the file, make sure the ! is at the beginning of the path
|
||||||
if (jsPath[0] === '!') {
|
if (jsPath[0] === '!') {
|
||||||
return require('path').join('!' + tmpPath, jsPath.substr(1))
|
return require('path').join('!' + tmpPath, jsPath.substr(1));
|
||||||
}
|
}
|
||||||
return require('path').join(tmpPath, jsPath)
|
return require('path').join(tmpPath, jsPath);
|
||||||
})
|
});
|
||||||
module.exports.templateFilesToInject = templateFilesToInject.map((tplPath) => {
|
module.exports.templateFilesToInject = templateFilesToInject.map((tplPath)=>{
|
||||||
// If we're ignoring the file, make sure the ! is at the beginning of the path
|
// If we're ignoring the file, make sure the ! is at the beginning of the path
|
||||||
if (tplPath[0] === '!') {
|
if (tplPath[0] === '!') {
|
||||||
return require('path').join('!assets/', tplPath.substr(1))
|
return require('path').join('!assets/', tplPath.substr(1));
|
||||||
}
|
}
|
||||||
return require('path').join('assets/', tplPath)
|
return require('path').join('assets/', tplPath);
|
||||||
})
|
});
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
* https://sailsjs.com/anatomy/tasks/register/build.js
|
* https://sailsjs.com/anatomy/tasks/register/build.js
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = function (grunt) {
|
module.exports = function(grunt) {
|
||||||
grunt.registerTask('build', [
|
grunt.registerTask('build', [
|
||||||
// 'polyfill:dev', //« uncomment to ALSO transpile during development (for broader browser compat.)
|
// 'polyfill:dev', //« uncomment to ALSO transpile during development (for broader browser compat.)
|
||||||
'compileAssets',
|
'compileAssets',
|
||||||
|
@ -18,5 +18,5 @@ module.exports = function (grunt) {
|
||||||
'linkAssetsBuild',
|
'linkAssetsBuild',
|
||||||
'clean:build',
|
'clean:build',
|
||||||
'copy:build'
|
'copy:build'
|
||||||
])
|
]);
|
||||||
}
|
};
|
||||||
|
|
|
@ -11,19 +11,20 @@
|
||||||
* https://sailsjs.com/anatomy/tasks/register/build-prod.js
|
* https://sailsjs.com/anatomy/tasks/register/build-prod.js
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = function (grunt) {
|
module.exports = function(grunt) {
|
||||||
grunt.registerTask('buildProd', [
|
grunt.registerTask('buildProd', [
|
||||||
'polyfill:prod', // « Remove this to skip transpilation in production (not recommended)
|
'polyfill:prod', //« Remove this to skip transpilation in production (not recommended)
|
||||||
'compileAssets',
|
'compileAssets',
|
||||||
'babel', // « Remove this to skip transpilation in production (not recommended)
|
'babel', //« Remove this to skip transpilation in production (not recommended)
|
||||||
'concat',
|
'concat',
|
||||||
'uglify',
|
'uglify',
|
||||||
'cssmin',
|
'cssmin',
|
||||||
'hash', // « Cache-busting
|
'hash',//« Cache-busting
|
||||||
'copy:beforeLinkBuildProd', // « For prettier URLs after cache-busting
|
'copy:beforeLinkBuildProd',//« For prettier URLs after cache-busting
|
||||||
'linkAssetsBuildProd',
|
'linkAssetsBuildProd',
|
||||||
'clean:build',
|
'clean:build',
|
||||||
'copy:build',
|
'copy:build',
|
||||||
'clean:afterBuildProd'
|
'clean:afterBuildProd'
|
||||||
])
|
]);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,12 @@
|
||||||
* https://sailsjs.com/anatomy/tasks/register/compile-assets.js
|
* https://sailsjs.com/anatomy/tasks/register/compile-assets.js
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = function (grunt) {
|
module.exports = function(grunt) {
|
||||||
grunt.registerTask('compileAssets', [
|
grunt.registerTask('compileAssets', [
|
||||||
'clean:dev',
|
'clean:dev',
|
||||||
'jst:dev',
|
'jst:dev',
|
||||||
'less:dev',
|
'less:dev',
|
||||||
'copy:dev',
|
'copy:dev',
|
||||||
'coffee:dev'
|
'coffee:dev'
|
||||||
])
|
]);
|
||||||
}
|
};
|
||||||
|
|
|
@ -13,11 +13,15 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = function (grunt) {
|
module.exports = function (grunt) {
|
||||||
|
|
||||||
|
|
||||||
grunt.registerTask('default', [
|
grunt.registerTask('default', [
|
||||||
// 'polyfill:dev', //« uncomment to ALSO transpile during development (for broader browser compat.)
|
// 'polyfill:dev', //« uncomment to ALSO transpile during development (for broader browser compat.)
|
||||||
'compileAssets',
|
'compileAssets',
|
||||||
// 'babel', //« uncomment to ALSO transpile during development (for broader browser compat.)
|
// 'babel', //« uncomment to ALSO transpile during development (for broader browser compat.)
|
||||||
'linkAssets',
|
'linkAssets',
|
||||||
'watch'
|
'watch'
|
||||||
])
|
]);
|
||||||
}
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
* https://sailsjs.com/anatomy/tasks/register/link-assets.js
|
* https://sailsjs.com/anatomy/tasks/register/link-assets.js
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = function (grunt) {
|
module.exports = function(grunt) {
|
||||||
grunt.registerTask('linkAssets', [
|
grunt.registerTask('linkAssets', [
|
||||||
'sails-linker:devJs',
|
'sails-linker:devJs',
|
||||||
'sails-linker:devStyles',
|
'sails-linker:devStyles',
|
||||||
'sails-linker:clientSideTemplates'
|
'sails-linker:clientSideTemplates'
|
||||||
])
|
]);
|
||||||
}
|
};
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
* https://sailsjs.com/anatomy/tasks/register/link-assets-build.js
|
* https://sailsjs.com/anatomy/tasks/register/link-assets-build.js
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = function (grunt) {
|
module.exports = function(grunt) {
|
||||||
grunt.registerTask('linkAssetsBuild', [
|
grunt.registerTask('linkAssetsBuild', [
|
||||||
'sails-linker:devJsBuild',
|
'sails-linker:devJsBuild',
|
||||||
'sails-linker:devStylesBuild',
|
'sails-linker:devStylesBuild',
|
||||||
'sails-linker:clientSideTemplatesBuild'
|
'sails-linker:clientSideTemplatesBuild'
|
||||||
])
|
]);
|
||||||
}
|
};
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
* https://sailsjs.com/anatomy/tasks/register/link-assets-build-prod.js
|
* https://sailsjs.com/anatomy/tasks/register/link-assets-build-prod.js
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = function (grunt) {
|
module.exports = function(grunt) {
|
||||||
grunt.registerTask('linkAssetsBuildProd', [
|
grunt.registerTask('linkAssetsBuildProd', [
|
||||||
'sails-linker:prodJsBuild',
|
'sails-linker:prodJsBuild',
|
||||||
'sails-linker:prodStylesBuild',
|
'sails-linker:prodStylesBuild',
|
||||||
'sails-linker:clientSideTemplatesBuild'
|
'sails-linker:clientSideTemplatesBuild'
|
||||||
])
|
]);
|
||||||
}
|
};
|
||||||
|
|
|
@ -7,21 +7,22 @@
|
||||||
* https://sailsjs.com/anatomy/tasks/register/polyfill.js
|
* https://sailsjs.com/anatomy/tasks/register/polyfill.js
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = function (grunt) {
|
module.exports = function(grunt) {
|
||||||
grunt.registerTask('polyfill:prod', 'Add the polyfill file to the top of the list of files to concatenate', () => {
|
grunt.registerTask('polyfill:prod', 'Add the polyfill file to the top of the list of files to concatenate', ()=>{
|
||||||
grunt.config.set('concat.js.src', [require('sails-hook-grunt/accessible/babel-polyfill')].concat(grunt.config.get('concat.js.src')))
|
grunt.config.set('concat.js.src', [require('sails-hook-grunt/accessible/babel-polyfill')].concat(grunt.config.get('concat.js.src')));
|
||||||
})
|
});
|
||||||
grunt.registerTask('polyfill:dev', 'Add the polyfill file to the top of the list of files to copy and link', () => {
|
grunt.registerTask('polyfill:dev', 'Add the polyfill file to the top of the list of files to copy and link', ()=>{
|
||||||
grunt.config.set('copy.dev.files', grunt.config.get('copy.dev.files').concat({
|
grunt.config.set('copy.dev.files', grunt.config.get('copy.dev.files').concat({
|
||||||
expand: true,
|
expand: true,
|
||||||
cwd: require('path').dirname(require('sails-hook-grunt/accessible/babel-polyfill')),
|
cwd: require('path').dirname(require('sails-hook-grunt/accessible/babel-polyfill')),
|
||||||
src: require('path').basename(require('sails-hook-grunt/accessible/babel-polyfill')),
|
src: require('path').basename(require('sails-hook-grunt/accessible/babel-polyfill')),
|
||||||
dest: '.tmp/public/polyfill'
|
dest: '.tmp/public/polyfill'
|
||||||
}))
|
}));
|
||||||
var devLinkFiles = grunt.config.get('sails-linker.devJs.files')
|
var devLinkFiles = grunt.config.get('sails-linker.devJs.files');
|
||||||
grunt.config.set('sails-linker.devJs.files', Object.keys(devLinkFiles).reduce((linkerConfigSoFar, glob) => {
|
grunt.config.set('sails-linker.devJs.files', Object.keys(devLinkFiles).reduce((linkerConfigSoFar, glob)=>{
|
||||||
linkerConfigSoFar[glob] = ['.tmp/public/polyfill/polyfill.min.js'].concat(devLinkFiles[glob])
|
linkerConfigSoFar[glob] = ['.tmp/public/polyfill/polyfill.min.js'].concat(devLinkFiles[glob]);
|
||||||
return linkerConfigSoFar
|
return linkerConfigSoFar;
|
||||||
}, {}))
|
}, {}));
|
||||||
})
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,16 +11,17 @@
|
||||||
* https://sailsjs.com/anatomy/tasks/register/prod.js
|
* https://sailsjs.com/anatomy/tasks/register/prod.js
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = function (grunt) {
|
module.exports = function(grunt) {
|
||||||
grunt.registerTask('prod', [
|
grunt.registerTask('prod', [
|
||||||
'polyfill:prod', // « Remove this to skip transpilation in production (not recommended)
|
'polyfill:prod', //« Remove this to skip transpilation in production (not recommended)
|
||||||
'compileAssets',
|
'compileAssets',
|
||||||
'babel', // « Remove this to skip transpilation in production (not recommended)
|
'babel', //« Remove this to skip transpilation in production (not recommended)
|
||||||
'concat',
|
'concat',
|
||||||
'uglify',
|
'uglify',
|
||||||
'cssmin',
|
'cssmin',
|
||||||
'sails-linker:prodJs',
|
'sails-linker:prodJs',
|
||||||
'sails-linker:prodStyles',
|
'sails-linker:prodStyles',
|
||||||
'sails-linker:clientSideTemplates'
|
'sails-linker:clientSideTemplates',
|
||||||
])
|
]);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
* https://sailsjs.com/anatomy/tasks/register/sync-assets.js
|
* https://sailsjs.com/anatomy/tasks/register/sync-assets.js
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = function (grunt) {
|
module.exports = function(grunt) {
|
||||||
grunt.registerTask('syncAssets', [
|
grunt.registerTask('syncAssets', [
|
||||||
'jst:dev',
|
'jst:dev',
|
||||||
'less:dev',
|
'less:dev',
|
||||||
'sync:dev',
|
'sync:dev',
|
||||||
'coffee:dev'
|
'coffee:dev'
|
||||||
])
|
]);
|
||||||
}
|
};
|
||||||
|
|
Loading…
Reference in New Issue