{"id":17753225,"url":"https://github.com/zvakanaka/mere-server","last_synced_at":"2026-01-20T00:34:07.314Z","repository":{"id":56405712,"uuid":"147761137","full_name":"zvakanaka/mere-server","owner":"zvakanaka","description":"Serve dynamic html and json with restify","archived":false,"fork":false,"pushed_at":"2020-11-09T22:39:10.000Z","size":380,"stargazers_count":0,"open_issues_count":9,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-09-18T11:01:00.181Z","etag":null,"topics":["api","html","json","server"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/mere-server","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zvakanaka.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-07T02:43:41.000Z","updated_at":"2019-11-27T03:52:15.000Z","dependencies_parsed_at":"2022-08-15T18:10:13.817Z","dependency_job_id":null,"html_url":"https://github.com/zvakanaka/mere-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zvakanaka%2Fmere-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zvakanaka%2Fmere-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zvakanaka%2Fmere-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zvakanaka%2Fmere-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zvakanaka","download_url":"https://codeload.github.com/zvakanaka/mere-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247640034,"owners_count":20971548,"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","html","json","server"],"created_at":"2024-10-26T13:23:19.188Z","updated_at":"2026-01-20T00:34:07.274Z","avatar_url":"https://github.com/zvakanaka.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mere-server\nServe HTML or JSON\n\n`$ npm install --save mere-server`\n\n## Hello World Server\n\n```js\nconst mereServer = require('mere-server');\n\nconst routes = [\n  { route: '/hello-world', bodyCb: () =\u003e { return '\u003ch1\u003eHello World\u003c/h1\u003e' } },\n  { route: '/users-table', bodyCb: require('./controllers/users') },\n  { route: '/add-user', bodyCb: require('./controllers/addUser'), method: 'POST', responseType: 'JSON' }\n];\n\nmereServer.init(routes, { port: 8080 });\n```\n\n## Custom Route Handlers\nStreaming video\n```js\nconst mereServer = require('mere-server');\nconst fs = require('fs');\n\nfunction streamVideo (server, route, _bodyCb) {\n  server.get(route, async (req, res) =\u003e {\n    const path = '/home/you/video.mp4';\n    const stat = fs.statSync(path);\n    const total = stat.size;\n    const range = req.headers.range || 'bytes=0-';\n    const parts = range.replace(/bytes=/, '').split('-');\n    const partialstart = parts[0];\n    const partialend = parts[1];\n    const start = parseInt(partialstart, 10);\n    const end = partialend ? parseInt(partialend, 10) : total - 1;\n    const chunksize = (end - start) + 1;\n    const file = fs.createReadStream(path, { start, end });\n    res.writeHead(206, {\n      'Content-Range': `bytes ${start}-${end}/${total}`,\n      'Accept-Ranges': 'bytes',\n      'Content-Length': chunksize,\n      'Content-Type': 'video/mp4'\n    });\n    file.pipe(res);\n  });\n}\n\nconst routes = [\n  {\n    route: '/',\n    bodyCb: (url, req) =\u003e {\n      return `\u003ch1\u003eVideo Stream Demo\u003c/h1\u003e\n      \u003cvideo controls src=\"http://localhost:8080/video-stream\"/\u003e`;\n    },\n    method: 'GET'\n  },\n  // GET /video-stream will be handled by the streamVideo function\n  { route: '/video-stream', method: 'GET', responseType: 'video/mp4' }\n];\n\nmereServer.init(routes, {\n  port,\n  routeHandlers: [ // custom route handlers\n    { method: 'GET', responseType: 'video/mp4', func: streamVideo }\n  ]\n});\n```\n\nDeploy with cron job:\n```sh\n@reboot cd /home/you/path/to/your-mere-server \u0026\u0026 /home/you/.nvm/versions/node/v10.15.3/bin/node index.js 3456\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzvakanaka%2Fmere-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzvakanaka%2Fmere-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzvakanaka%2Fmere-server/lists"}