Socket
Book a DemoInstallSign in
Socket

denim-api-auth-middleware

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

denim-api-auth-middleware

Express API Key Auth Middleware

1.0.9
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

denim-api-auth-middleware

Api Key authorization middleware for Express

Getting Started

yarn add denim-api-auth-middleware

Prerequisites

Tested with Express 4

Installing

install package

yarn add denim-api-auth-middleware

  • OR - npm install denim-api-auth-middleware

most basic setup

import Express from 'express'
import makeApiKeyAuthMiddlware from 'denim-api-auth-middleware'
import http from 'http'

const app = new Express()

//Note: production keys should be randomly generated. See https://github.com/substack/node-hat
const API_KEYS = { 
    mySecretKey: 'mySecretPassword'
}
const apiKeyAuthMiddlware = makeApiKeyAuthMiddleware(API_KEYS) //initialize
app.use(apiKeyAuthMiddlware) // API Key auth middleware

app.get('/',(req, res)=>{
	res.send('Great Success')
})

const server = http.createServer(app)
server.listen(8080, () =>
  console.log('HTTP Server Listening on Port',8080)
)
# curl localhost:8080

Forbidden

# curl localhost:8080 \  
  --header "Authorization: mySecretKey:mySecretPassword"
  
Great Success

Running the tests

run tests once: yarn test

watch tests: yarn test --watch

Deployment

yarn publish

Built With

  • node - Node 9.2.0
  • prettier-standard - Used for code style
  • babel-cli - Used for transpiling and running es6
  • babel-preset-env - Used for transpiling and running es6
  • jest - Testing framework
  • chai - Assertion Library
  • husky - Pre-commit hooks
  • lint-staged - Linting for changed files

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Keywords

express

FAQs

Package last updated on 24 Dec 2017

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.