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

@weeb_services/wapi-core

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@weeb_services/wapi-core - npm Package Compare versions

Comparing version 1.4.1-alpha1 to 1.4.1-alpha10

lib/logger.js

16

index.js
'use strict'
// Set up winston
const winston = require('winston')
winston.remove(winston.transports.Console)
winston.add(winston.transports.Console, {
timestamp: true,
colorize: true
})
// Middleware

@@ -15,2 +7,3 @@ module.exports.BaseMiddleware = require('./lib/middleware/base.middleware')

module.exports.PermMiddleware = require('./lib/middleware/perm.middleware')
module.exports.TrackingMiddleware = require('./lib/middleware/tracking.middleware')

@@ -25,1 +18,8 @@ // Routers

module.exports.Utils = require('./lib/utils')
module.exports.Logger = require('./lib/logger')
module.exports.Registrator = require('./lib/registrator')
module.exports.Errors = {
HttpError: require('./lib/structures/errors/HttpError'),
}
module.exports.ShutdownHandler = require('./lib/shutdownHandler')
'use strict'
const winston = require('winston')
const logger = require('../logger')

@@ -43,3 +43,3 @@ const {HTTPCodes, DefaultResponses} = require('../constants')

} catch (e) {
winston.error(e)
logger.error(e)
const response = this.getResponse(HTTPCodes.INTERNAL_SERVER_ERROR)

@@ -46,0 +46,0 @@ res.status(response.status)

@@ -5,3 +5,3 @@ const Middleware = require('./base.middleware')

class Track extends Middleware {
constructor (name, version, environment) {
constructor (name, version, environment, trackingKey) {
super()

@@ -11,2 +11,3 @@ this.name = name

this.environment = environment
this.trackingKey = trackingKey
}

@@ -28,3 +29,3 @@

}
const visitor = ua(req.config.track, uid, {https: true, strictCidFormat: false})
const visitor = ua(this.trackingKey, uid, {https: true, strictCidFormat: false})
const trackingData = {

@@ -31,0 +32,0 @@ uid,

'use strict'
const router = require('express').Router()
const winston = require('winston')
const logger = require('../logger')

@@ -21,3 +21,3 @@ const { HTTPCodes, DefaultResponses } = require('../constants')

} catch (e) {
winston.error(e)
logger.error(e)
this.handleResponse(res, HTTPCodes.INTERNAL_SERVER_ERROR)

@@ -24,0 +24,0 @@ }

'use strict'
module.exports.checkScopes = (wantedScope, scopes) => {
function checkScopes (wantedScope, scopes) {
if (scopes.indexOf('admin' > -1)) {

@@ -12,1 +12,46 @@ return true

}
function checkPermissions (account, wantedPermissions, requireAccount = true) {
if (!account) {
return !requireAccount
}
if (account.perms.all) {
return true
}
for (const perm of wantedPermissions) {
if (account.perms[perm]) {
return true
}
}
return false
}
function buildMissingScopeMessage (name, env, scopes) {
if (!Array.isArray(scopes)) {
scopes = [scopes]
}
scopes = scopes.map(s => buildFullyQualifiedScope(name, env, s))
let message = 'missing scope' + scopes.length > 1 ? 's' : ''
message = message + ' ' + scopes.join(' or ')
return message
}
function buildFullyQualifiedScope (name, env, scope) {
const fqScope = `${name}-${env}`
if (scope !== '') {
return fqScope + ':' + scope
}
return fqScope
}
function isTrue (value) {
if (typeof value === 'string') {
return value === 'true'
} else if (typeof value === 'boolean') {
return value
} else {
return false
}
}
module.exports = {buildFullyQualifiedScope, buildMissingScopeMessage, checkPermissions, checkScopes, isTrue}
{
"name": "@weeb_services/wapi-core",
"version": "1.4.1-alpha1",
"version": "1.4.1-alpha10",
"description": "Weeb API core",

@@ -22,7 +22,9 @@ "main": "index.js",

"dependencies": {
"axios": "^0.17.1",
"express": "^4.15.3",
"@moebius/http-graceful-shutdown": "^1.0.1",
"axios": "^0.18.0",
"express": "^4.16.3",
"shortid": "^2.2.8",
"universal-analytics": "^0.4.16",
"url-pattern": "^1.0.3",
"winston": "^2.3.1"
"winston": "^3.0.0-rc2"
},

@@ -33,7 +35,7 @@ "engines": {

"devDependencies": {
"eslint": "^4.17.0",
"eslint-config-standard": "^11.0.0-beta.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-node": "^6.0.0",
"eslint-plugin-promise": "^3.6.0",
"eslint": "^4.18.2",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.9.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.7.0",
"eslint-plugin-standard": "^3.0.1"

@@ -40,0 +42,0 @@ },

@@ -1,8 +0,3 @@

// Set up winston
const winston = require('winston')
winston.remove(winston.transports.Console)
winston.add(winston.transports.Console, {
timestamp: true,
colorize: true,
})
// Set up logger
const logger = require('./index').Logger

@@ -18,5 +13,5 @@ try {

}
winston.info('Tests loaded.')
logger.info('Tests loaded.')
winston.info(`Testing wapi-core@${pkg.version}`)
logger.info(`Testing wapi-core@${pkg.version}`)

@@ -29,3 +24,3 @@ let successful = 0

const test = new tests[i]()
winston.info(`Running test for ${test.name}`)
logger.info(`Running test for ${test.name}`)
try {

@@ -36,3 +31,3 @@ await test.run()

failed++
return winston.error(`Test failed: ${e}`)
return logger.error(`Test failed: ${e}`)
}

@@ -44,9 +39,9 @@ }

.then(() => {
winston.info(`Done. Completed ${successful} test(s) successfully, failed ${failed} test(s).`)
logger.info(`Done. Completed ${successful} test(s) successfully, failed ${failed} test(s).`)
})
.catch(e => {
winston.error(`Failed to run tests: ${e}`)
logger.error(`Failed to run tests: ${e}`)
})
} catch (e) {
winston.error(`Failed to run tests: ${e}`)
logger.error(`Failed to run tests: ${e}`)
}

Sorry, the diff of this file is not supported yet

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