Game server for the js13kGames Competition.
Download the skeleton. Extract the files and install the third party libraries with npm
.
npm install
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
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) { ... }
}
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.
All server category entries must be hosted on Heroku. You can either use free or paid plan.
You can find more information about the platform on the Heroku Dev Center site.
public
folder.Sandbox server
Package size still below 13 kB
Sandboxed environment
Do not leak the sandbox
procfile
and the skeleton code.Socket.io client lib
<script src="https://github.com/js13kGames/js13kserver/raw/master/socket.io/socket.io.js"></script>
to your HTML and that will be loaded. No server configuration will be needed. The sandbox already did it.Google's free STUN servers are the only allowed external services:
Can I test the sandbox before submitting?
Is there any example? How do I develop my game using the sandbox server?
I have more questions!
Can I minify the server side code?
Can I add more npm packages?
What files count in the 13kb limit?
public
folder.Can I deploy new code after I submited the entry?
Can I modify the procfile
or the skeleton code?