Small project to search commits from your repository.
After server was loaded data will be stored to Redis database from api endpoint.
There are several steps to:
- create Schema like this:
const commitSchema = new Schema(Commit, {
message: { type: 'text' },
author: { type: 'string' },
url: { type: 'string' }
})
- get data from your repository:
const response = octokit.request('GET https://api.github.com/repos/{owner}/{repo}/commits', {
owner: process.env.GITHUB_OWNER,
repo: process.env.GITHUB_REPO
});
- save data to Redis
response.then(function(result) {
result.data.map((commit) => {
saveDataToRedis(
commit.commit.message,
commit.commit.author.name,
commit.html_url,
)
})
})
- create index in Redis:
await commitRepository.createIndex()
Data will be loaded from server via endpoints to frontend. There you can see all commits and search for data.
- Get all data (used search() function from Redis repository)
app.get('/commits', async (req, res) => {
const commits = await commitRepository.search().return.all();
res.json(commits)
})
- Search messages (used search() function from Redis repository with parameters)
app.post('/search', async (req, res) => {
const commits = await commitRepository.search().where('message').matches(req.body.message).return.all()
res.json(commits)
})
- Server (Node.js) -> node server.js
- Frontend (React) -> npm start
- For development was used Docker to run Redis. You can self host Redis or create an account at official website Redis Cloud.
- Generate token from your GitHub account
- Install Node.js and NPM
- Create .env file with variables:
- REDIS_URL
- GITHUB_TOKEN
- GITHUB_OWNER
- GITHUB_REPO
Pull data from repository Github
Here some resources to help you quickly get started using Redis Stack. If you still have questions, feel free to ask them in the Redis Discord or on Twitter.
- Sign up for a free Redis Cloud account using this link and use the Redis Stack database in the cloud.
- Based on the language/framework you want to use, you will find the following client libraries:
- Redis OM .NET (C#)
- Watch this getting started video
- Follow this getting started guide
- Redis OM Node (JS)
- Watch this getting started video
- Follow this getting started guide
- Redis OM Python
- Watch this getting started video
- Follow this getting started guide
- Redis OM Spring (Java)
- Watch this getting started video
- Follow this getting started guide
- Redis OM .NET (C#)
The above videos and guides should be enough to get you started in your desired language/framework. From there you can expand and develop your app. Use the resources below to help guide you further:
- Developer Hub - The main developer page for Redis, where you can find information on building using Redis with sample projects, guides, and tutorials.
- Redis Stack getting started page - Lists all the Redis Stack features. From there you can find relevant docs and tutorials for all the capabilities of Redis Stack.
- Redis Rediscover - Provides use-cases for Redis as well as real-world examples and educational material
- RedisInsight - Desktop GUI tool - Use this to connect to Redis to visually see the data. It also has a CLI inside it that lets you send Redis CLI commands. It also has a profiler so you can see commands that are run on your Redis instance in real-time
- Youtube Videos
- Official Redis Youtube channel
- Redis Stack videos - Help you get started modeling data, using Redis OM, and exploring Redis Stack
- Redis Stack Real-Time Stock App from Ahmad Bazzi
- Build a Fullstack Next.js app with Fireship.io
- Microservices with Redis Course by Scalable Scripts on freeCodeCamp