js13kGames / js13kserver

js13kGames Server category files and rules
90 stars 33 forks source link

js13kgames.com Game Server

Game server for the js13kGames Competition.

Install

Download the skeleton. Extract the files and install the third party libraries with npm.

npm install

Running

You can run the server locally with the following command:

npm run start:dev

You can reach the test server at http://localhost:3000

The dev server uses nodemon to auto restart when you change some source file. If you want to pass some parameter to it, just add an -- after start:dev. An example:

npm run start:dev -- --inspect

Code structure

All your code must be in the public folder. Put your server side code into the server.js file. The shared.js file is loaded at the begining of the server.js file. You can also use this code on the client side.

The server.js is a standard Node.js module. You can use the following structure to create new Express routes or Socket.io connection handler.

module.exports = {
    // Express route to /hello
    hello => (req, res) { ... }
    // Socket.io connection event handler
    io => (socket) { ... }
}

Persistent storage

The server category entries can use 13kByte persistent storage. The key and value size also counts into the limit!

The storage uses SQL database to save the key/value pairs. By default it's SQLite but on Heroku you have to use the Postgres add-on!

In the server.js file you can access the storage interface. The API documentation is inside the lib folder.

Deploy to Heroku

All server category entries must be hosted on Heroku. You can either use free or paid plan.

  1. Push your files to your GitHub repository
  2. Create new WebApp on heroku
  3. Add Heroku Postgres add-on (optional)
  4. Connect your WebApp with the GitHub repository
  5. Deploy your code

You can find more information about the platform on the Heroku Dev Center site.

Submit your entry

  1. Zip all files in the public folder.
  2. Submit your entry on the js13kgames.com site.
  3. Add contact@js13kgames.com games as collaborator to your Heroku WebApp.

Server category rules

FAQ