How to use mustache-express - 2 common examples

To help you get started, we’ve selected a few mustache-express 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 HermesMessenger / Hermes / src / server.ts View on Github external
import { router } from './server/api'

import { AnyCommand, Response, Command } from './@types/Command'
import { Connections } from './server/@types/connections'

const app = express()

// Parsers
app.set('trust proxy', true)
app.use(bodyParser.json()) // for parsing application/json
app.use(bodyParser.urlencoded({ extended: true })) // for parsing application/x-www-form-urlencoded
app.use(cookieParser()) // for parsing cookies

// Templates
app.set('views', paths.templatePath)
app.engine('mustache', mustache(paths.templatePath))
app.set('view engine', 'mustache')
app.set('view cache', process.env.NODE_ENV === 'production') // Only cache templates in production

// API
app.use('/api', router)

// Static files
app.use('/css', express.static(paths.cssPath))
app.use('/js', express.static(paths.jsPath))
app.use('/images', express.static(paths.imgPath))
app.use('/themes', express.static(paths.themePath))

app.get('/favicon.png', function (req, res) {
  res.sendFile(paths.imgPath + 'logo.png')
})
github darkwire / darkwire.io / src / app.js View on Github external
let usage = 0;

const $CONFIG = {
  port: process.env.port || process.env.PORT || 3000
};

const app = express();
const server = http.createServer(app);
const io = Io(server);

let rooms = [];

app.use(compression());
app.use(favicon(__dirname + '/public/favicon.ico'));
app.engine('mustache', mustacheExpress());
app.set('view engine', 'mustache');
app.set('views', __dirname + '/views');
app.use(express.static(__dirname + '/public'));

function generateNewRoom(req, res, id) {
  const room = new Room(io, id);
  rooms.push(room);
  console.log(`rooms created: ${usage++}`);

  return res.redirect(`/${id}`);
}

function stripName(name) {
  const chatName = name.toLowerCase().replace(/[^A-Za-z0-9]/g, '-');
  if (chatName.length >= 50) {
    return chatName.substr(0, 50);

mustache-express

Use mustache, including partials, in Express 3

MIT
Latest version published 3 years ago

Package Health Score

57 / 100
Full package analysis

Popular mustache-express functions