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

@vercel/cosmosdb-server

Package Overview
Dependencies
Maintainers
9
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vercel/cosmosdb-server

A Cosmos DB server implementation

  • 0.15.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
264K
decreased by-30.13%
Maintainers
9
Weekly downloads
 
Created
Source

cosmosdb-server

A Cosmos DB server implementation for testing your apps locally.

const { default: cosmosServer } = require("@vercel/cosmosdb-server");
const { CosmosClient } = require("@azure/cosmos");
const https = require("https");

cosmosServer().listen(3000, () => {
  console.log(`Cosmos DB server running at https://localhost:3000`);

  runClient().catch(console.error);
});

async function runClient() {
  const client = new CosmosClient({
    endpoint: `https://localhost:3000`,
    key: "dummy key",
    // disable SSL verification
    // since the server uses self-signed certificate
    agent: https.Agent({ rejectUnauthorized: false })
  });

  // initialize databases since the server is always empty when it boots
  const { database } = await client.databases.createIfNotExists({ id: 'test-db' });
  const { container } = await database.containers.createIfNotExists({ id: 'test-container' });

  // use the client
  // ...
}

To choose between listening for HTTP and HTTPS, import the right function.

const { createHttpServer, createHttpsServer } = require("@vercel/cosmosdb-server"); 

To run the server on cli:

cosmosdb-server -p 3000

or without SSL:

cosmosdb-server -p 3000 --no-ssl

installation

npm install @vercel/cosmosdb-server

It exposes the cosmosdb-server cli command as well.

API

cosmosServer(opts?: https.ServerOptions): https.Server

Create a new instance of cosmos server. You can pass https server options as the argument.

See https.createServer for more information.

Supported operations

  • Database operations.
  • Container operations.
  • Item operations.
  • User-defined function operations.
  • Any SQL queries except the spatial functions ST_ISVALID and ST_ISVALIDDETAILED. Other spatial functions are supported; however, the ST_DISTANCE function uses centroid distances and results may differ from Cosmos DB values.

It may not support newly added features yet. Please report on the Github issue if you find one.

Developing

To build the project, use yarn build.

To run the server from development code, after building, use node lib/cli.js.

FAQs

Package last updated on 23 Sep 2024

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