npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nfactorial/playcanvas_server

v1.0.35

Published

Test server for working with playcanvas.

Downloads

4

Readme

Build status

| Linux | | :---------------: | | lin-badge |

PlayCanvas Server

Node server code for PlayCanvas title development. The server code in this module is not intended for production deployment but, rather, to quickly get up and running with a server for early testing.

git clone https://github.com/nfactorial/playcanvas_server
npm install

To run the unit tests you must have mocha installed:

npm install -g mocha

Once mocha is installed, the unit tests can be run with:

npm run test

This library makes use of the game state module also available via npm.

Usage

To use this library, install it into your project using npm:

npm install --save @nfactorial/playcanvas_server

Then, inside your main entry file, require the module, create an instance of the GameServer object and then invoke the run method:

const GameServer = require('@nfactorial/playcanvas_server').GameServer;

const game = new GameServer();

game.run();

By default, the game server will listen on port 2000. You may change this by supplying the port number as a parameter to the run method.

The GameServer object uses express to manage the HTTP requests, you may add your own routes to the express application via the 'expressServer' variable of the GameServer instance.

Script Server

During development it is useful for your PlayCanvas scripts to be supplied from your local machine. Allowing you to iterate quickly on script development, to simplify setup for this the module supplies a simply configured script server that can be taken advantage of.

To create a script server, require the module, create an instance of the ScriptServer object and then invoke the run method:

const ScriptServer = require('@nfactorial/playcanvas_server').ScriptServer;

const scripts = new ScriptServer();

scripts.run(__dirname, '/development');

The PlayCanvas editor expects scripts to be supplied on port 9000 and the ScriptServer object defaults to this port number. The first parameter supplied to the run method specifies the root directory on the local machine and the second parameter specifies the sub-folder where the script files located. Scripts also reside within a 'scripts' folder. For example, if we specify '/development' (as we have in the above example) the file 'myscript.js' would be located at './development/scripts/myscript.js'.

Script servers should only be used when running locally.

Facebook Authentication

The game server makes use of passport.js and Facebook to allow support for user sign-user with Facebook. It then connects to Cognito on AWS to help manage user accounts. In-order to provide this support, you must provide a number of environment variables to configure the Facebook authentication.

The settings for these variables should not be stored in version control for security reasons.

FACEBOOK_APP_ID Set to the application ID assigned to your facebook application.

FACEBOOK_APP_SECRET Set to the application secret code assigned to your Facebook application. For security reasons, you should only use the app secret on the server side and it should not be present anywhere else.

FACEBOOK_CALLBACK_URL The URL to be invoked by Facebook once sign-in has completed.

AWS_ACCOUNT_ID The ID of the AWS account to be used by the server.

AWS_REGION The region which contains your Cognito identity pool.

AWS_IAM_ROLE_ARN The IAM role to be used by the server.

AWS_COGNITO_IDENTITY_POOL_ID; The identifier associated with the cognito identity pool to be used. This value can be obtained from Cognito within the AWS console.

When facebook completes the authentication process, it redirects the browser to a 'success' page. This module renders a template HTML file in response and sends it to the user. The template file should reside in the projects './views' folder. During rendering the template file will be supplied with a variable called 'user' which contains the JSON description of the logged in user.

Facebook sign-in can be disabled by.... [TODO!]