Build a file-based key-value data store that supports the basic CRD (create, read, and delete) operations. This data store is meant to be used as a local storage for one single process on one laptop. The data store must be exposed as a library to clients that can instantiate a class and work with the data store.
- Download or Clone this Repository
- Run this command
npm install
, This will install all the dependencies. - To run the application all you have to type is
npm start
ornpm start <absolute_path_datastore>
This Application only allows three functions those are:
- Create
- Read
- Delete
This function only supports POST method, this method only accepts JSON format. The Key should always be a string capped at 32chars and value is always JSON capped at 16KB. Create cannot be invoked for an existing key. If key is already present in the datastore then appropriate message is shown.
This Method can be imported from CRD library as
const CRD = require("./CRD/CRD");
CRD.Create(key_to_be_inserted, data_path_of_your_datastore);
This function only supports GET method, this method accepts key from the user and searches for the key in the DataStore and returns the value for the key, if not found then appropriate message is shown. If any value has Time-To-Live
property, Once the Time-To-Live for a key has expired,
the key will no longer be available for Read or Delete operations.
This Method can be imported from CRD library as
const CRD = require("./CRD/CRD");
CRD.Read(key_to_be_searched, data_path_of_your_datastore);
This function only supports DELETE method, this method accepts key from the user and searches for the key in the DataStore and deletes the value for the key, if not found then appropriate message is shown.. If any value has Time-To-Live
property, Once the Time-To-Live for a key has expired,
the key will no longer be available for Read or Delete operations.
This Method can be imported from CRD library.
const CRD = require("./CRD/CRD");
CRD.Delete(key_to_be_deleted, data_path_of_your_datastore);
API supports three function those are
GET
=> This method is used to read the data from datastore using the key.POST
=> This method is used to create and store data into datastore.DELETE
=> This method is used to delete the data from datastore using the key.
The following are not allowed in the application
- Use appropriate method for CRD, that is
GET
is used for Read function,POST
is used for Create function andDELETE
is used for Delete function. if any other method is used it will show you the help page. - Please use a valid directory of your datastore.
- If an absolute path is given then the file name should have
.json
extension.
This API gives you flexibility to use the API in two ways, those are:
http://localhost:3000/create/<JSON_Data>
http://localhost:3000/create?key=<JSON_Data>
Either of the above options can be used. If any incorrect way is used then it will automatically direct you to the help page.
This API gives you flexibility to use the API in two ways, those are:
http://localhost:3000/read/<The_key_to_be_read>
http://localhost:3000/read?key=<The_key_to_be_read>
Either of the above options can be used. If any incorrect way is used then it will automatically direct you to the help page.
This API gives you flexibility to use the API in two ways, those are:
http://localhost:3000/delete/<The_key_to_be_deleted>
http://localhost:3000/delete?key=<The_key_to_be_deleted>
Either of the above options can be used. If any incorrect way is used then it will automatically direct you to the help page.