当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript stylus.middleware函数代码示例

本文整理汇总了TypeScript中stylus.middleware函数的典型用法代码示例。如果您正苦于以下问题:TypeScript middleware函数的具体用法?TypeScript middleware怎么用?TypeScript middleware使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了middleware函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: config

    private config() {
        this.expressApp.set("views", path.join(__dirname, "views"));
        this.expressApp.set("view engine", "pug");

        this.expressApp.use(bodyParser.json());
        this.expressApp.use(bodyParser.urlencoded({extended: true}));

        this.expressApp.use(stylus.middleware({
            src: __dirname + "/public",
            compile: this.compileCSS
        }));

        this.expressApp.use(express.static(path.join(__dirname, "public")));
        this.expressApp.use(express.static(path.join(__dirname, "bower components")));

        this.expressApp.use(function(err: any, req: express.Request, res: express.Response, next: express.NextFunction) {
            var error = new Error("Not Found");
            err.status = 404;
            next(err);
        });
    }
开发者ID:shenningsgard,项目名称:net-board,代码行数:21,代码来源:app.ts

示例2: function

}));
app.all('/hgtozip', function (req, res) { res.redirect('/hgtozip/'); });
app.use("/hgtozip/", hgToZip);

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

app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.logger('dev'));
app.use(stylus.middleware(
	{ 
		src: __dirname + '/public', 
		compile: compile
  	}
));
app.configure(function() {
	app.use(express.static('public'));
	app.use(express.cookieParser());
	app.use(express.bodyParser());
	app.use(app.router);
});
//endregion

app.get("/", function (request, response) {
	response.render("home");
});

console.log(os.hostname());
开发者ID:LukaHorvat,项目名称:Personal,代码行数:32,代码来源:index.ts

示例3: function

(module).exports = function() {
    // Warn of version mismatch between global "lcm" binary and local installation
    // of Locomotive.
    if (this.version !== require('locomotive').version) {
        console.warn(util.format('version mismatch between local (%s) and global (%s) Locomotive module', require('locomotive').version, this.version));
    }

    var config = configuration.ServerConfiguration;

    // Configure application settings.  Consult the Express API Reference for a
    // list of the available [settings](http://expressjs.com/api.html#app-settings).

    var viewsDir = path.resolve(config.startupDirectory, "./views");
    var stylesDir = path.resolve(config.startupDirectory, "./styles");
    var publicDir = path.resolve(config.startupDirectory, "./dist/public");

    config.logger.debug("Views directory: %s", viewsDir);
    config.logger.debug("Styles directory: %s", stylesDir);
    config.logger.debug("Public directory: %s", publicDir);

    function compile(str: string, path: string) {
        console.log(str);
        console.log(path);

        return stylus(str)
            .set('filename', path)
            .set('compress', true)
            .use(nib());
    }

    this.use(stylus.middleware({
          src: process.cwd()
        , dest: publicDir
        , compile: compile
    }));

    this.set('views', viewsDir);
    this.set('view engine', 'jade');

    // Register Jade as a template engine.
    this.engine('jade', require('jade').__express);

    // Override default template extension.  By default, Locomotive finds
    // templates using the `name.format.engine` convention, for example
    // `index.html.ejs`  For some template engines, such as Jade, that find
    // layouts using a `layout.engine` notation, this results in mixed conventions
    // that can cuase confusion.  If this occurs, you can map an explicit
    // extension to a format.
    this.format('html', { extension: '.jade' })

  // Register formats for content negotiation.  Using content negotiation,
  // different formats can be served as needed by different clients.  For
  // example, a browser is sent an HTML response, while an API client is sent a
  // JSON or XML response.
  /* this.format('xml', { engine: 'xmlb' }); */

  // Use middleware.  Standard [Connect](http://www.senchalabs.org/connect/)
  // middleware is built-in, with additional [third-party](https://github.com/senchalabs/connect/wiki)
  // middleware available as separate modules.  

    this.use(poweredBy('Locomotive'));
    this.use(express.logger());
    this.use(express.favicon());
    this.use(express["cookieParser"]());
    this.use(express.static(publicDir));
    this.use(express.bodyParser());
    this.use(express.methodOverride());
}
开发者ID:ciuliot,项目名称:mongo-admin-ui,代码行数:68,代码来源:all.ts

示例4: express

import * as routes from "./routes/index";
import * as http from "http";
import * as path from "path";
import * as stylus from "stylus";
import * as favicon from "serve-favicon";
import * as logger from "morgan";
import * as cookieParser from "cookie-parser";
import * as bodyParser from "body-parser";

var app = express();

// view engine setup
app.set("port", process.env.PORT || 3000);
app.set("views", path.join(__dirname, "views"));
app.set("view engine", "ejs");
app.use(stylus.middleware(path.join(__dirname, "public")));
// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, "public", "favicon.ico")));
if (app.get("env") === "development") {
	app.use(logger("dev"));
}

app.use(cookieParser());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, "public")));

app.get("/", routes.index);
app.get("/about", routes.about);
app.get("/contact", routes.contact);
开发者ID:yoshikiokawa,项目名称:NodeJsExpressTypeScriptTemplate,代码行数:30,代码来源:app.ts

示例5: require

import * as fs from "fs";
import * as express from "express";
const expose = require("express-expose"); // import * as expose from "express-expose";
const stylus = require("stylus"); // import * as stylus from "stylus";
const nib = require("nib"); // import * as nib from "nib";
import * as marked from "marked";
const hljs = require("highlight.js"); // import * as highlight from "highlight.js";


const app: express.Express = expose(express());
app.set("views", `${__dirname}/views`);
app.set("view engine", "jade");

app.use(stylus.middleware({
  src: `${__dirname}/`,
  dest: `${__dirname}/../public`,
  compile: (str: string, path: string) => { return stylus(str).use(nib()).set("filename", path).set("compress", true); }
}));
app.get("/styles/highlight.css", (req, res) => { res.sendFile(path.resolve(`${__dirname}/../node_modules/highlight.js/styles/railscasts.css`)) });

interface Category {
  name: string;
  title: string;
  pages: { [pageName: string]: PageDesc };
}

interface PageDesc {
  name: string;
  title: string;
}
开发者ID:BitcoinSolution,项目名称:docs.superpowers-html5.com,代码行数:30,代码来源:index.ts


注:本文中的stylus.middleware函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。