{"id":14967723,"url":"https://github.com/workshape/mandi","last_synced_at":"2025-10-25T21:31:59.816Z","repository":{"id":91119968,"uuid":"80558269","full_name":"Workshape/mandi","owner":"Workshape","description":"Plug and play, JSON configurable Node.js CMS","archived":false,"fork":false,"pushed_at":"2018-05-27T12:51:10.000Z","size":531,"stargazers_count":32,"open_issues_count":0,"forks_count":8,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-01-31T10:51:12.021Z","etag":null,"topics":["cms","cms-api","cms-framework","cms-server","cmsui","es6","jade","javascript","js","json-schema","node","nodejs","pug","stylus","vue","vue2","vuejs","vuejs2"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Workshape.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2017-01-31T20:18:24.000Z","updated_at":"2024-07-18T07:28:13.000Z","dependencies_parsed_at":"2023-04-13T17:35:36.465Z","dependency_job_id":null,"html_url":"https://github.com/Workshape/mandi","commit_stats":{"total_commits":104,"total_committers":2,"mean_commits":52.0,"dds":0.009615384615384581,"last_synced_commit":"2726c8a53bc5ec6e9e505b71bc92b47cf4c82733"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Workshape%2Fmandi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Workshape%2Fmandi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Workshape%2Fmandi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Workshape%2Fmandi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Workshape","download_url":"https://codeload.github.com/Workshape/mandi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238212425,"owners_count":19434955,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cms","cms-api","cms-framework","cms-server","cmsui","es6","jade","javascript","js","json-schema","node","nodejs","pug","stylus","vue","vue2","vuejs","vuejs2"],"created_at":"2024-09-24T13:38:31.041Z","updated_at":"2025-10-25T21:31:54.494Z","avatar_url":"https://github.com/Workshape.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mandi CMS\n\n![Mandi dashboard screenshot](http://i.imgur.com/n9JSl2A.png)\n\nA lightweight, configurable CMS build using [Koa](http://koajs.com/), [MongoDB](https://www.mongodb.com/), [Pug](https://pugjs.org/), [Vue.js](https://vuejs.org/) and [Stylus](http://stylus-lang.com/).\n\nSetting up and configuring this application will provide you with a simple interface to manage (create, edit, delete, ..) data entries based on a custom JSON schema.\n\nMandi can be cloned or be installed as an npm module and integrated with a pre-existing node application or HttpServer.\n\nRequirements\n---\n\n- Node.js (v7.0.0+)\n- MongoDB (v3.2.0+)\n\nQuick usage\n---\n\nInstall mandi using npm:\n\n```bash\nnpm install --save mandi\n```\n\n#### Attach to a http server\n\nCreate a Mandi instance and integrate it onto a pre-existing http node server:\n\n```javascript\nconst Mandi = require('../lib/Mandi')\nconst http = require('http')\n\n// Create a simple configuration\nlet config = {\n  mongo     : { url: 'mongodb://localhost/mandi-cms' },\n  basePath  : '/admin',\n  publicUrl : 'http://localhost:8000/admin'\n}\nlet schema = {\n  title: 'My simple blog',\n  types: {\n    posts: {\n      label: 'Post',\n      schema: {\n        cover: { extends: 'image', label: 'Cover' },\n        name: { extends: 'name' },\n        content: { extends : 'content' }\n      }\n    }\n  },\n  statics: {\n    title: { extends: 'title', label   : 'Website title' },\n    description: { extend: 'content', label: 'Website description' }\n  }\n}\n\n// Instanciate Mandi\nlet mandi = new Mandi(config, schema)\n\n// Instanciate a HTTPServer using Mandi's middleware function\nlet server = http.createServer(mandi.middleware())\n\n// Start server on port 8000\nserver.listen(8000)\n\n// The Mandi interface should now be available at localhost:8000/admin\nmandi.util.log.info('Running Mandi on', 'http://localhost:8000/admin')\n```\n\n#### Run Mandi app on its own\n\nCreate a Mandi instance initialise it on its own\n\n```javascript\nconst Mandi = require('../lib/Mandi')\nconst http = require('http')\n\n// Create a simple configuration\nlet config = {\n  port : 8000\n  // ...\n}\nlet schema = {\n  // ...\n}\n\n// Instanciate Mandi\nlet mandi = new Mandi(config, schema)\n\n// Instanciate a HTTPServer using Mandi's middleware function\nmandi.listen()\n```\n\n#### Run without npm (clone the repo and run standalone)\n\nTo setup this codebase on your development environment please follow these steps:\n\n```bash\ngit clone https://www.github.com/workshape/mandi\ncd mandi\nnpm install\nnpm run build\n```\n\nBefore running the app, you still have to\n\n* Confgure the app (Basic configuration)\n* Write the CMS JSON schema in `./schema.json` (use `./schema.default.json` as reference)\n\nThen, you just need to run the server:\n\n```bash\nnpm start\n```\n\nMandi class\n---\n\n#### Arguments\n\n* `config` (Object) - an object containing server / db configuration (see 'Basic configuration')\n* `schema` (Object) - an object containing the data structure of the CMS (See JSON schema configuration)\n\n#### Methods\n\n* `.listen( port : String )` Listen on given port - if port is not passed, will default to port specified the config Object passed to the constructor\n* `.middleware()` Gets callback Function to be attached to a HTTP server (see `callback()` method on [Koa documentation](https://github.com/koajs/koa/blob/master/docs/api/index.md#appcallback))\n* `.on( eventName : String, callback : Function )` Bind a callback to a specified event\n\n#### Events \n\nMandi is an [EventEmitter](https://nodejs.org/api/events.html)\n\n* event: `log` - args: [ `message : String` ] Mandi emits events for each of its logs - the app can also be muted using the `quiet` configuration option, so that it's possible to manage logs in a custom way\n\nBasic configuration\n---\n\nThe configuration defaults to the one in `config/default.json` but it passed to the `Mandi` constructor\n\n#### Configuration options:\n\n* `publicUrl` (Env. `PUBLIC_URL`) The base URL the CMS will be served at (without trailing slash)\n* `basePath` The base path the CMS will be served at (useful if mounting an instance of Mandi on a pre-existing HttpServer)\n* `secret` (Env. `SECRET`) A secret used to hash passwords\n* `port` (Env. `PORT`) The port the website is gonna be served at by Node.js\n* `mongo.url` (Env `MONGO_URL`) The URL of the mongo database (by default `mongodb://localhost/mandi\n* `aws.key` (Env. `AWS_KEY`) Your Amazon Web Services key (optional - AWS configuration is used for S3 file uploads, but will fall back on local file system if not setup)\n* `aws.secret` (Env. `AWS_SECRET`) Your Amazon Web Services secret\n* `aws.bucket` (Env. `AWS_S3_BUCKET`) Your Amazon Web Services S3 Bucket name\n* `aws.region` (Env. `AWS_REGION`) Your Amazon Web Services S3 Bucket region (defaults to `us-standard`)\n* `uploadsDir` (Env. `UPLOADS_DIR`) Absoute path used to customise the uploads directory\n* `quiet` (Env. `QUIET`) Mute all the logs (they can still be detected binding listening to events with `.on('log', msg =\u003e { /* ... */ })`)\n\nJSON schema configuration\n---\n\nAll data types that will be managable through the CMS are defined in a simple JSON schema that can be created by the user.\n\nThis schema needs to be created under the `website.json` filename in the root directory - and it will extend the default configuration file `website.default.json`\n\nThe default file contains an example of a basic `posts` type that can be used - for example - creating a blogging system\n\nYou can use this file as a refence for your `website.json` file\n\n### Website.json properties:\n\nYou can override the following properties in the Object exported by `website.json`:\n\n* `title` **String** - *The admin website's title as it will be displayed in the interface*\n* `types` **Object** - *The value under each key of this Object contains the JSON schema assigned to the DB collection named with its key*\n\nDefining types\n---\n\nTypes are basically validation schemas that will determine the UI the CMS generates to administer the various of data entries that will be managed through the CMS\n\nHere's the type you can find in the default CMS configuration `website.default.json`:\n\n```json\n{\n  \"types\": {\n\n    \"posts\": {\n      \"label\": \"Post\",\n      \"schema\": {\n\n        \"cover\": {\n          \"extends\" : \"image\",\n          \"label\"   : \"Cover\"\n        },\n\n        \"name\": {\n          \"extends\" : \"name\"\n        },\n\n        \"excerpt\": {\n          \"extends\" : \"content\",\n          \"label\"   : \"Excerpt\",\n          \"tip\"     : \"Plane text - short and descriptive\"\n        },\n\n        \"content\": {\n          \"extends\" : \"html\",\n          \"label\"   : \"HTML content\"\n        }\n\n      }\n    },\n\n  },\n  \"statics\": {\n\n      \"title\": {\n        \"extends\" : \"title\",\n        \"label\"   : \"Website title\"\n      },\n\n      \"description\": {\n        \"extends\" : \"content\",\n        \"label\"   : \"Website description\"\n      }\n\n  }\n}\n```\n\nEach type contains the following properties:\n\n* `label` The display name for an individual entry of this type\n* `schema` An Object containing the validation schema for given type\n\nEach field in the schema should extend from a basic `validator-preset` - you can set the `extends` property to do so, and every other field is gonna extend the schema it refers to\n\nTo learn more about the properties you can override you can look at how the base type presets are defined in `common/util/validator-presets.js`\n\nTypes presets\n---\n\nWhen defining the CMS types, you can chose to extend from the following presets (defined in `common/util/validator-presets.js`\n\n* `email` A required 4-100 characters long valid email String\n* `url` A required valid url String\n* `password` A required 6-100 characters long valid String\n* `name` A required 1-100 characters long valid String\n* `title` A required 1-150 characters long valid String\n* `content` A 0-1500 characters long valid String\n* `file` Any file\n* `image` A file of mime type matching one of `image/jpeg`, `image/png` or `image/gif`\n\nRunning the CMS interface\n---\n\nNow that you configured the app and the JSON schema, you need to start the CMS - run\n\n`npm start`\n\nThe interface should now be running on [localhost:4000](http://localhost:4000)\n\nBy default, a overlord user will be created with the following credentials:\n\n**Username**: `admin`\u003cbr\u003e\n**Password**: `foobar`\n\nWhen logged in you will be able to change your password\n\nDevelopment\n---\n\nThe following npm tasks are available to support development workflow:\n\n* `npm run watch-server` Watch for changes on the server-side codebase and restart server when necessary\n* `npm run watch` Watch for changes in the client-side codebase and rebuild what's been changed\n* `npm run build` Re-build the codebase\n* `npm run dev` Run `watch-server` and `watch` together\n\nLicence\n---\n\nCopyright (c) 2017 WorkShape.io Ltd. - Released under the [MIT license](https://github.com/tancredi/mandi/blob/master/LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworkshape%2Fmandi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fworkshape%2Fmandi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworkshape%2Fmandi/lists"}