🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

github.com/mirovarga/cmsd

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/mirovarga/cmsd

v0.0.0-20230427233914-da6e2dd5f5c6
Source
Go
Version published
Created
Source

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:

  • Download a release and unpack it into a directory.

  • cd to the directory.

  • 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
    
  • 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

FAQs

Package last updated on 27 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts