Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

darkflare

Package Overview
Dependencies
Maintainers
2
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

darkflare

The API Engine

Source
npmnpm
Version
4.3.0
Version published
Weekly downloads
1
Maintainers
2
Weekly downloads
 
Created
Source

darkflare v4

Setup

# Get the latest release.
npm i darkflare

# Get on the bleeding edge with the latest unstable release.
npm i darkflare@canary

Configuration

Create a new file named darkflare.json in the root directory of your project.

{
  "$schema": "https://darkflare.run/schema.json"
  // use auto-complete
}
  • name - the name for your app (used for caching)
  • base - the base for your app, e.g. /api
  • cors - the allowed origin for incoming requests
  • cache - cache responses for a given amount of seconds
  • passThroughOnException - pass request to origin on exception

Usage

Routes

Create a new file in your /src/routes directory and name it whatever you want the endpoint to be. If you want a dynamic route, add a [ to the beginning and a ] to the end of the name to access it in ctx.req.parameters

e.g. /src/routes/index.ts 👉 / or /src/routes/example.ts 👉 /example or /src/routes/[key]/whatever.ts 👉 /:key/whatever

import { useRoute, Type } from 'darkflare'

const Get = useRoute({
  schema: {
    body: Type.String()
  }
}, async ctx => {
  console.log(ctx.req.body) // string
  
  return 'Hello World'
})

export { Get }

Linting

darkflare lint

# Fix occuring issues:
darkflare lint --fix

Building

darkflare build

FAQs

Package last updated on 23 Oct 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