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

@types/json-server

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/json-server

TypeScript definitions for json-server

  • 0.14.7
  • ts4.5
  • ts4.6
  • ts4.7
  • ts4.8
  • ts4.9
  • ts5.0
  • ts5.1
  • ts5.2
  • ts5.3
  • ts5.4
  • ts5.5
  • ts5.6
  • ts5.7
  • ts5.8
  • ts5.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
29K
increased by0.13%
Maintainers
1
Weekly downloads
 
Created
Source

Installation

npm install --save @types/json-server

Summary

This package contains type definitions for json-server (https://github.com/typicode/json-server).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/json-server.

index.d.ts

import { NextHandleFunction } from "connect";
import { Application, RequestHandler, Router } from "express";
import { LowdbSync } from "lowdb";

export interface JsonServerRouter<T> extends Router {
    db: LowdbSync<T>;
}

/**
 * Returns an Express server.
 */
export function create(): Application;

/**
 * Returns middlewares used by JSON Server.
 */
export function defaults(options?: MiddlewaresOptions): RequestHandler[];

/**
 * Returns JSON Server router.
 * @param source Either a path to a json file (e.g. `'db.json'`) or an object in memory.
 * This object will then be wrapped by lowdb, but you can also just pass in your own lowdb
 * instance that will then not be wrapped.
 * @param options Set foreign key suffix (default: `'Id'`)
 */
export function router<T extends object>(
    source: LowdbSync<T> | T | string,
    options?: { foreignKeySuffix: string },
): JsonServerRouter<T>;

/**
 * Add custom rewrite rules.
 */
export function rewriter(rules: { [rule: string]: string }): Router;

/**
 * Returns body-parser middleware used by JSON Server router.
 *
 * @returns
 * ```
 * [bodyParser.json({ limit: '10mb', extended: false }), bodyParser.urlencoded({ extended: false })]
 * ```
 */
export const bodyParser: [NextHandleFunction, NextHandleFunction];

export interface MiddlewaresOptions {
    /**
     * Path to static files
     * @default "public" (if folder exists)
     */
    static?: string | undefined;

    /**
     * Enable logger middleware
     * @default true
     */
    logger?: boolean | undefined;

    /**
     * Enable body-parser middleware
     * @default true
     */
    bodyParser?: boolean | undefined;

    /**
     * Disable compression
     * @default false
     */
    noGzip?: boolean | undefined;

    /**
     * Disable CORS
     * @default false
     */
    noCors?: boolean | undefined;

    /**
     * Accept only GET requests
     * @default false
     */
    readOnly?: boolean | undefined;
}

Additional Details

Credits

These definitions were written by Jeremy Bensimon.

FAQs

Package last updated on 07 Nov 2023

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