Home / File/ github-view.js — express Source File

github-view.js — express Source File

Architecture documentation for github-view.js, a javascript file in the express codebase.

Entity Profile

Relationship Graph

Source Code

'use strict'

/**
 * Module dependencies.
 */

var https = require('node:https');
var path = require('node:path');
var extname = path.extname;

/**
 * Expose `GithubView`.
 */

module.exports = GithubView;

/**
 * Custom view that fetches and renders
 * remove github templates. You could
 * render templates from a database etc.
 */

function GithubView(name, options){
  this.name = name;
  options = options || {};
  this.engine = options.engines[extname(name)];
  // "root" is the app.set('views') setting, however
  // in your own implementation you could ignore this
  this.path = '/' + options.root + '/master/' + name;
}

/**
 * Render the view.
 */

GithubView.prototype.render = function(options, fn){
  var self = this;
  var opts = {
    host: 'raw.githubusercontent.com',
    port: 443,
    path: this.path,
    method: 'GET'
  };

  https.request(opts, function(res) {
    var buf = '';
    res.setEncoding('utf8');
    res.on('data', function(str){ buf += str });
    res.on('end', function(){
      self.engine(buf, options, fn);
    });
  }).end();
};

Domain

Subdomains

Frequently Asked Questions

What does github-view.js do?
github-view.js is a source file in the express codebase, written in javascript. It belongs to the ViewEngine domain, LocalsManagement subdomain.
What functions are defined in github-view.js?
github-view.js defines 2 function(s): GithubView, render.
Where is github-view.js in the architecture?
github-view.js is located at examples/view-constructor/github-view.js (domain: ViewEngine, subdomain: LocalsManagement, directory: examples/view-constructor).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free