{"id":15021532,"url":"https://github.com/zhex/fe-dev-server","last_synced_at":"2025-07-30T15:08:36.953Z","repository":{"id":36208717,"uuid":"40512977","full_name":"zhex/fe-dev-server","owner":"zhex","description":"FE Dev Server target to help frontend web developers create view template, styles and js easily.","archived":false,"fork":false,"pushed_at":"2022-11-30T00:12:37.000Z","size":6568,"stargazers_count":28,"open_issues_count":0,"forks_count":11,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-30T03:42:16.487Z","etag":null,"topics":["mock","mock-data"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"funky-monkey/IsoCountryCodes","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zhex.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":"2015-08-11T00:37:02.000Z","updated_at":"2023-08-24T07:54:46.000Z","dependencies_parsed_at":"2023-01-16T23:46:23.101Z","dependency_job_id":null,"html_url":"https://github.com/zhex/fe-dev-server","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/zhex/fe-dev-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhex%2Ffe-dev-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhex%2Ffe-dev-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhex%2Ffe-dev-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhex%2Ffe-dev-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhex","download_url":"https://codeload.github.com/zhex/fe-dev-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhex%2Ffe-dev-server/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267889263,"owners_count":24161157,"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","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["mock","mock-data"],"created_at":"2024-09-24T19:56:41.620Z","updated_at":"2025-07-30T15:08:36.892Z","avatar_url":"https://github.com/zhex.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FE Dev Server [![Build and Deploy](https://github.com/zhex/fe-dev-server/actions/workflows/deploy.yml/badge.svg)](https://github.com/zhex/fe-dev-server/actions/workflows/deploy.yml)\n\nFE Dev Server target to help frontend web developers create view template, styles and js easily. It try the best to simulate real server environment which can help you to make you job done. \n\n## Features\n\n1. Various template engines and embedded page data.\n2. Url simulation\n3. Mock data in file\n4. Proxy configuration\n\n## Quick start\n\nInstall it as a command line tool with the following step:\n\n\nInstall module globally\n\n```\n$ npm install -g fe-dev-server\n```\n\ncreate project folder and get into the folder\n\n```\n$ mkdir workdir \u0026\u0026 cd workdir\n```\n\ninitial the project folder\n\n```\n$ fds init\n```\n\nstart up server\n\n```\n$ fds server\n```\n\nstart up server \u0026 open browser\n\n```\n$ fds server -o\n```\n\nAlso, it can be integrated into your own project as a node module.\n\n```js\nvar fds = require('fe-dev-server');\n\nvar app = fds({\n    basePath: __dirname,\n    mockFolder: 'data',\n    port: 8001  \n});\n```\n\n## Routes\n\nRoutes is stored in `routes.js` as key/value pairs by default.\n\nSample:\n\n```js\nmodule.exports = {\n    // set /test route to test.html page, default http method is GET\n    '/test':                    'test.html',\n    \n    // set /books route to books.pug template with GET method\n    'GET::/books':              'books.pug',\n    \n    // set json api with a json file in mock folder\n    'POST::/api/books':         'mock::books.json',\n    \n    // mock file can also be a js file, which has more power to do the customization\n    'GET::/api/category':       'mock::category.js',\n\n    // fds works with java template such as jsp;\n    // before do this, you have to set enableJava to true in your fds-config.js file\n    '/jsp-page':                'books.jsp',\n    \n    // it allow your route to proxy an online page\n    '/proxy-api':               'http://www.github.com/zhex.json',\n    \n    // proxy can do fuzzy mapping;\n    // in the setting, if you visit /books/hello, it will map to http://example.com/books/hello\n    'ALL::/books/:pattern*':    'http://example.com/books/'\n};\n```\nthe rule is `'[method]::[route_url]': '[template_file]'`.\n\nAllowed method: `GET`, `POST`, `PUT`, `PATCH`, `DETELE`\n\n`GET` will be used if it is not specified.\n\nIf you want to setup an ajax api url, you can set the template to a json file. The server will look for the json/js file in view folder and send back it as a json object. the data in the view folder sounds not make sense. So if you want put the json/js file in the mock folder, then you can add a `mock::` prefix in the template path, then the server will look for the file in mock folder.\n\nIf the mock file is a js file, then it is good to define as a module function:\n\n```js\nmodule.exports = function (data, utils) {\n    return {\n        id: data.params.id,\n        name: data.query.name || 'hello world',\n        content: data.body.content\n    };\n};\n```\nThe `data.params` is the match variable collection in the particular route; The `data.query` is the query data from request url, so you can easily test your page with different api return.\n\n`utils` provide some easy to use method to handle the data.\n\navailable method:\n\n- utils.isObject(obj)\n- utils.isArray(obj)\n- utils.isFunc(obj)\n- utils.contains(array, item)\n- utils.serialize(obj)\n- utils.assign() - which is [object-assign](https://www.npmjs.com/package/object-assign) library\n- utils.moment() - which is [moment](http://momentjs.com/) library\n- utils.Mock - which is [mockjs](http://mockjs.com) library\n\nAlso, you can add `$$header` in the data file to extend http response header, and using `$$delay` to set simulate the http connection delay.\n\n```js\n{\n    \"$$header\": {\n        \"x-access-token\": \"abcs\"\n    },\n    \"$$delay\": 3000,\n    \"title\": \"hello world\"\n}\n\n```\n\n## embedded template engines\n\n- [pug](https://pugjs.org/api/getting-started.html)\n- [handlebars](http://handlebarsjs.com/)\n- [ejs](http://www.embeddedjs.com/)\n- [jsp](https://en.wikipedia.org/wiki/JavaServer_Pages) (java)\n- [velocity](http://velocity.apache.org/) (java)\n\n\n## Configuration\n\nYou can custom your configuration in `fds-config.js` file.\n\n```js\ndefaultConfig = {\n    basePath: path.resolve(__dirname, './example'),\n    publicFolder: 'public',\n    viewFolder: 'views',\n    mockFolder: 'mocks',\n    routeFile: 'routes.js',\n    port: 3000\n}\n```\n\n### basePath\n\nThe base path of the project, all other folder settings are related to base path.\n\n### viewFolder\n\ndefault: 'views'\n\nWhere you can put your view template files.\n\n### mockFolder\n\ndefault: 'mocks'\n\nSave you mock data into this folder. each view template will have a matched json data file will be loaded automatcially. \n\nFor example: we have a `${viewFolder}/projects/index.html` template, then data in `${viewFolder}/projects/index.json` file will be auto loaded into the template.\n\n### publicFolder\n\ndefault: 'public'\n\nWhere you can put your image, style and js files here. This folder is set by `express.static()`\n\n### routeFile\n\ndefault: 'routes.js'\n\nRoutes mapping file\n\n### mockExts\n\ndefault: ['.js', '.json']\n\nSome people like to set mockFolder as the same as viewFolder for convinence reason, `mockExts` give you the ability to define your own mock file type to avoid the conflict issue. Also, the ext order in array demonstrate the priority from higher to lower.\n\n### port\n\ndefault: 3000\n\nExpress server port\n\n### enableJava\n\ndefault: true\n\nSometimes you don't need to support java templates, you can turn it off with this property to `false`.\n\n### livereload\n\ndefault: true\n\nlivereload is awesome, it will refresh your browser automatically after anything changed. If you dont like this feature, you can set it to `false` to switch it off. also you can set it as a **livereload option object**;\n\n### open\n\ndefault: { route: '/', browser: ['google chrome'] }\n\nBrowser setting allow you to open dev site automatically on server started with `-o` option in cli. It will open google chrome by default. \n\n```\n$ fds server -o\n```\n\n## License\n\nThis project is licensed under the terms of the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhex%2Ffe-dev-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhex%2Ffe-dev-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhex%2Ffe-dev-server/lists"}