{"id":20562173,"url":"https://github.com/3ufferick/pejvak","last_synced_at":"2025-07-06T20:06:41.457Z","repository":{"id":57749383,"uuid":"380376937","full_name":"3ufferick/pejvak","owner":"3ufferick","description":"a simple nodejs web framework","archived":false,"fork":false,"pushed_at":"2023-06-30T18:36:22.000Z","size":51,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-13T13:43:26.242Z","etag":null,"topics":["framework","nodejs","server","template","web"],"latest_commit_sha":null,"homepage":"","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/3ufferick.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,"governance":null}},"created_at":"2021-06-25T23:51:17.000Z","updated_at":"2022-08-20T14:09:20.000Z","dependencies_parsed_at":"2023-12-07T22:03:55.815Z","dependency_job_id":"6374cb60-a730-4b0c-9e8e-d2ff8c679a1c","html_url":"https://github.com/3ufferick/pejvak","commit_stats":null,"previous_names":["rickali137/pejvak"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3ufferick%2Fpejvak","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3ufferick%2Fpejvak/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3ufferick%2Fpejvak/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3ufferick%2Fpejvak/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/3ufferick","download_url":"https://codeload.github.com/3ufferick/pejvak/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242171481,"owners_count":20083557,"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":["framework","nodejs","server","template","web"],"created_at":"2024-11-16T04:09:30.403Z","updated_at":"2025-03-06T08:16:47.061Z","avatar_url":"https://github.com/3ufferick.png","language":"JavaScript","readme":"pejvak is a fast web framework with minimum dependencies and small size for [Node.js](https://nodejs.org/). it has an embeded template rendering engine. I have just created `pejvak` for my personal projects in the first place.\n\n## Installation\n\nThis is a [Node.js](https://nodejs.org/en/) module available through the\n[npm registry](https://www.npmjs.com/).\n\nBefore installing pejvak, [install node.js](https://nodejs.org/en/download/).\n\nfirst create a `package.json` with\nthe [`npm init` command](https://docs.npmjs.com/creating-a-package-json-file).\n\nthen use [`npm install`](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):\n\n```console\n$ npm install pejvak\n```\n# How to use\n## Example 1\n```js\nimport pejvak from \"pejvak\"\n\nlet srv = new pejvak({ port: 80 });\n\nsrv.handle(\"GET\", \"/\", (req, res) =\u003e {\n  res.send(\"This is a GET method\");\n});\n\nsrv.start();\n```\n## Example 2\nassuming your project folder structure is like this:\n```\nProjectFolder\n|\n|__node_modules\n|  |__pejvak\n|  |__jquery\n|\n|__view\n|  |__home.pejvakhtml\n|  |__rendercode.pejvakhtml\n|  |__main.template\n|\n|__www\n|  |__static.html\n|  |__...\n|\n|__index.js\n|__package-lock.json\n|__package.json\n```\n### example project files:\n`pejvak constructor` has 3 parameters.\n* settings\n* routes\n* virtualPaths\n### settings (1st parameter)\nthe structure should be something like this:\n```js\nconst settings = {\n  www: \"./www\",  //main www folder where you should place static files(html,css,local js files, images, ...)\n  view: \"./view\",  //view folder containing `.template` and `.pejvakhtml` files\n  port: 80,    //http port number\n  renderFileExtension: \".pejvakhtml\",    //default pejvak rendering file extension (usually: \".pejvakhtml\")\n  forbidenExtensions: [\".pejvakhtml\", \".pem\"],  //all forbidden file extensions from direct http requests\n  https: {  //in case of using https\n    port: 443,  //https secure port\n    keyFile: \"./key.pem\",  //https key file location path\n    certFile: \"./cert.pem\"  //https certificate file location path\n  }\n}\n```\n### routes (2nd parameter)\nyou can set some static routes when you don't need to run a block of code to render. for example assume that you have a static `rendercode` page and a simple `static html`. then you can set the routing path for them at the initialize point of pejvak server:\n```js\nconst routes = {\n  \"/rendercode\": { file: \"/rendercode.pejvakhtml\", template: \"/main.template\" },\n  \"/static\": { file: \"/static.html\" },\n};\n```\n### virtualPaths (3d parameter)\nhere you can bind any unique path to access to the desired module folder. virtual paths makes the module files accessible through web:\n```js\nconst vritualpaths = {\n  \"/js/jquery\": \"node_modules/jquery/dist\",\n}\n```\ncomplete index.js file should be like this:\n```js\n/** index.js */\nimport pejvak from \"pejvak\"\n\nconst settings = {\n  www: \"./www\",\n  view: \"./view\",\n  port: 80,\n  renderFileExtension: \".pejvakhtml\",\n  forbidenExtensions: [\".pejvakhtml\"],\n};\nconst routes = {\n  \"/rendercode\": { file: \"/rendercode.pejvakhtml\", template: \"/main.template\" },\n  \"/static\": { file: \"/static.html\" },\n};\nconst vritualpaths = {\n  \"/js/jquery\": \"node_modules/jquery/dist\",\n};\n\nlet srv = new pejvak(settings, routes, vritualpaths);\n\nsrv.handle(\"GET\", \"/\", (req, res) =\u003e {\n  res.render(\"home.pejvakhtml\", \"main.template\", { user: \"rick\", role: \"admin\" });\n});\n\nsrv.handle(\"POST\", \"/gettime\", (req, res) =\u003e {\n  res.send(new Date().toLocaleTimeString()).end();\n});\n\nsrv.start();\n```\n```html\n\u003c!-- main.template --\u003e\n\u003c!doctype html\u003e\n\u003chtml\u003e\n\n\u003chead\u003e\n  \u003cmeta charset=\"utf-8\"\u003e\n  \u003ctitle\u003e{@title}\u003c/title\u003e\n  \u003cstyle\u003e\n    body { padding: 10px; }\n    .menu { margin: 5px; border: 1px solid #555; border-radius: 5px; padding: 10px; font-size: 1.5em; }\n  \u003c/style\u003e\n  {@head}\n\u003c/head\u003e\n\n\u003cbody\u003e\n  \u003ca class=\"menu\" href=\"/\"\u003eHome\u003c/a\u003e\n  \u003ca class=\"menu\" href=\"/rendercode\"\u003erender code\u003c/a\u003e\n  \u003ca class=\"menu\" href=\"/static\"\u003estatic\u003c/a\u003e\n  {@content}\n  {@script}\n\u003c/body\u003e\n\n\u003c/html\u003e\n```\n```html\n\u003c!-- home.pejvakhtml --\u003e\n@part:title {home page} part:title;\n@part:head\n{\n  \u003cstyle\u003e\n    span { color: red; }\n  \u003c/style\u003e\n} part:head;\n\n@part:content\n{\n  \u003ch2\u003ehome page is rendered with model data\u003c/h2\u003e\n  \u003ch3\u003ethe user \u003cspan\u003e${model.user}\u003c/span\u003e has role \u003cspan\u003e${model.role}\u003c/span\u003e\u003c/h3\u003e\n  \u003cbutton onclick=\"gettime()\"\u003eget server time\u003c/button\u003e\n  \u003cspan id=\"time\"\u003e\u003c/span\u003e\n} part:content;\n\n@part:script\n{\n  \u003cscript\u003e\n    function gettime() {\n      $.ajax({\n        type: \"POST\",\n        url: \"/gettime\",\n      }).done(function (data) {\n        $(\"#time\").html(data);\n      });\n    }\n  \u003c/script\u003e\n  \u003c!-- consider using of \"/js/jquery/...\" has been defined as a virtual path before --\u003e\n  \u003cscript src=\"/js/jquery/jquery.min.js\"\u003e\u003c/script\u003e\n} part:script;\n```\n```html\n\u003c!-- rendercode.pejvakhtml --\u003e\n@part:title {rendercode page} part:title;\n@part:head\n{\n\u003cstyle\u003e\n  body { background-color: rgb(83, 158, 163); }\n  * { color: white; border-color: white !important; }\n  span { font-size: 2em; }\n\u003c/style\u003e\n} part:head;\n\n@part:content\n{\n  \u003ch2\u003ethe matrix is filled with server side js rendering code\u003c/h2\u003e\n  @for(var i = 1; i \u003c 5; i++) {\n    \u003cspan style=\"color: yellow\"\u003e ${i} \u003c/span\u003e\n    @for(var j = 1; j \u003c 10; j++) {\n      \u003cspan style=\"color: aqua\"\u003e ${j} \u003c/span\u003e\n    @}\n   \u003cbr/\u003e\n  @}\n} part:content;\n```\nprobably you have noticed some `{@partname}` tag style in the above code. this format is used in the template designing feature of pejvak and will be explained later ([Template structure](#template-structure)).\n\nalso `@` char at the beginning of lines (other than parts) means that the js code is going to render at the server side.\n## Template structure\nin a `.template` file you can define dynamic parts in the format of `{@partname}`. you can choose any desired name. \n```html\n...\n\u003chead\u003e\n  {@name}\n\u003c/head\u003e\n...\n```\n\nparts are replaced with the given value during the rendering process. then inside `.pejvakhtml` files you can define contents of each part separately in the following format:\n```html\n@part:name {\n  ...(content)...\n} part:name;\n```\n## Rendering javascript codes\nyou can use any javascript code inside `.pejvakhtml` files which is going to run during the rendering process. to do so, just add the `@` at the beginning of the line.\n```html\n@for(var i = 1; i \u003c 5; i++) {\n  \u003cspan\u003e${i}\u003c/span\u003e\n@}\n```\n## Docs\ncoming soon\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F3ufferick%2Fpejvak","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F3ufferick%2Fpejvak","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F3ufferick%2Fpejvak/lists"}