Skip to content
A Cosmos DB server implementation for testing your applications locally.
Branch: master
Clone or download
Latest commit b666393 Jul 17, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github fix github action Jul 2, 2019
src bump cosmosdb-query Jul 2, 2019
test bump cosmosdb-query Jul 2, 2019
.editorconfig convert to typescript Jun 26, 2019
.gitignore convert to typescript Jun 26, 2019
.gitmodules use https for submodule Jun 26, 2019
README.md improve readme Jul 4, 2019
cert.pem initial commit Aug 20, 2018
key.pem initial commit Aug 20, 2018
package.json bump dependencies Jul 17, 2019
tsconfig.json bump cosmosdb-query Jul 2, 2019
yarn.lock bump dependencies Jul 17, 2019

README.md

cosmosdb-server

A Cosmos DB server implementation for testing your apps locally.

const { default: cosmosServer } = require('@zeit/cosmosdb-server');
const { CosmosClient } = require('@azure/cosmos');

// disable SSL verification
// since the server uses self-signed certificate
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

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`,
    auth: {
      masterKey: "test key" // dummy key
    }
  });

  // 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 run the server on cli:

cosmosdb-server -p 3000

installation

npm install @zeit/cosmosdb-server

It exposes the cosmosdb-server cli command as well.

Supported operations

  • Database operations.
  • Container operations.
  • Item operations.
  • User-defined function operations.
  • Any SQL queries except spatial functions
You can’t perform that action at this time.