rest-tagging
Advanced tools
Comparing version 0.0.2 to 0.0.3
24
app.js
@@ -18,9 +18,11 @@ // Generated by CoffeeScript 1.6.3 | ||
(function() { | ||
var PREFIX, RedisTagging, app, express, rt; | ||
var RESTPREFIX, RedisTagging, app, cfg, express, rt; | ||
PREFIX = "rt"; | ||
cfg = require("./config.json"); | ||
RESTPREFIX = cfg.rest_path_prefix; | ||
RedisTagging = require("redis-tagging"); | ||
rt = new RedisTagging(); | ||
rt = new RedisTagging(cfg.redis); | ||
@@ -42,3 +44,3 @@ express = require('express'); | ||
app.put('/' + PREFIX + '/id/:bucket/:id', function(req, res) { | ||
app.put('/' + RESTPREFIX + '/id/:bucket/:id', function(req, res) { | ||
var tags; | ||
@@ -60,3 +62,3 @@ tags = JSON.parse(req.query.tags || "[]"); | ||
app["delete"]('/' + PREFIX + '/id/:bucket/:id', function(req, res) { | ||
app["delete"]('/' + RESTPREFIX + '/id/:bucket/:id', function(req, res) { | ||
return rt.remove(req.params, function(err, resp) { | ||
@@ -71,3 +73,3 @@ if (err) { | ||
app.get('/' + PREFIX + '/id/:bucket/:id', function(req, res) { | ||
app.get('/' + RESTPREFIX + '/id/:bucket/:id', function(req, res) { | ||
return rt.get(req.params, function(err, resp) { | ||
@@ -82,3 +84,3 @@ if (err) { | ||
app.get('/' + PREFIX + '/allids/:bucket', function(req, res) { | ||
app.get('/' + RESTPREFIX + '/allids/:bucket', function(req, res) { | ||
return rt.allids(req.params, function(err, resp) { | ||
@@ -93,3 +95,3 @@ if (err) { | ||
app.get('/' + PREFIX + '/tags/:bucket', function(req, res) { | ||
app.get('/' + RESTPREFIX + '/tags/:bucket', function(req, res) { | ||
req.query.bucket = req.params.bucket; | ||
@@ -106,3 +108,3 @@ req.query.tags = JSON.parse(req.query.tags || "[]"); | ||
app.get('/' + PREFIX + '/toptags/:bucket/:amount', function(req, res) { | ||
app.get('/' + RESTPREFIX + '/toptags/:bucket/:amount', function(req, res) { | ||
return rt.toptags(req.params, function(err, resp) { | ||
@@ -117,3 +119,3 @@ if (err) { | ||
app.get('/' + PREFIX + '/buckets', function(req, res) { | ||
app.get('/' + RESTPREFIX + '/buckets', function(req, res) { | ||
return rt.buckets(function(err, resp) { | ||
@@ -128,3 +130,3 @@ if (err) { | ||
app["delete"]('/' + PREFIX + '/bucket/:bucket', function(req, res) { | ||
app["delete"]('/' + RESTPREFIX + '/bucket/:bucket', function(req, res) { | ||
rt.removebucket(req.params, function(err, resp) { | ||
@@ -131,0 +133,0 @@ console.log(resp); |
{ | ||
"name": "rest-tagging", | ||
"description": "A REST interface for redis-tagging", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"author": "P. Liess <smrchy+npm@gmail.com>", | ||
@@ -10,8 +10,7 @@ "engines": { | ||
"scripts": { | ||
"test": "mocha ./test/test.js", | ||
"start": "node ./server.js" | ||
"test": "mocha ./test/test.js" | ||
}, | ||
"dependencies": { | ||
"redis-tagging": "*", | ||
"express": "*" | ||
"express": "*" | ||
}, | ||
@@ -18,0 +17,0 @@ "devDependencies": { |
@@ -15,4 +15,4 @@ # REST Tagging | ||
* For the test make sure Redis runs locally and run `npm test` | ||
* *Optional:* Modify the server port in server.js | ||
* Start the server: `node server.js` | ||
* *Optional:* Modify the default parameters (namespaces and Redis host) in config.json | ||
* Start the server: `npm start` | ||
@@ -40,3 +40,3 @@ | ||
Response: | ||
Returns: | ||
@@ -51,3 +51,3 @@ `true` | ||
Response: | ||
Returns: | ||
@@ -58,4 +58,4 @@ `true` | ||
**The main method.** Return the IDs for one or more tags. When more than one tag is supplied the query can be an intersection (default) or a union. | ||
`type=inter` (default) only those IDs will be returned where all tags match. | ||
**The main method.** Return the IDs for one or more tags. When more than one tag is supplied the query can be an intersection (default) or a union. | ||
`type=inter` (default) only those IDs will be returned where all tags match. | ||
`type=union` all IDs where any tag matches will be returned. | ||
@@ -78,3 +78,3 @@ | ||
``` | ||
```json | ||
{ | ||
@@ -90,3 +90,5 @@ "total_items":108, | ||
`SELECT * FROM Concerts WHERE ID IN (8167,25652) ORDER BY Timestamp DESC` | ||
```sql | ||
SELECT * FROM Concerts WHERE ID IN (8167,25652) ORDER BY Timestamp DESC | ||
``` | ||
@@ -104,10 +106,12 @@ | ||
```json | ||
{ | ||
"total_items": 18374, | ||
"items":[ | ||
{"tag":"rock", "count":1720}, | ||
{"tag":"pop", "count":1585}, | ||
{"tag":"New York", "count":720} | ||
] | ||
} | ||
``` | ||
{"total_items": 18374, | ||
"items":[ | ||
{"tag":"rock", "count":1720}, | ||
{"tag":"pop", "count":1585}, | ||
{"tag":"New York", "count":720} | ||
]} | ||
``` | ||
@@ -124,3 +128,3 @@ ### GET */rt/id/:bucket/:id* | ||
``` | ||
```json | ||
[ | ||
@@ -143,3 +147,3 @@ "rock", | ||
``` | ||
```json | ||
[ | ||
@@ -163,3 +167,3 @@ "id123", | ||
``` | ||
```json | ||
[ | ||
@@ -166,0 +170,0 @@ "concerts", |
@@ -5,3 +5,3 @@ // Generated by CoffeeScript 1.6.3 | ||
PORT = 8102; | ||
PORT = require("./config.json").port; | ||
@@ -8,0 +8,0 @@ app = require("./app"); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24649
13
363
180