Nostalgic Primordial Monster
    Have ideas to improve npm?Join in the discussion! »

    apiwee

    0.1.11 • Public • Published

    A fast and lightweight solution for quickly adding api keys to an Express application

    Installation

    $ npm install apiwee

    the code to put it in

    var express = require('express');
    var app = express();
    var apiweeConfig = {
        username: 'username', // required
        password: 'password', // required
        publicPaths: ['GET:/', 'GET:/health'], // optional
        file: __dirname + '/../myNewFileLocation' // optional, otherwise stored in node_modules/apiwee
    }
    var apiwee = require('apiwee')(express, app,apiweeConfig);
     
    app.use(apiwee);
     
    app.listen(3000);

    how it works

    Apiwee is added to the Express middleware functionality, where it validates from a local file (slower than memory but can be updated dynamically).

    then navigate to {yourDomain}:{yourPort}/apiwee/admin and login with the credentials provided in the instantiation this will take you to the configurations page where you can define the keys and the routes. You can delete keys, add new ones, edit the key field, drag routes to the api key, and disable keys.

    once your api keys are defined use them by using the header field x-api-key

    username and password are shown hard-coded in the config but use your best judgement on how to pass them into the instantiation.

    handling multiple instances

    aws asg group

    ensure that each aws instance has permissions for running the aws cli command describe-instances it also requires you to use the tags Environment and Name for the groups

    below are the required fields for setting up the api keys on all instances in your aws asg group

    var apiweeConfig = {
        username: 'username',
        password: 'password',
        awsRegion: 'us-east-1',
        awsEnvironment: 'development',
        awsInstanceName: 'myApp',
        protocol: 'http/https',
        port: 3000
    }
    var apiwee = require('apiwee')(express,app,apiweeConfig);

    hard-coded ips

    below is the required config for scaling your api keys across instances using their addresses Include all ips, including the address it is running on

    var apiweeConfig = {
        username: 'username',
        password: 'password',
        ips: ['1.1.1.1', '1.1.1.2', '1.1.1.3'],
        protocol: 'http/https',
        port: 3000
    }
    var apiwee = require('apiwee')(express,app,apiweeConfig);

    screenshots

    login configure

    Install

    npm i apiwee

    DownloadsWeekly Downloads

    4

    Version

    0.1.11

    License

    MIT

    Last publish

    Collaborators

    • avatar