Giter Site home page Giter Site logo

maverick-yan / tol-node-public Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 12.7 MB

2017: Vanilla ES5+ Experimental API for gamedevs, including PlayFab, MailChimp, SparkPost, Stripe, and Discord integrations

Home Page: https://api.ThroneOfLies.com

License: MIT License

JavaScript 97.16% CSS 0.31% HTML 2.53%

tol-node-public's Introduction

tol-node-public (TNP) - for game developers

IMPORTANT: Use this for SNIPPETS, not to actually clone. This is meant for example-use and sharing chunks of code that may help you do what you want. This repo is no longer maintained as of 7/5/2017 ~ it should still serve of use for years to come :)


PreReqs:

Although it's highly recommended to just pull SNIPPET EXAMPLES from here since it's experimental and an on-going WIP, if you're still daring enough to clone, good luck - here are some basic instructions:

  1. Edit "rename_me_to_secret-keys.json" file in /tol2/data/ and replace placeholder values.
  2. Rename "rename_me_to_secret-keys.json" to "secret-keys.json" and fill in your secret keys (remember the key names)
  3. SSL/TLS (https) is required for out-of-box use: Copy your cert.pem and key.pem files to /tol2/ssl/
  4. Navigate to /tol2/ and type sudo npm install --save to install the req's /tol2/node_modules/ dir)
  5. I use 'npm run dev' for debugging and 'npm run forever' for production.

Scripts:

package.json comes with two "dev" scripts - run via npm run <script_name>:

  1. forever - type sudo npm run forever to run forever+nodemon together to keep your app going and restart on changes, automatically.
  2. kill - type sudo npm run kill to kill forever+nodemon. TODO: Don't kill everything, be selective.
  3. restart - calls npm kill, then npm forever
  4. dev - Debugging mode

PlayFab Example:

/tol2/routes/playfab.js

// https://api.playfab.com/Documentation/Client/method/LoginWithPlayFab
router.post('/loginwithpf', cors(corsOptions), (req, res) => {
    // Init
    PFInitPost(req, '/loginwithpf');

    // Send
    PlayFabClient.LoginWithPlayFab(req.body, (err, data) => {
        PFGenericCallback(res, err, data);
    });
});

Mailchimp Example:

/tol2/routes/mailchimp.js

// REGISTER
router.post('/register', cors(corsOptions), (req, res) => {
    // Init
    MCInitPost(req, '/register');
    var email = req.body["email"];
    var username = req.body["username"];
    var emailMd5 = GetMd5(email);
    var url = `/lists/${i42ListId}/members/${emailMd5}`;

    console.log("MC: PUT >> " + url);
    mailchimp.put(url, {
        "email_address": email,
        "status": "pending",
        "merge_fields": {
            "EMAIL": email,
            "UNAME": username
        }
    }, (err, data) => {
        // Generic callback + res
        mcGenericCallback(err, data, req, res);
    });
});

Other examples

Coming Soon™

Disclaimer:

  • This is a template/wrapper for PlayFab with some experiments of other useful/relevant features.
  • This repo may or may not be updated/monitored by me. If you want authority for pull requests and I've been slack, let me know~

Like what you see?

Support my game and I'll call that a thanks ;D

License

MIT

tol-node-public's People

Contributors

dylanh724 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.