Giter Site home page Giter Site logo

brightsign-node-js-starter's Introduction

BrightSign Node.js Sample

This sample BrightAuthor:connected application shows how to instantiate a node.js server that runs on a BrightSign player. It creates a web server that can serve static files from port 9090. 

This example was created for BrightAuthor:connected.

Prerequisites

  • If you don’t have it already, download Nodejs to install Node.js and npm.
  • Your computer and BrightSign player must be connected to the internet.
  • BrightAuthor:connected should already be downloaded and installed on your computer.

Deploying a Node.js Aerver Application with BrightAuthor:connected

Create your Node.js Application

  1. Clone the project or download ZIP, and then unzip node.js-starter-project-master.zip.
  2. If you have not run npm previously, run npm init in your terminal to initialize the install. If you wish, you can import other modules with npm  install for additional functionality.
  3. Import the node modules you will need your application to function and write your JavaScript code (in this example, the node modules are all included in express and the JavaScript is in index.js). From the Downloads folder, run:
npm install --save express  
  1. Run these Webpack commands to package your node application as a single JavaScript file (see Appendix B: Notes for more details): 
npm install --save-dev webpack webpack-cli copy-webpack-plugin zip-webpack-plugin  

npx webpack --mode production    

Create your Application

After running Webpack, follow the steps below to create your application. This example assumes that you have the latest version of BrightAuthor:connected:

  1. In the Presentation dropdown menu, select New Presentation.
  2. Select Single Zone > Node.js as the presentation type.
  3. Enter a presentation name and select the application folder icon under Node.js.
  4. In the pop-up window, choose the bundle.js example under the dist folder or include your own JavaScript application. Then choose Select:
  5. In the main window, select Start.
  6. Save and publish your presentation.

If you have a more complex node application, or don't have the latest version of BrightAuthor:connected, you may need to use an alternate method to create your application. See Appendix A for this method.

Display Files from your Webserver 

If you have used the unmodified example, you can access the files in your root directory or in your directory folder using the link in a browser. For example:

http://<ip_address_of_ BrightSign>:9090/filename

Appendix

Appendix A: An Alternate Method

If you have a more complex node application, or don't have the latest version of BrightAuthor:connected, you can use these steps to create your application:

  1. Create an html file or use the node-server.html file that is provided in the node.js-starter-project-master folder, as the application entry point.
  2. In the Presentation dropdown menu, select New Presentation and enter a presentation name.
  3. Expand Presentation Settings and select Support Content.
  4. Under Script Plugin, add your plugin or use node-server.brs from the example, to enable Node.js in your presentation.
  5. Use the “File Select” icon to add your application zip as an additional file (for example, dist/node-server.zip).

Appendix B: Notes

  • The  node_modules directory contains a lot of unnecessary files in addition to the code your application needs, and its size can be a problem when you deploy your application to an SD card or publish it to the cloud. Webpack, which bundles JavaScript modules to use in browsers, solves this problem.
  • An example is included to help you use BrightSign Javascript objects. See the "externals" section of the webpack.config.js.
  • See the BrightSign Node.js documentation for more information.

brightsign-node-js-starter's People

Contributors

dependabot[bot] avatar jsinai avatar stmulq avatar

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.