Skip to content

Commit 3e7917f

Browse files
committed
updated
1 parent 8244a23 commit 3e7917f

File tree

2,020 files changed

+266515
-22
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,020 files changed

+266515
-22
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

README.md

+25-22
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
1-
#Gamification Server
1+
# Gamification Server
22

33
Gamification-server provides a framework for providing awards/points to users or teams and can be operated either standalone or integrated with other web-based applications. Based on the notion of badges used within other gamification systems. The gamification-server is implemented as an Express.js web application, built by [DevLeague](http://www.devleague.com/).
44

55

6-
##APIs and remote usage
6+
## APIs and remote usage
77

88
Gamification-server is designed so that other sites can send in "signals" that are parsed through a rules engine and generate points and badges. Also, other sites and apps can pull in JSON to list badges that a user has.
99

10-
You can add the ``static/gamification-server-request.js`` file to any remote app and use the following code to add badges to your page. You will only need to have this one file and set up a proxy to make requests:
11-
12-
```javascript
13-
<script src="/static/gamification-server-request.js"></script>
14-
<script>
15-
$(document).ready(function() {
16-
gamification.init({
17-
server_url:"http://gamification-server.com/",
18-
project_names:"my_app,overall_game",
19-
user_name: "{{ request.user.username }}",
20-
$badge_container: $('#badge-container')
21-
});
22-
});
23-
</script>
24-
```
10+
### End Points
11+
12+
* GET `/api/player`
13+
Returns an array of all the players
14+
15+
* POST `/api/player/new`
16+
Creates a new player and returns the new player
17+
18+
* GET `/api/player/<PLAYER_ID>`
19+
Returns the player's current stats, badges and achievements
20+
21+
* GET `/api/player/<PLAYER_ID>/badges`
22+
Returns all the badges
23+
24+
* POST `/api/player/<PLAYER_ID>/assign_badge`
25+
Creates a new badge for the player and returns an array of all the players badges.
26+
27+
2528

26-
###Installation
29+
### Installation
2730

28-
* Make sure Node.js, NPM, and Git are installed.
31+
* Make sure Node.js, NPM, MongoDB and Git are installed.
2932

30-
* Download and unpack [the project](https://github.com/devleague/gamification-server) on your Raspberry Pi in the directory of your choice. Or alternatively checkout from source:
33+
* Download and unpack [the project](https://github.com/devleague/gamification-server) on your computer in the directory of your choice. Or alternatively checkout from source:
3134

3235
```bash
3336
$ git clone [email protected]:devleague/gamification-server.git
@@ -48,7 +51,7 @@ $ npm start
4851

4952
* Navigate to [http://localhost:3000](http://localhost:3000) in your browser of choice.
5053

51-
##Contributing
54+
## Contributing
5255

5356
If you'd like to contribute to this project, please make a pull request. We'll review the pull request and discuss the changes. All pull request contributions to this project will be released under the MIT license.
5457

@@ -58,6 +61,6 @@ If you'd like to contribute to this project, please make a pull request. We'll r
5861
4. Push to the branch: ````git push origin my-new-feature````
5962
5. Submit a pull request :D
6063

61-
##Credits
64+
## Credits
6265

6366
- [DevLeague](http://www.devleague.com/)

model/Player.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
3+
require('./index');
4+
const Promise = require('bluebird');
5+
const mongoose = Promise.promisifyAll(require('mongoose'));
6+
mongoose.Promise = require('bluebird');
7+
8+
var playerSchema = mongoose.Schema({
9+
name: String
10+
});
11+
12+
var Player = mongoose.model('Player', playerSchema);
13+
14+
module.exports = Player;

model/index.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const mongoose = require('mongoose');
2+
const isDeveloping = process.env.NODE_ENV !== 'production';
3+
4+
if (isDeveloping) {
5+
mongoose.connect('mongodb://localhost/gamification');
6+
} else {
7+
/*
8+
* Mongoose by default sets the auto_reconnect option to true.
9+
* We recommend setting socket options at both the server and replica set level.
10+
* We recommend a 30 second connection timeout because it allows for
11+
* plenty of time in most operating environments.
12+
*/
13+
const options = {
14+
server: { socketOptions: {
15+
keepAlive: 300000, connectTimeoutMS: 30000,
16+
} },
17+
replset: { socketOptions: {
18+
keepAlive: 300000, connectTimeoutMS: 30000,
19+
} },
20+
};
21+
mongoose.connect(process.env.MONGODB_URI, options);
22+
}
23+
const db = mongoose.connection;
24+
25+
db.on('error', console.error.bind(console, 'connection error:'));
26+
db.once('open', () => {
27+
// We're connected to MongoDB
28+
});
29+
30+
module.exports = db;

node_modules/.bin/mime

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/semver

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/accepts/HISTORY.md

+212
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/accepts/LICENSE

+23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)