GithubHelp home page GithubHelp logo

00mjk / cosmosdb-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vercel/cosmosdb-server

0.0 0.0 0.0 348 KB

A Cosmos DB server implementation for testing your applications locally.

License: MIT License

JavaScript 1.50% Shell 0.91% TypeScript 97.59%

cosmosdb-server's Introduction

cosmosdb-server

A Cosmos DB server implementation for testing your apps locally.

const { default: cosmosServer } = require("@zeit/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 run the server on cli:

cosmosdb-server -p 3000

installation

npm install @zeit/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.

cosmosdb-server's People

Contributors

andremaz avatar asleire avatar dependabot[bot] avatar dsschneidermann avatar javivelasco avatar lonewarrior556 avatar lossyrob avatar mglagola avatar nkzawa avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.