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:
parent
edee08a778
commit
37afd429ec
3 changed files with 23 additions and 16 deletions
16
lib/index.js
16
lib/index.js
|
@ -11,6 +11,8 @@ var express = require('express')
|
|||
, validate_name = Middleware.validate_name
|
||||
, media = Middleware.media
|
||||
, expect_json = Middleware.expect_json
|
||||
, Handlebars = require('handlebars')
|
||||
, fs = require('fs');
|
||||
|
||||
function match(regexp) {
|
||||
return function(req, res, next, value, name) {
|
||||
|
@ -107,12 +109,6 @@ module.exports = function(config_hash) {
|
|||
app.param('_rev', match(/^-rev$/))
|
||||
app.param('org_couchdb_user', match(/^org\.couchdb\.user:/))
|
||||
|
||||
/* app.get('/', function(req, res) {
|
||||
res.send({
|
||||
error: 'unimplemented'
|
||||
})
|
||||
})*/
|
||||
|
||||
/* app.get('/-/all', function(req, res) {
|
||||
var https = require('https')
|
||||
var JSONStream = require('JSONStream')
|
||||
|
@ -124,6 +120,14 @@ module.exports = function(config_hash) {
|
|||
console.log(d)
|
||||
})
|
||||
})*/
|
||||
|
||||
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?
|
||||
app.get('/:package/:version?', can('access'), function(req, res, next) {
|
||||
|
|
|
@ -129,7 +129,9 @@ module.exports.log_and_etagify = function(req, res, next) {
|
|||
res.send = function(body) {
|
||||
try {
|
||||
if (typeof(body) === 'string' || typeof(body) === 'object') {
|
||||
res.header('Content-type', 'application/json')
|
||||
if (!res.getHeader('Content-type')) {
|
||||
res.header('Content-type', 'application/json')
|
||||
}
|
||||
|
||||
if (typeof(body) === 'object' && body != null) {
|
||||
if (body.error) {
|
||||
|
|
19
package.json
19
package.json
|
@ -15,16 +15,17 @@
|
|||
"sinopia": "./bin/sinopia"
|
||||
},
|
||||
"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",
|
||||
"semver": ">= 2.2.1",
|
||||
"minimatch": ">= 0.2.14",
|
||||
"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": {
|
||||
"fs-ext": ">= 0.3.2"
|
||||
|
@ -58,4 +59,4 @@
|
|||
"type": "WTFPL",
|
||||
"url": "http://www.wtfpl.net/txt/copying/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue