Skip to content

Jayvirrathi/node-redis-rest-api

Repository files navigation

REST API with Node.js, Redis using Redis-Om

Prerequisites

  • Nodejs
  • Redis/Docker

Build Setup

# install dependencies
npm install

Env

Rename file named .env.sample to .env.

docker

docker run -p 6380:6379 redislabs/redismod:preview
REDIS_URL=redis://localhost:6380

cloud url

REDIS_URL=redis://default:PASSWORD@HOST:PORT

Start Project url

npm run dev

Request:

User

create Index for search

POST api/v1/create/song/

POST api/v1/song/
{
  "title": "Bug in the JavaScript",
  "artist": "Dylan Beattie and the Linebreakers",
  "genres": ["folk rock", "parody", "pop rock", "rock"],
  "lyrics": "It’s nine-o-clock on a Saturday,\\nYou should be out having fun,\\nBut there’s one bug left in the next release,\\nAnd you’re not going out ‘till it’s done,\\n\\nYou’ve checked all the database indexes,\\nYou’ve tested your API hooks,\\nAnd you’re starting to think, that you might need that drink\\n‘Cos there’s only one place left to look…\\n\\nThere must be a bug in the JavaScript,\\nThe bug’s in the single page app,\\nBecause everything else was built properly,\\nBut the front end’s a pile of crap\\n\\nNow null is a reference to nothing,\\nDon’t mix it up with undefined,\\nAnd there’s zero and NaN, and Infinity, man,\\nJust remember which ones can be signed,\\nAnd you think that you’re working with integers,\\nWhen you’re really in floating point hell,\\nAnd your objects are hashes, but when your code crashes,\\nYou’ll find they were functions as well,\\n\\nIt was never intended to do all this,\\nThey say it was built in ten days,\\nBut it’s out of the bottle, it’s going full throttle,\\nWe’ve all caught the JavaScript craze,\\nWell we use it for code that runs everywhere,\\nFrom the cloud to your mobile phone,\\nBut we’re sharing a string padding library,\\n‘Cos it’s better than writing our own\\n\\nNow JavaScript’s not a bad language,\\nThough it’s frequently misunderstood,\\nBut before you see what you can use it for,\\nPlease stop to think whether you should,\\nBecause just about everything’s true here,\\nIt’s all part of the language design\\nExcept zero, blank strings, the array of no things,\\nAnd the end of 1969",
  "music": "\"Piano Man\" by Billy Joel",
  "year": 2019,
  "duration": 360,
  "link": "https://www.youtube.com/watch?v=jxi0ETwDvws"
}