Coder Social home page Coder Social logo

redislabs-training / ru102js Goto Github PK

View Code? Open in Web Editor NEW
50.0 8.0 106.0 4.34 MB

Source code for the RU102JS Redis for JavaScript Developers Course

Home Page: https://university.redis.com/courses/ru102js/

License: MIT License

HTML 1.25% JavaScript 98.50% Lua 0.25%
nodejs redis node-redis training-materials redislabs redislabs-training nosql hacktoberfest hacktoberfest2021

ru102js's Introduction

RediSolar for Node.js

Preview of running application - Solar Site Map with markers

Introduction

This is the sample application codebase for RU102JS, Redis for JavaScript Developers at Redis University.

Solutions to the course programming challenges can be found on the solutions branch.

Prerequisites

In order to start and run this application, you will need:

  • Node.js (We recommend using the current Long Term Stable version and have tested with version 18.4.2).
  • npm (installed with Node.js).
  • Access to a local or remote installation of Redis Stack - local preferred, we provide a Docker Compose file in this repo, read on for details.

If you're using Windows, check out the following resources for help with running Redis:

Setup

To get started, clone this repository:

$ git clone https://github.com/redislabs-training/ru102js.git
$ cd ru102js

Now install the dependencies:

$ npm install

You'll also need to have a Redis Stack instance running. Either install it locally, or use the Docker Compose file provided:

  • Install Docker and Docker Compose.
  • Start up the Docker daemon.
  • Run docker-compose up -d in the project directory. This command will give you Redis Stack on localhost port 6379 with no password required. The container will persist Redis data to the redisdata folder.

You should see the following once the command has successfully run:

Creating network "ru102js_default" with the default driver
Creating redis_ru102js ... done

You'll also see the redis_ru102js container running if you open up the Docker app.

If you want to shut down the Redis Stack container, use:

docker-compose down

Configuration

The application uses a configuration file, config.json to specify the port that it listens on plus some logging parameters and how it connects to a database.

The supplied config.json file is already set up to use Redis on localhost port 6379. Change these values if your Redis instance is on another host or port, or requires a password to connect.

{
  "application": {
    "port": 8081,
    "logLevel": "debug",
    "dataStore": "redis"
  },
  "dataStores": {
    "redis": {
      "host": "localhost",
      "port": 6379,
      "password": null,
      "keyPrefix": "ru102js"
    }
  }
}

The keyPrefix for Redis is used to namespace all the keys that the application generates or references. So for example a key sites:999 would be ru102js:sites:999 when written to Redis.

Load Sample Data

To load sample site data and sample metrics, run:

npm run load src/resources/data/sites.json flushdb

flushdb is optional, and will erase ALL data from Redis before inserting the sample data.

The application uses the key prefix ru102js by default, so you should be able to use the same Redis instance for this application and other data if necessary.

Development Workflow

In order to speed up development, you can run the application using nodemon, so that any changes to source code files cause the server to reload and start using your changes.

npm run dev

Edit code, application will hot reload on save.

If you want to run without nodemon, use:

npm start

But you will then need to stop the server and restart it when you change code.

Accessing the Front End Web Application

You should be able to see the front end solar dashboard app at:

http://localhost:8081/

Running Tests

The project is setup to use Jest for testing. To run all tests:

npm test

To run a specific suite of tests (e.g. those in tests/basic.test.js):

npm test -t basic

To run Jest continuously in watch mode, which gives you access to menus allowing you to run subsets of tests and many more options:

npm testdev

Optional (but Recommended): RedisInsight

RedisInsight is a graphical tool for viewing data in Redis and managing Redis server instances. You don't need to install it to be successful with this course, but we recommend it as a good way of viewing data stored in Redis.

To use RedisInsight, you'll need to download it then point it at your Redis instance. Check out the RedisInsight documentation for help.

If you're using the Docker Compose file provided with this course to run Redis Stack, you can optionally choose to access a web-based version of Redis Stack at http://localhost:8001 whenever the container is running.

Linting

This project uses ESLint with a slightly modified version of the Airbnb JavaScript Style Guide.

  • The file .eslintrc contains a short list of rules that have been disabled for this project.
  • The file .eslintignore contains details of paths that the linter will not consider when linting the project.

To run the linter:

npm run lint

Need Help / Join our Community

If you need help with the course or want to chat to your fellow students and the wider Redis community, please join us on our Discord server.

Subscribe to our YouTube Channel / Follow us on Twitch

We'd love for you to check out our YouTube channel, and subscribe if you want to see more Redis videos! We also stream regularly on our Twitch.tv channel - follow us to be notified when we're live or checkout our streaming schedule.

ru102js's People

Contributors

itsrojasleon avatar jadesingh avatar luizhap avatar pawlean avatar suzeshardlow avatar vishal5251 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ru102js's Issues

Min node version must be at least v10

Readme file specifies
Node.js (8.9.4 or newer, we recommend using the current Long Term Stable version),

But min working version is v.10.

Attempt to run with in node v 8.12.0 resulted in error:

C:\ru102js\node_modules\update-notifier\index.js:58
} catch {
^

SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object. (C:\ru102js\node_modules\nodemon\bin\nodemon.js:15:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: nodemon
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Update to use Redis Stack container

Change the container used in the Docker compose file to be the Redis Stack one, when this has support for ARM... required for Apple M1 processors.

Enhance README with instructions showing how to use Redis via Docker Compose

Enhance the README.md file, adding a section in "Setup" describing how to use Redis with the RedisTimeSeries module using the provided docker-compose.yml.

Students following this course need an instance of Redis with the RedisTimeSeries module installed. A previous Hacktoberfest contributor added docker-compose.yml for us. To be successful with this issue, you'll want to add to README.md in the "Setup" section, and tell readers that they can get started with Redis using Docker simply by doing:

docker-compose up -d

Tell them this will give them Redis on localhost port 6379 with no password required, and that it will have the required RedisTimeSeries module installed. Also show what output to expect when running the above command, and that they can shut down the Redis container when done with docker-compose down.

Mention that the container will persist Redis data to the redisdata folder.

This is part of our participation in Hacktoberfest 2021. Learn how to complete this issue here: https://developer.redis.com/hacktoberfest/

Need help or want to talk to us? Join us on Discord where we have a dedicated Hacktoberfest channel: https://discord.gg/ueQwKUh5Z3

Please ask to be assigned this issue before starting work on it!

Add a screenshot of the running application to the README

Update README.md to add a screenshot of the running application, showing the map view with the solar site markers on it. For this you will need to follow the instructions in the README to get the application running.

This is part of our participation in Hacktoberfest 2021. Learn how to complete this issue here: https://developer.redis.com/hacktoberfest/

Need help or want to talk to us? Join us on Discord where we have a dedicated Hacktoberfest channel: https://discord.gg/ueQwKUh5Z3

Update package.json to resolve npm install warnings.

Update package.json / package-lock.json to resolve the majority of issues reported by npm install (note: please do not update the version of the "redis" package used by this project, it should remain at "^2.8.0").

Ensure the existing tests still pass after you have made your changes. Details of how to run the tests can be found in the README.md file.

This is part of our participation in Hacktoberfest 2021. Learn how to complete this issue here: https://developer.redis.com/hacktoberfest/

Need help or want to talk to us? Join us on Discord where we have a dedicated Hacktoberfest channel: https://discord.gg/ueQwKUh5Z3

Add the option to use Redis via Docker Compose for this course.

Add a docker-compose.yml file that uses the RedisTimeSeries Docker container (https://hub.docker.com/r/redislabs/redistimeseries), and configure Redis in that container to persist data to a local folder named "redisdata". Here's an example file from another project that works like this (this one uses the redismod container but it's the same idea): https://github.com/redislabs-training/node-js-crash-course/blob/main/docker-compose.yml

This is part of our participation in Hacktoberfest 2021. Learn how to complete this issue here: https://developer.redis.com/hacktoberfest/

Need help or want to talk to us? Join us on Discord where we have a dedicated Hacktoberfest channel: https://discord.gg/ueQwKUh5Z3

Add a cool new feature.

Add a cool new feature that has these properties:

  • Something
  • Something else
  • Even more things

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.