This is web app buit using node, express, mongodb
Features
- All the user data and passwords are saved in MongoDB
- All levels and game data is stored in MongoDB
- Uses session and cookie to login and Presist the user logged in.
- Users passwords hash is stored in DB.
- Users can login and logout.
- Users cannot acess the higher level with out completeing the levels below.
- Client can also login as gusest.
Preview
Login page
Home page
Game play
Implimentation
Download the project and set up mongoDB. This project is designed to work on mongoDB
Installing packages
run the following node package command to install all dependencies to you project folder
npm install
.env
Now let's create .env file on the root directry of the project
USERDB_URL = your users db url
LEVELDB_URL = your projects db url
SESSON_KEY = secret encription string
Create these entries on the .env file
Add data to display
For this web app to work, You need to add game level data to games db.
// each level code should contain data structured like blow in DB.
{
title:'the text you see next to the level number on title',
answer:'answer of current level',
question:'</ question source-code here >',
level:"level of the question in number"
}
The sructure if db of level should be like above. The order if question arranged in DB will not effet the result output.
Finally
After setting up you database and .env file you are all set
Now you can start server by entering command
npm start
In which start is a script defined by us in package.json file. Which is refferd to nodemon index.js
or
node index.js
For more developement use nodemon
To install nodemon
npm install nodemon
To run nodemon
nodemon index.js
Just change node to nodemon while running your main file
So thats's it you are all set and ready to go
Thank you and stay creative.