mirror of
https://github.com/zhigang1992/deployd.git
synced 2026-05-27 14:30:50 +08:00
added property type listing
This commit is contained in:
4
lib/collections/property-types.js
Normal file
4
lib/collections/property-types.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = function (req, res, next) {
|
||||
res.data = require('../property-types');
|
||||
next();
|
||||
};
|
||||
6
lib/internal-routes.js
Normal file
6
lib/internal-routes.js
Normal file
@@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
'/keys': './collections/keys',
|
||||
'/types': './collections/types',
|
||||
'/resources': './collections/resources',
|
||||
'/property-types': './collections/property-types'
|
||||
};
|
||||
14
lib/property-types.js
Normal file
14
lib/property-types.js
Normal file
@@ -0,0 +1,14 @@
|
||||
module.exports = {
|
||||
String: {
|
||||
defaultName: 'string'
|
||||
},
|
||||
Number: {
|
||||
defaultName: 'number'
|
||||
},
|
||||
Boolean: {
|
||||
defaultName: 'boolean'
|
||||
},
|
||||
Date: {
|
||||
defaultName: 'date'
|
||||
}
|
||||
};
|
||||
@@ -6,6 +6,7 @@ var resources = require('./collections/resources')
|
||||
, revalidator = require('revalidator')
|
||||
, keys = require('./collections/keys')
|
||||
, url = require('url')
|
||||
, internals = require('./internal-routes')
|
||||
;
|
||||
|
||||
/**
|
||||
@@ -16,7 +17,6 @@ module.exports = function (req, res, next) {
|
||||
var parsed = url.parse(req.url).path.split('?')[0].replace('/', '').split('/')
|
||||
, collections = req.collections = []
|
||||
, references = req.references = []
|
||||
, internals = {'/types': './collections/types', '/resources': './collections/resources', '/keys': './collections/keys'}
|
||||
, method = req.method
|
||||
, path = '/'
|
||||
;
|
||||
@@ -29,9 +29,7 @@ module.exports = function (req, res, next) {
|
||||
path += collections[0];
|
||||
|
||||
// route to the first collection
|
||||
resources.get({path: path}).first(function (err, resource) {
|
||||
|
||||
|
||||
resources.get({path: path}).first(function (err, resource) {
|
||||
if(internals[path]) {
|
||||
var rawHdr = req.headers['x-dssh-key']
|
||||
, authErr = {status: 401}
|
||||
|
||||
@@ -8,4 +8,15 @@ describe('Available Types', function(){
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('Property Types', function(){
|
||||
describe('GET /property-types', function(){
|
||||
it('should return an object describing the availalbe property types', function(done) {
|
||||
client.use('/property-types').get(function (err, res) {
|
||||
expect(res).to.eql(require('../lib/property-types'));
|
||||
done(err);
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user