by Vibert Thio
Hi there, I suppose that you want to build a web game with a small server. It can support a leaderboard, or even a user login system.
First of all, you need to build a web-based game. If you have no idea what to build, you can fork the project "Whack A Mole".
Remix my project "simple-game-server"
Glitch will automatically generate a database and setup the server for you. The server is written with Node.js, Express, and Sequalize (ORM).
Open SQLite3 in "Console"
You can open the console in Glitch.
sqlite3 .data/database.sqlite
Try play around with the database live in the console using common SQL commands. You will see things like below.
sqlite> .tables
records
sqlite> select * from records;
1|Vibert|50|2019-12-10 04:31:23.200 +00:00|2019-12-10 04:31:23.200 +00:00
2|Thio|10|2019-12-10 04:32:38.911 +00:00|2019-12-10 04:32:38.911 +00:00
CORS setup
CORS have be set because of security issues.
var corsOptions = {
origin: [
'<https://simple-game-server.glitch.me>',
'{URL OF YOUR WEBSITE}' // e.g. <https://vibertthio.com>
],
optionsSuccessStatus: 200
}
Now we can add few lines of JavaScript to get the data on the server!