cmsd

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2023 License: MIT Imports: 16 Imported by: 0

README

CMSd

Turn files into a headless CMS.

NB: This project is a (working) prototype to see if it can be useful at all.

Overview

CMSd is a tool that turns files into a headless CMS.

It takes a glob pattern, indexes the matching files and exposes them via a readonly REST API.

Quick Start

To index and serve all files from the current directory follow these steps:

  1. Download a release and unpack it into a directory.

  2. cd to the directory.

  3. Run the REST API server:

    $ ./cmsd
    2023/04/28 01:24:43 Indexing files matching '*'
    2023/04/28 01:24:43 Indexed 9 files
    2023/04/28 01:24:43 Running on http://localhost:3000
    2023/04/28 01:24:43 Ctrl+C to quit
    
  4. Go to http://localhost:3000/items to see all
    indexed files.

Documentation

Indexing Files

The following will index all files in the current directory and start a REST API server.

$ cmsd

To index other files just specify a glob pattern as an argument, like this:

$ cmsd '*.md'

Notice the single quotes - we need to pass the argument as is, because (some) shells try to interpret the pattern and you would get different set of files than expected.

To start the REST API server on a different port specify the -p option, like this:

$ cmsd '*.md' -p 4000
REST API
Getting All Files
GET /items

You can filter the returned items using the following query parameters:

  • glob
  • dir
  • file-name
  • file-name-no-ext
  • ext

You can also sort the returned items using the sort query parameter. It recognizes the following values:

  • full-path
  • file-name
  • file-name-no-ext
  • ext

Adding a - before a value will sort the items in descending order.

Getting a File by its ID
GET items/:id

id is always the same - it is computed from full-path.

Getting a File's Content
GET /items/:id/raw

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL