- Notifications
You must be signed in to change notification settings - Fork0
A starter project for working with Redis and JS
redis-developer/redis-starter-js
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This is aRedis starter template for JS andNode using:
Copy and edit the.env file:
cp .env.example .env
Your.env file should contain the connection string you copied from Redis Cloud.
Your.env.docker file will look similar to.env, but should use the appropriate docker internal URLs. Here isan example:
REDIS_URL="redis://redis:6379"Next, spin up docker containers:
bun docker
You should have a server running onhttp://localhost:<port> where the port is set in your.env file (default is 8080). You can test the following routes:
GET /api/todos- Gets all todosGET /api/todos/:id- Gets a todo by IDGET /api/todos?[name=<name>]&[status=<status>]- Search for todos by name and/or statusPOST /api/todos- Create a todo with{ "name": "Sample todo" }PATCH /api/todos/:id- Update todo by ID with{ "status": "todo|in progress|complete" }DELETE /api/todos/:id- Delete a todo by ID
There are some tests in the__tests__ folder that can be run with the following command:
buntestThese tests setup and teardown on their own. You can modify them if you want to leave data in Redis.
To run the development server outside of docker:
bun install# thenbun devFormatting code:
bun format
Updating dependencies:
bun update
If you don't yet have a database setup in Redis Cloudget started here for free.
To connect to a Redis Cloud database, log into the console and find the following:
- The
public endpoint(looks likeredis-#####.c###.us-east-1-#.ec2.redns.redis-cloud.com:#####) - Your
username(defaultis the default username, otherwise find the one you setup) - Your
password(either setup through Data Access Control, or available in theSecuritysection of the databasepage.
Combine the above values into a connection string and put it in your.env and.env.docker accordingly. It shouldlook something like the following:
REDIS_URL="redis://default:<password>@redis-#####.c###.us-west-2-#.ec2.redns.redis-cloud.com:#####"Run thetests to verify that you are connected properly.
To learn more about Redis, take a look at the following resources:
- Redis Documentation - learn about Redis products, features, and commands.
- Learn Redis - read tutorials, quick starts, and how-to guides for Redis.
- Redis Demo Center - watch short, technical videos about Redis products and features.
About
A starter project for working with Redis and JS
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.