Nanotechnology Promises Much
    Wondering what’s next for npm?Check out our public roadmap! »

    TypeScript icon, indicating that this package has built-in type declarations

    1.1.6 • Public • Published


    License pipeline status coverage report

    The first version of C-Service: a distributed database service for CRDTs of the C-CRDTlib.

    The C-Service is meant to run on edge devices (terminal or PoP) and (will) support transactions and replication between services. It (will) run as a ServiceWorker in web browsers or as a standalone application.

    The C-Service exposes a REST API which should not be accessed directly, as it may not be stable; use the C-Client library instead.

    Getting started


    For the next steps, you will need the following software:

    • Make sure you have the latest stable version of Node.js;
    • C-Service runs on top of CouchDB.

    In addition, you will need to enable CORS in CouchDB. You can use the dedicated NPM package from PouchDB:

    npx add-cors-to-couchdb [] \
        [-u myusername] [-p mypassword]
    (server defaults to localhost)

    or the CouchDB user panel.

    Start C-Service

    Ensure CouchDB is running before starting C-Service. If it is running on another host, set the COUCHDB_URL accordingly. You will also need to provide CouchDB credentials:

    export COUCHDB_USER=my-user COUCHDB_PASSWORD=my-passwd

    Then run the service:

    npx @concordant/c-service

    This launches an Express server listening on TCP port 4000.

    Setup C-Service as a Systemd service

    First ensure CouchDB is setup as a systemd service named couchdb.service (or adapt the name in c-service.service file).

    Put the c-service folder in /opt/ or adapt the c-service.service file.

    Put the provided file c-service.service in /etc/systemd/system/.

    Create the file /etc/systemd/system/c-service.conf containing CouchDB admin credentials:


    Then start the service:

    systemctl start c-service

    Test C-Service using curl

    The C-Service exposes a REST API on /api, whose description can be found in file swagger.yml.

    Once your C-Service is running you can query its REST API with curl. You can view your changes in the CouchDB user pannel.

    Create the myapp database:

    curl --request POST                               \
         --header "Content-Type: application/json"    \
         --data '{"appName":"myapp"}'                 \

    Insert/update a PNCounter named myobject in myapp database:

    curl --request POST                               \
         --header "Content-Type: application/json"    \
         --data '{"appName":"myapp","id":"{\"name\":\"myobject\",\"type\":\"PNCounter\"}","document":"{\"type\":\"PNCounter\",\"metadata\":{\"increment\":[{\"name\":\"clientid\"},{\"first\":60,\"second\":{\"uid\":{\"name\":\"clientid\"},\"cnt\":-21474836}}],\"decrement\":[]},\"value\":60}"}'  \

    Get the PNCounter named myobject in myapp database:

    curl --request POST                               \
         --header "Content-Type: application/json"    \
         --data '{"appName":"myapp","id":"{\"name\":\"myobject\",\"type\":\"PNCounter\"}"}'                       \

    Get all objects of myapp database:

    curl --request POST                               \
         --header "Content-Type: application/json"    \
         --data '{"appName":"myapp"}'                 \

    Delete myapp database:

    curl --request POST                               \
         --header "Content-Type: application/json"    \
         --data '{"appName":"myapp"}'                 \


    npm i @concordant/c-service

    DownloadsWeekly Downloads






    Unpacked Size

    47.4 kB

    Total Files


    Last publish


    • avatar