How to use the stylus.middleware function in stylus

To help you get started, we’ve selected a few stylus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ekiwan / Dotametrics / server.js View on Github external
var express = require('express');
var stylus = require('stylus');
var nib = require('nib');
var replay = require('./replay.js');
var app = express();

console.log(replay.countRunes());

// Log requests
app.use(express.logger());

// Compile Stylus files
app.use(stylus.middleware({
  src: __dirname + '/public/styles/',
  dest: __dirname + '/public/styles/',
  compile: function(str, path) {
    return stylus(str)
      .set('filename', path)
      .set('compress', true)
      .use(nib());
  }
}));

//api routes
require('./routes.js')(app);

// Serve static files
app.use(express.static(__dirname + '/public'));
github kickstarts / kickstarts / lib / templates / benmstack / server.js View on Github external
// Jade
app.set('view engine', 'jade');
app.set('view options', { layout: true });
app.set('views', config.app.views);

// Sytlus
var compile = function compile(str, path) {
    return stylus(str)
        .set('filename', path)
        .set('compress', true)
        .set('debug', true)
        .use(nib());
};

app.use(stylus.middleware({
    src: path.join(__dirname, './'),
    dest: path.join(__dirname, './public'),
    compile: compile
}));

// Nginx Server
// app.enable('trust proxy');

// Compress response data with gzip / deflate.
app.use(compress());

// Body parsing middleware supporting.
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
    extended: true
}));
github josiahruddell / webnote5 / server.js View on Github external
app.configure(function() {
    app.set('views', __dirname + '/views');
    app.set('view engine', 'jade');
    app.use(express.cookieParser());
    app.use(express.bodyParser());
    app.use(express.session({store: sessionStore
        , secret: 'secret'
        , key: 'express.sid'}));
    app.use(csrf.check());
    app.use(express.methodOverride());
    app.use(require('stylus').middleware({
        src: __dirname + '/public'
    }));
    app.use(app.router);
    app.use(express.static(__dirname + '/public'));
    Model.logger.setLogLevel(7);
    Model.create_connection({
        url: 'webnote5.iriscouch.com',
        port: '80',
        db: 'core',
        auth: { // not required
          username: 'admin',
          password: 'n0mNo+es'
        }
        // secure:true,
    });
    Model.load('src/models');
github noveogroup / backbone.iobind / example / app.js View on Github external
// Configuration

var stylus_compile = function (str, path) {
  return stylus(str)
          .set('filename', path)
          .set('compress', true)
          .use(require('nib')())
          .use(require('fez')());
};


app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
//app.use(bodyParser());
app.use(stylus.middleware({
  src: path.join(__dirname, 'styles'),
  dest: path.join(__dirname, 'public'),
  compile: stylus_compile,
  force: true // this forces the css to be regenerated on every pageview
}));
app.use(express.static(__dirname + '/public'));


if (app.get('env') === 'development') {
  app.use(errorHandler({ dumpExceptions: true, showStack: true }));
}

if (app.get('env') === 'production') {
  app.use(errorHandler());
}
github ethanp / programming / StuffIWrote / Javascript / NodeJS / CoffeeScript / TextProc / app.js View on Github external
// instantiate an ExpressJS application
var app = express();

// set location of views
app.set('views', path.join(__dirname, 'views'));

// inform app of templating engine type
app.set('view engine', 'jade');

app.use(favicon());
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
app.use(cookieParser());
app.use(require('stylus').middleware(path.join(__dirname, 'public')));

/* The static middleware has the same effect as creating a route for
   each static file you want to deliver that renders a file and returns
   it to the client.

   E.g., now we can simply reference "/img/logo.png" (do not specify
   public), and the static middleware will serve that file, setting
   the content type appropriately. */
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', routes);
app.use('/users', users);

/// catch 404 and forward to error handler
app.use(function(req, res, next) {
    var err = new Error('Not Found');
github rauchg / mongoose-meetup-04-05 / lib / mongoose-meetup.js View on Github external
app.configure(function () {
    // general
    app.use(express.cookieParser());
    app.use(express.bodyParser());
    app.use(express.errorHandler({ dumpExceptions: true, showStack: true }))
    app.use(express.session({ secret: 'imnotwearingunderwear' }));

    // stylus
    app.use(stylus.middleware({
          src: __dirname + '/../views'
        , dest: __dirname + '/../public'
    }));

    // static
    app.use(express.static(__dirname + '/../public'));
  });
github geekyme / openshop / app.js View on Github external
app.configure(function(){
  app.set('port', process.env.PORT || Config.PROCESS.port);
  app.set('views', __dirname + '/views'); // folder for templating engine to look in
  app.set('view engine', 'jade'); // templating engine
  app.use(require('stylus').middleware({ src: __dirname + '/public' })); // styling engine and folder
  app.use(express.favicon()); // auto generate a favicon
  app.use(express.logger('dev')); // log everything that happens in the server
  app.use(express.bodyParser());
  // helmet for increased security
  app.use(express.methodOverride());
  app.use(helmet.xframe()); 
  app.use(helmet.iexss());
  app.use(helmet.contentTypeOptions());
  app.use(helmet.cacheControl());
  // Session & Cookies
  app.use(express.cookieParser());
  app.use(express.session({
    secret: "187n mnko21908qnxxgy1n9x1",
    cookie: {httpOnly: true, maxAge: 10*60*1000},
    store: sessionStore
  }));
github Ar3sDevelopment / rpi-systempanel / app.js View on Github external
var socket_io = require('socket.io');

var server = http.createServer(app).listen(1338, function () {
	console.log('System Panel server listening on port 1338');
});

var io = socket_io.listen(server, {
	log : false
});

function compile(str, path) {
	return stylus(str).set('filename', path).use(nib());
}
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(stylus.middleware( { src: path.join(__dirname,'public'), compile: compile } ));
app.use(express.static(path.join(__dirname,'public')));
app.use(express.favicon());
app.use(express.urlencoded());
app.use(express.json());
app.use(express.methodOverride());
app.use(express.errorHandler());
app.use(express.cookieParser());
app.use(express.session({ secret: '1234567890ABCDEF' }));
app.use(app.router);
app.use('/tmp', express.static(__dirname + '/tmp'));

app.get('/', function(req, res, next) {
	require('./index.js').page(req, res, app, next);
});

app.get('/login', function(req, res, next) {
github azat-co / expressworks / exercises / stylish_css / solution / solution.js View on Github external
const express = require('express')
const app = express()

app.use(require('stylus').middleware(process.argv[3]));
app.use(express.static(process.argv[3]));


app.listen(process.argv[2])
github hypebeast / expressjs.bootstrap.knockoutjs.tutorials / app.js View on Github external
app.configure(function(){
  app.set('port', process.env.PORT || 3030);
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  app.use(express.favicon());
  app.use(express.logger('dev'));
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(app.router);
  app.use(require('stylus').middleware(__dirname + '/public'));
  app.use(express.static(__dirname + '/public'));
});