I'm using Sails.js v0.12.4. The http.js uses module.exports.http
and not module.exports.express
I did the following to serve up another folder like the existing /assets
folder. In my example to serve up the app
folder, replace the 'node_modules/bootstrap/dist'
path with /app
In the config/http.js
file I added
var express = require('express');
Then in the middleware
object I added the express static module. I'm wanting to serve up the bootstrap assets contained in my node_modules
folder.
bootstrapAssets: express.static('node_modules/bootstrap/dist'),
Then in the order
array, I added the 'bootstrapAssets'
in the order I wanted this middleware to run. Here is the full code:
var express = require('express');
module.exports.http = {
middleware: {
passportInit : require('passport').initialize(),
passportSession : require('passport').session(),
bootstrapAssets : express.static('node_modules/bootstrap/dist'),
order: [
'startRequestTimer',
'cookieParser',
'session',
'bootstrapAssets',
'passportInit',
'passportSession',
'myRequestLogger',
'bodyParser',
'handleBodyParserError',
'compress',
'methodOverride',
'poweredBy',
'$custom',
'router',
'www',
'favicon',
'404',
'500'
],
Now in my HTML I can access the the bootstrap css using the following:
<link rel="stylesheet" href="/css/bootstrap.min.css">