0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

Added basic GUI

This commit is contained in:
Brian Peacock 2014-05-06 16:34:48 -05:00
parent edee08a778
commit 37afd429ec
3 changed files with 23 additions and 16 deletions

View file

@ -11,6 +11,8 @@ var express = require('express')
, validate_name = Middleware.validate_name , validate_name = Middleware.validate_name
, media = Middleware.media , media = Middleware.media
, expect_json = Middleware.expect_json , expect_json = Middleware.expect_json
, Handlebars = require('handlebars')
, fs = require('fs');
function match(regexp) { function match(regexp) {
return function(req, res, next, value, name) { return function(req, res, next, value, name) {
@ -107,12 +109,6 @@ module.exports = function(config_hash) {
app.param('_rev', match(/^-rev$/)) app.param('_rev', match(/^-rev$/))
app.param('org_couchdb_user', match(/^org\.couchdb\.user:/)) app.param('org_couchdb_user', match(/^org\.couchdb\.user:/))
/* app.get('/', function(req, res) {
res.send({
error: 'unimplemented'
})
})*/
/* app.get('/-/all', function(req, res) { /* app.get('/-/all', function(req, res) {
var https = require('https') var https = require('https')
var JSONStream = require('JSONStream') var JSONStream = require('JSONStream')
@ -125,6 +121,14 @@ module.exports = function(config_hash) {
}) })
})*/ })*/
var template = Handlebars.compile(fs.readFileSync('../lib/GUI/index.handlebars', {encoding: 'UTF-8'}));
app.get('/', can('access'), function(req, res, next) {
res.setHeader('Content-Type', 'text/html');
res.send(template({
name: "Sinopia"
}));
});
// TODO: anonymous user? // TODO: anonymous user?
app.get('/:package/:version?', can('access'), function(req, res, next) { app.get('/:package/:version?', can('access'), function(req, res, next) {
storage.get_package(req.params.package, {req: req}, function(err, info) { storage.get_package(req.params.package, {req: req}, function(err, info) {

View file

@ -129,7 +129,9 @@ module.exports.log_and_etagify = function(req, res, next) {
res.send = function(body) { res.send = function(body) {
try { try {
if (typeof(body) === 'string' || typeof(body) === 'object') { if (typeof(body) === 'string' || typeof(body) === 'object') {
if (!res.getHeader('Content-type')) {
res.header('Content-type', 'application/json') res.header('Content-type', 'application/json')
}
if (typeof(body) === 'object' && body != null) { if (typeof(body) === 'object' && body != null) {
if (body.error) { if (body.error) {

View file

@ -15,16 +15,17 @@
"sinopia": "./bin/sinopia" "sinopia": "./bin/sinopia"
}, },
"dependencies": { "dependencies": {
"express": "3.4.x",
"commander": ">= 2.1.0",
"js-yaml": ">= 3.0.1",
"cookies": ">= 0.3.8",
"request": ">= 2.31.0",
"async": ">= 0.2.9", "async": ">= 0.2.9",
"semver": ">= 2.2.1",
"minimatch": ">= 0.2.14",
"bunyan": ">= 0.22.1", "bunyan": ">= 0.22.1",
"mkdirp": ">= 0.3.5" "commander": ">= 2.1.0",
"cookies": ">= 0.3.8",
"express": "3.4.x",
"handlebars": "^2.0.0-alpha.2",
"js-yaml": ">= 3.0.1",
"minimatch": ">= 0.2.14",
"mkdirp": ">= 0.3.5",
"request": ">= 2.31.0",
"semver": ">= 2.2.1"
}, },
"optionalDependencies": { "optionalDependencies": {
"fs-ext": ">= 0.3.2" "fs-ext": ">= 0.3.2"