0.2.9 • Published 4 years ago

net-util-base v0.2.9

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

Description

Utility modules for different functions.

Code Block (block)

try catch code block so I don't have to put the same try catch all over the code.

Mongo DB connect (dbConnection)

connect to mongo db using environment variable process.env.DB_CONN

hits

This middle middle ware will look at each request that goes through the router looking for a match on from the "route" configuration. When an "req.originalUrl" path matches the "route" parameter, the domain and area are used to create a record in mongo db.

var hits = require("net-util-base").hits;
var hitList = [ { route: "/", domain: "readbible.us", area: "entry" } ];
appRouter.use(hits.create(hitList), express.static(__dirname + '/public_compiled'));

auth on google oAuth 2.0

Environment Variables

GOOGLE_CLIENT_ID=1234567890.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=secretfromgoogle
GOOGLE_REDIRECT=http://localhost/login/google/return

Code Sample

const appRouter = express();

const authRoute = require('./server/authRoute');

authRoute.initPassport(appRouter,
appPermissions.permissionCheck);

function permissionCheck(accessToken, refreshToken, profile, cb) {

let accessList = ['1123456789901234567890', '12345678901234567890'];

//put logic here for user access

const userHasAccess = accessList.indexOf(profile.id) > -1;

if (userHasAccess)

    return cb(null, profile);

else

    return cb(null, false, {message: 'User does not have access to this application'});

}
0.2.9

4 years ago

0.2.0

6 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago