{"id":17470807,"url":"https://github.com/chuck-durst/germaine","last_synced_at":"2025-04-21T15:41:50.977Z","repository":{"id":57250012,"uuid":"147010097","full_name":"chuck-durst/germaine","owner":"chuck-durst","description":"Germaine is an ExpressJs middleware that allows you to quickly deploy an API that listens on a given endpoint and serves content from a JSON file. ","archived":false,"fork":false,"pushed_at":"2019-01-03T18:22:13.000Z","size":78,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-07T21:45:05.493Z","etag":null,"topics":["api","expressjs","json","jsonapi","nodejs","rest"],"latest_commit_sha":null,"homepage":null,"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/chuck-durst.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}},"created_at":"2018-09-01T15:28:27.000Z","updated_at":"2021-12-25T21:22:48.000Z","dependencies_parsed_at":"2022-08-24T16:51:51.805Z","dependency_job_id":null,"html_url":"https://github.com/chuck-durst/germaine","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chuck-durst%2Fgermaine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chuck-durst%2Fgermaine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chuck-durst%2Fgermaine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chuck-durst%2Fgermaine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chuck-durst","download_url":"https://codeload.github.com/chuck-durst/germaine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249525036,"owners_count":21285927,"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":["api","expressjs","json","jsonapi","nodejs","rest"],"created_at":"2024-10-18T16:10:26.635Z","updated_at":"2025-04-20T01:00:27.434Z","avatar_url":"https://github.com/chuck-durst.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"**Germaine is an ExpressJs middleware that allows you to quickly deploy an API that listens on a given endpoint and serves content from a JSON file.**\n\n\n\n\n# Features\n\n-   dependency free\n-   lightweight (3Ko)\n-   super-fast\n-   delay simulator (for lazy loading tests)\n-   dynamic reading\n-   Define your endpoints in a funny way :)\n\n\n\n\n# Installing\n\nUsing npm:\n\n    $ npm install germaine\n\nUsing bower:\n\n    $ bower install germaine\n\n\n\n\n# API\n\n## germaine(path\\[, config])\n\n**path**\n\nThe path to the file used as database. It can be JSON or JavaScript.\n\n\n\n**config**\n\n| **NAME** |                                  **TYPE**                                 | **DESCRIPTION**                                                                                                                                                                                                                    |\n| :------- | :-----------------------------------------------------------------------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| isStatic | boolean                                                **Default**: false | By default, the file will be read **each time the url is called**. This allows you to update the content at any time without having to restart the whole server. You can disable this feature by setting **isStatic** to **true**. |\n| delay    | int,object                                             **Default**: 0     | You can add a custom delay (**ms**) to the requests. This is useful to simulate lazy loading for example.  You can also provide an object with the **min** and **max** properties to randomise the delay.                          |\n\n\n\n\n\n\n# Example\n\n    const express  = require('express');\n\n    const germaine = require('../index');\n\n    const path     = require('path');\n\n    const app = express();\n\n    app.get(\n\n      '/germaine/*', \n\n      germaine(path.resolve(__dirname, './example-database.json'))\n\n    );\n\n    app.listen(3030, function () {\n\n      console.log('germaine listening on localhost:3030/germaine!');\n\n    });\n\n\n\n\n# How it works\n\nLet's assume that this JSON represents your database:\n\n\n\n    {\n\n      \"pages\": {\n\n        \"home\": {\n\n          \"title\": \"Home page\",\n\n          \"content\": {\n\n            \"intro\": \"...\"\n\n          }\n\n        },\n\n        \"bio\": {\n\n          \"title\": \"About myself\"\n\n        },\n\n        \"content\": {\n\n          \"lastProject\": \"Germaine\"\n\n        }\n\n      }\n\n    }\n\n\n\nWith germaine, you can get access at **any depth segment** of the file from the url.\n\n\n\nFor example, you can **get the content of the homepage** this way :\n\n    GET /germaine/pages/home\n\n\n\nBut you can also **only ask for the page title**!\n\n    GET /germaine/pages/home/title\n\n\n\nThis let you define more or less complexes structures and **sort your content** very easily! \n\n\n\n\n# When should I use this?\n\n\n\n-   When you only need to get **static content** from a server\n-   For building **tests**\n-   When you have to build something that needs to make **simple API calls**, but the API has not been developed\n\n\n\n\n# Can I use it on production?\n\nYes **of course**! Germaine is a **simple middleware for express**, so it's up to you to add any restrictions and controls you which. \n\n\n\n\n# What about multi-language?\n\nGermaine would like not to overweight. She therefore does not prefer to transform herself into a multi-function toolbox but remain herself, simple. However, it is always possible for you to cheat a little :\n\n    const express  = require('express');\n\n    const germaine = require('../index');\n\n    const path     = require('path');\n\n    const app = express();\n\n    app.get('/germaine/*', (req, res) =\u003e {\n\n      if (headers['content-language']) {\n\n        const path = `database-${headers['content-language']}.json`;\n\n        return germaine(path.resolve(__dirname, path)(req, res);\n\n      }\n\n    }));\n\n    app.listen(3030, function () {\n\n     console.log('germaine listening on localhost:3030/germaine!');\n\n    });\n\n\n\n\n# And if I want to use several JSON files?\n\n\n\nGermaine would like not to overweight. She therefore does not prefer to transform herself into a multi-function toolbox but remain herself, simple. However, it is always possible for you to cheat a little :\n\n\n\n    const express  = require('express');\n\n    const germaine = require('../index');\n\n    const path     = require('path');\n\n    const app = express();\n\n    app.get(\n\n      '/germaine/pages*', \n\n      germaine(path.resolve(__dirname, './pages-database.json'))\n\n    );\n\n    app.get(\n\n      '/germaine/articles*', \n\n      germaine(path.resolve(__dirname, './articles-database.json'))\n\n    );\n\n    app.listen(3030, function () {\n\n    console.log('germaine listening on localhost:3030/germaine!');\n\n    });\n\n\n\n\n# License\n\nMIT\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchuck-durst%2Fgermaine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchuck-durst%2Fgermaine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchuck-durst%2Fgermaine/lists"}