New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@iannisz/node-api-kit

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iannisz/node-api-kit

A simple, handy and intuitive NodeJS API toolkit that lazy programmers will love. Simply install the API Kit with:

  • 0.0.6
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Node API Kit

A simple, handy and intuitive NodeJS API toolkit that lazy programmers will love. Simply install the API Kit with:

npm i @iannisz/node-api-kit

and save yourself a lot of time!

Example

import { createAPI, readJSONBody, createToken } from '@iannisz/node-api-kit'

// Create an API that listens on port 3000.

const api = createAPI(3000)

// Simple public route that sends back "Hello, World!".

api.get('/', (req, res) => {
	res.end('Hello, World!')
})

// JSON APIs made easy.

api.post('/json', async (req, res) => {
	try {
		const body = await readJSONBody(req)
		const { message } = body

		if (message == null) {
			res.statusCode = 400
			res.end(`Missing "message" field in body`)
			return
		}

		res.end(`I received your message "${ message }"!`)
	}
	catch {
		res.statusCode = 400
		res.end(`Bad body`)
	}
}, {
	needAuth: true // User needs to provide a valid API token.
})

// Create a dummy API token that we can use to test our API.

console.log(`Test API token: ${ createToken({ user: 'test' }) }`)

FAQs

Package last updated on 04 Aug 2022

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