Skip to content
This repository has been archived by the owner on Mar 22, 2018. It is now read-only.

Commit

Permalink
skeleton #132
Browse files Browse the repository at this point in the history
  • Loading branch information
arafato committed Mar 14, 2018
1 parent c99def3 commit 4ae8109
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 2 deletions.
20 changes: 20 additions & 0 deletions lib/actions/table/QueryEntities.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

const AzuriteTableResponse = require('./../../model/table/AzuriteTableResponse'),
tableStorageManager = require('./../../core/table/TableStorageManager');

class QueryEntities {
constructor() {
}

process(request, res) {
tableStorageManager.queryEntities(request)
.then((response) => {
res.set(response.httpProps);
// const payload = this._createResponsePayload(response.payload, request.accept);
res.status(200).send(payload);
});
}
}

module.exports = new QueryEntities();
3 changes: 2 additions & 1 deletion lib/core/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ const Operations = {
INSERT_ENTITY: 'InsertEntity',
DELETE_TABLE: 'DeleteTable',
DELETE_ENTITY: 'DeleteEntity',
QUERY_TABLE: 'QueryTable'
QUERY_TABLE: 'QueryTable',
QUERY_ENTITY: 'QueryEntity'
}
}

Expand Down
4 changes: 4 additions & 0 deletions lib/core/table/TableStorageManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ class TableStorageManager {
return BbPromise.resolve(new AzuriteTableResponse({ payload: payload }));
}

queryEntities(request) {
return BbPromise.resolve(new AzuriteTableResponse({}));
}

_getTable(name) {
const coll = this.db.getCollection(Tables.Tables);
const result = coll.chain()
Expand Down
4 changes: 4 additions & 0 deletions lib/middleware/table/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ actions[Operations.DELETE_ENTITY] = (request, res) => {

actions[Operations.QUERY_TABLE] = (request, res) => {
queryTable.process(request, res);
}

actions[Operations.QUERY_ENTITY] = (request, res) => {
queryTable.process(request, res);
}
5 changes: 5 additions & 0 deletions lib/middleware/table/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,9 @@ validations[Operations.DELETE_ENTITY] = (valContext) => {
validations[Operations.QUERY_TABLE] = (valContext) => {
valContext
.run(TableExistsVal)
}

validations[Operations.QUERY_ENTITY] = (valContext) => {
valContext
.run(TableExistsVal)
}
3 changes: 2 additions & 1 deletion lib/routes/table/EntityRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ const env = require('./../../core/env'),
* for details on specification.
*/
module.exports = (app) => {
// app.route(`/${env.emulatedStorageAccountName}/:table`)
app.route(new RegExp(`\/${env.emulatedStorageAccountName}\/([A-Za-z0-9]+)(.*)`))
.get((req, res, next) => {
req.azuriteOperation = Operations.QUERY_ENTITY;
req.azuriteRequest = new AzuriteTableRequest({ req: req });
next();
})
.head((req, res, next) => {
Expand Down

0 comments on commit 4ae8109

Please sign in to comment.