Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pg-challenges

Package Overview
Dependencies
Maintainers
1
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-challenges

Reusable challenges-system build with Postgres and Hapi.

  • 2.0.6
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Challenges

Build Status codecov

Pre-requisites:

  • Create a challenges_test and challenges database:

    CREATE DATABASE challenges;
    CREATE DATABASE challenges_test
    
  • Initialise tables and populate your database by running

    npm run db
    
  • creates a 'Challenges' table

A plugin which exposes the following functions on the request.server.methods.pg.challengs object:

add(challengeObject, cb)

function to add challenge to pre-existing challenge table challengeObject:

{
  title: 'Tea',
  description: 'With milk',
  org_id: 1,
  creator_id: 1,
  active: true
}

Returns [] if challenge was successfully added, and an error if not.

getById(id, cb)

function to get a specific challenge, and associated tags, id: Integer

returns:

{
  id: 2,
  title: 'Challenge Number 2',
  description: 'How can I...?',
  org_id: 1,
  creator_id: 3,
  tags: [ { id: 2, name: 'Corporate' } ]
}

or an empty object {} if no challenge was found.

getByTag(id, cb)

function to get all challenges that contain a certain tag id: Integer if we want to filter by a tag id or false if we do not want to filter

If a tag id is given, returns:

{ filter_tag: 'Design for disassembly',
  challenges:
   [ { id: 4,
       date: '2016-12-07 15:36:24.636112+00',
       title: 'Challenge Number 4',
       description: 'Who should I...?',
       org_id: 2,
       shared_by: 'dwyl',
       tags:
        [
          { tag_id: 9, tag_name: 'Automotive and Transport Manufacturing' },
          { tag_id: 11, tag_name: 'Chemicals' },
          { tag_id: 60, tag_name: 'Secondary education' }
        ]
      },
     { id: 7,
       date: '2016-12-07 15:36:24.636112+00',
       title: 'Challenge Number 7',
       description: 'Is it possible to...?',
       org_id: 4,
       shared_by: 'EMF',
       tags: [{}, {}, ... ]
     },
      ...
    ]
}

If false is given, returns the same shape, but with

filter_tag: undefined

FAQs

Package last updated on 07 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc