简体中文 | English
A simple in-memory database service built with Node.js.
- Node.js >= 14.0.0
- npm >= 6.0.0
- Lightweight in-memory database
- RESTful API interface
- Easy to use
- Basic CRUD operations support
npm install nodeMemoryDBStart the server:
npm run startThe server will start on port 81 and run as a memory database service.
- GET
/get- Parameters:
key: (Optional) Key name. Returns all data if not providedmeta: (Optional) Set to 1 to return metadata
- Parameters:
Request examples:
# Get data for specific key
curl http://localhost:81/get?key=abc
# Get data with metadata
curl http://localhost:81/get?key=abc&meta=1
# Get all data
curl http://localhost:81/getResponse example:
{
"message": "get abc success",
"data": "123"
}- GET/POST
/set- Parameters:
key: Key namevalue: Value to store
- Parameters:
Request examples:
# Using GET
curl "http://localhost:81/set?key=abc&value=123"
# Using POST
curl -X POST http://localhost:81/set \
-H "Content-Type: application/json" \
-d '{"key": "abc", "value": "123"}'Response example:
{
"message": "abc is stored",
"data": "success"
}- GET/POST
/del- Parameters:
key: Key name to delete
- Parameters:
Request example:
curl "http://localhost:81/del?key=abc"Response example:
{
"message": "abc is deleted",
"data": "success"
}- GET/POST
/clear- Note: Only accessible from localhost (127.0.0.1)
Request example:
curl http://localhost:81/clearResponse example:
{
"message": "DB is cleared",
"data": "success"
}- express: ^4.17.1
- body-parser: ^1.19.0
- cors: ^2.8.5
MIT