Skip to content

A simple server to take JSON-LD that has been created from CSVW and serve it in various useful formats

License

Notifications You must be signed in to change notification settings

theodi/csvw-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSVW Server

CSVW Server is an express-based server that provides an interface to interact with data following the CSV on the Web (CSVW) format. It is designed to support various content negotiation options to deliver data in the most suitable format for the consumer.

Table of Contents

  1. Features
  2. Installation
  3. Usage
  4. API Endpoints
  5. Content Negotiation
  6. Configuration
  7. Contributing
  8. License
  9. Contact

Features

  • Content Negotiation: Delivers data in various formats such as JSON-LD, CSV, JSON, and HTML based on the Accept header or query parameters.
  • Language Negotiation: Supports multiple languages for labels and descriptions based on the Accept-Language header.
  • Custom Rendering: Utilizes EJS templates for custom HTML rendering of data.
  • Configurable: Easily configurable via environment variables.

Installation

To install CSVW Server, you need to have Node.js and npm installed on your system. If they are not installed, you can download and install them from the official Node.js website.

Once Node.js and npm are installed, you can install the CSVW Server using the following commands:

git clone https://github.com/theodi/csvw-server.git
cd csvw-server
npm install

Configuration

You can configure the server using a .env file. Here is an example configuration:

PORT=3000
HOST=localhost
BASE=http://example.com/
DATADIR=data/example4/
SECRET=MYSECRET

The BASE configuration variable specifies the root URL of your server. It also acts as the base prefix for your JSON-LD/CSVW data. This should be set to the domain you intend to serve data from, ensuring consistency between the server's domain and the identifiers used in your data.

DATADIR is the default directory from which to load the jsonld from and should contain a file called data.jsonsld

SECRET is the session secret for nodejs. Sessions hold the data the user is currently browsing and allows a single URI to have multiple versions of the same data.

Usage

To start the server, run:

npm start

By default, the server will run on port 3000. You can access it by visiting http://localhost:3000 in your browser.

API Endpoints

  • GET /transactions/: Fetches a list of all transactions.
  • GET /transactions/:id: Fetches a specific transaction by ID.

Content Negotiation

CSVW Server supports content negotiation to provide responses in various formats. You can request a specific format using the Accept header in your HTTP request.

Supported formats:

  • application/ld+json: JSON-LD format.
  • text/csv: CSV format.
  • application/json: JSON format.
  • text/html: HTML format.

Contributing

Contributions to the CSVW Server project are welcome. Please check out our GitHub repository for more information on how to get involved.

License

CSVW Server is licensed under the MIT License. See the LICENSE.md file for more details.

Contact

For any questions or concerns, please open an issue on our GitHub repository, and we will get back to you as soon as possible.


Created and maintained by The Open Data Institute.

About

A simple server to take JSON-LD that has been created from CSVW and serve it in various useful formats

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published