How to use the nodal.Controller function in nodal

To help you get started, we’ve selected a few nodal 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 keithwhor / nodal / src / app / controllers / static_controller.js View on Github external
module.exports = (function() {

  'use strict';

  const Nodal = require('nodal');
  const crypto = require('crypto');
  const fs = require('fs');

  const Error404Controller = Nodal.require('app/controllers/error/404_controller.js');

  class StaticController extends Nodal.Controller {

    get() {

      let filepath = this.params.matches[0];
      let ext = filepath.substr(filepath.lastIndexOf('.') + 1);
      filepath = filepath.replace(/(\.){1,2}\//gi, '');

      fs.readFile(`./static/${filepath}`, (err, buffer) => {

        if (err) {
          return Error404Controller.prototype.get.call(this);
        }

        this.setHeader('Content-Type', Nodal.Mime.lookup(ext) || 'application/octet-stream');

        if (this.getHeader('Content-Type').split(';')[0].split('/')[0] === 'video') {
github keithwhor / nodal / src / app / controllers / auth_controller.js View on Github external
'use strict';

const Nodal = require('nodal');

class AuthController extends Nodal.Controller {

  authorize(callback) {

    this.setHeader('Cache-Control', 'no-store');
    this.setHeader('Pragma', 'no-cache');

    callback(null);

  }

}

module.exports = AuthController;
github keithwhor / nodal / src / app / controllers / error / 404_controller.js View on Github external
module.exports = (function() {

  "use strict";

  const Nodal = require('nodal');

  class Error404Controller extends Nodal.Controller {

    get() {

      this.status(404);

      this.render(
        Nodal.Template.generate('error/404.html').render(this.params)
      );

    }

  }

  return Error404Controller;

})();
github keithwhor / nodal / src / app / controllers / index_controller.js View on Github external
'use strict';

const Nodal = require('nodal');

class IndexController extends Nodal.Controller {

  get() {

    this.respond({message: 'Welcome to your Nodal Project'});

  }

}

module.exports = IndexController;

nodal

An API Server and Framework for node.js

MIT
Latest version published 1 year ago

Package Health Score

48 / 100
Full package analysis