franciscop / server

:desktop_computer: Simple and powerful server for Node.js
https://serverjs.io/
MIT License
3.56k stars 171 forks source link

nunjucks alpha3 #81

Closed coderam closed 6 years ago

coderam commented 6 years ago

Description

// Import the library
const server = require('server');
const express = require('express');
const nano = require('nano')('http://localhost:5984');

const settings = require('settings');

const app = express;
const { get, post } = server.router;
const { render, json, redirect, status } = server.reply;

const nunjucks = require('nunjucks');
var env = nunjucks.configure('views'); 

const engine = {
    port: settings.PORT,
  nunjucks: (file, options) => require('nunjucks').render(file, options)
};

server(engine, ctx => render('index.nunjucks', {  }));

[Tue Mar 06 2018 00:41:58 GMT-0600 (CST)] ERROR Error: Module "nunjucks" does not provide a view engine.
    at new View (/home/acer/nodespace/node_modules/express/lib/view.js:84:13)
    at Function.render (/home/acer/nodespace/node_modules/express/lib/application.js:570:12)
    at ServerResponse.render (/home/acer/nodespace/node_modules/express/lib/response.js:1008:7)
    at Promise (/home/acer/nodespace/node_modules/server/reply/reply.js:139:13)
    at new Promise (<anonymous>)
    at stack.push.ctx (/home/acer/nodespace/node_modules/server/reply/reply.js:136:26)
    at Reply.exec (/home/acer/nodespace/node_modules/server/reply/reply.js:175:11)
    at processReturn (/home/acer/nodespace/node_modules/server/src/join/index.js:11:22)
    at Object.middle (/home/acer/nodespace/node_modules/server/src/join/index.js:43:17)
franciscop commented 6 years ago

This is not a support forum @coderam (nor is my email for that matter). If you have an issue that you think it's caused by server.js open an issue and I will try to fix it, but please state how to reproduce it, explain the issue, etc. Just copy/paste a bit of code that uses 3 different servers and an error message is not acceptable and that is why there's a template for you to fill when you write an issue.