Coder Social home page Coder Social logo

quicksilver-node's Introduction

quicksilver-node's People

Contributors

deezone avatar sergiitk avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

quicksilver-node's Issues

Test coverage

Add test coverage using supertests and Mocha for each of the endpoints:

  • router.get('/'
  • router.get('/v1'
  • router.post('/v1/imports'
  • router.post('/v1/imports/summaries'
  • router.route('/v1/user/activity')
    • .post
    • .get

Test Coverage: /api/v1/user/activity

Adjustments to application to update endpoint logic based on test development.

  • /api/v1/user/activity:
    • it('GET: Lookup of missing user activity log entries returns 404 response code.'
    • it('POST: User activity log entry returns 200 response code and OK message.'
    • it('GET: Lookup of user activity log entry returns 200 response code. Returned data is formatted as expected.'
    • it('DELETE: Test user activity log entry returns 200 response code.'
    • it('GET: Lookup of deleted user activity log entry returns 404 response code.'

Support Config in Environment Variables

  • Add support for missing mb_config.json file, fall back to default settings.
  • Add support for environment variables as source of configuration settings
  • if missing, create logging directory

Reference - must read and re-read

Example of using environment vars:

log.Println("Overriding configuration from env vars.")
if os.Getenv("APP_DATADIR") != "" {
    config.DataDir = os.Getenv("APP_DATADIR")
}
if os.Getenv("APP_HOST") != "" {
    config.Host = os.Getenv("APP_HOST")
}
if os.Getenv("APP_PORT") != "" {
    config.Port = os.Getenv("APP_PORT")
}
if os.Getenv("APP_USERNAME") != "" {
    config.Username = os.Getenv("APP_USERNAME")
}
if os.Getenv("APP_PASSWORD") != "" {
    config.Password = os.Getenv("APP_PASSWORD")
}
if os.Getenv("APP_DATABASE") != "" {
    config.Database = os.Getenv("APP_DATABASE")
}

Works with Docker

$ docker run --rm \
  -e "APP_DATADIR=/var/lib/data" \
  -e "APP_HOST=203.0.113.10" \
  -e "APP_PORT=3306" \
  -e "APP_USERNAME=user" \
  -e "APP_PASSWORD=password" \
  -e "APP_DATABASE=test" \
  app:v2

AfterSchool

A logging support for user imports from After School.

User Transactional Activites

  • Add route to support POSTs of transactional requests: router.route('/v1/user/transactional').
  • Add collection to support logging user transactional requests:
    • `var userTransactionalsCollectionName = 'user-transactional';
    • schema:
    var userTransactionalLoggingSchema = new mongoose.Schema({
      logged_date : { type: Date, default: Date.now },
      email : { type : String, trim : true },
      source : {
        type : String,
        trim : true,
        enum: ['US', 'CA', 'UK', 'ID', 'BR', 'MX']
      },
      activity : {
        type : String,
        lowercase : 1,
        trim : true,
        enum: ['user_register', 'user_password', 'campaign_signup', 'campaign_reportback']
      },
      activity_date : { type: Date, default: Date.now },
      activity_details : { type : String }
    });
    userTransactionalLoggingSchema.set('autoIndex', false);

    models.userTransactionalModel = mongoose.model(userTransactionalCollectionName, userTransactionalLoggingSchema);
  • Module: user-transactional
    • UserTransactional.prototype.post = function(req, res) {

Test Coverage: /api/v1/import/summaries

Adjustments to application to update endpoint logic based on test development.

  • /api/v1/imports/summaries:
    • it('GET: Lookup of missing import summary log entries returns 404 response code.'
    • it('POST: Import log summary entry returns 200 response code and OK message.'
    • it('GET: Lookup of summary import log entry returns 200 response code. Returned data is formatted as expected.'
    • it('DELETE: Test summary log entry returns 200 response code.'
    • it('GET: Lookup of deleted import summary log entry returns 404 response code.'

Monitor forever Process

Add automated monitoring to ensure http://subscriptions.dosomething.org is functional. The application lives at 10-100-25-44/usr/bin/nodejs mbc-user-subscriptions-server.js which runs as a daemon:

$ PORT=4711 forever start mbc-user-subscriptions-server.js

Create/Add Campaigns Key

When campaign data is cached create/add an index key with a list of all campaigns cached.

  • When campaign is added through POST /campaign create / add to the index key of all the campaign cached values: [nid]-[language]-[expiry timestamp].

    Storing Sets: Sets are similar to lists, but the difference is that they don’t allow duplicates.

    The first item of the array represents the name of the key while the rest represent the
    elements of the list.

client.sadd(['tags', 'angularjs', 'backbonejs', 'emberjs'], function(err, reply) {
    console.log(reply); // 3
});

Reference:

Related:

Test Coverage: / GET /v1/imports

  • Add coverage to ensure origin_start and origin_end are returning expected results.
  • Confirm logged_date is the current date, not the default 1970-something date

Get Campaigns Key

Create an endpoint to GET a list of all the campaign nid-languages being stored.

  • GET /campaign/index

    To retrieve the members of the set, use the smembers() function as following:

client.smembers('tags', function(err, reply) {
    console.log(reply);
});

Reference:

Related:

mb-logging-api Test Coverage

Complete test coverage:

  • /api/v1/imports:
    • it('POST: Import log entry returns 200 response code and OK message.'
    • it('GET: Lookup import log entry returns 200 response code and expected content.'
    • it('DELETE: Import log entry returns 200 response code and expected OK response.'
    • it('GET: Lookup of missing import log entry returns 404 response code.'
    • it('GET: Lookup of import log entry returns 200 response code. Returned data is formatted as expected.'
    • it('DELETE: Test import log entry returns 200 response code.'
    • it('GET: Lookup of deleted import log entry returns 404 response code.'
  • /api/v1/imports/summaries:
    • it('GET: Lookup of missing import summary log entries returns 404 response code.'
    • it('GET: Lookup of summary import log entry returns 200 response code. Returned data is formatted as expected.'
    • it('DELETE: Test summary log entry returns 200 response code.'
    • it('GET: Lookup of deleted import summary log entry returns 404 response code.'

See commented out stubs in test.js.

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.