{"id":13447497,"url":"https://github.com/hiowenluke/noapi","last_synced_at":"2025-03-22T01:31:03.991Z","repository":{"id":65424605,"uuid":"195736636","full_name":"hiowenluke/noapi","owner":"hiowenluke","description":"A high performance API framework for Node.js, load directory \"biz\" as a web API server","archived":false,"fork":false,"pushed_at":"2020-02-10T18:27:20.000Z","size":5877,"stargazers_count":104,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-02T00:37:56.762Z","etag":null,"topics":[],"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/hiowenluke.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":"2019-07-08T04:29:55.000Z","updated_at":"2024-05-16T19:16:34.000Z","dependencies_parsed_at":"2023-01-23T10:55:21.039Z","dependency_job_id":null,"html_url":"https://github.com/hiowenluke/noapi","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/hiowenluke%2Fnoapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiowenluke%2Fnoapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiowenluke%2Fnoapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiowenluke%2Fnoapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hiowenluke","download_url":"https://codeload.github.com/hiowenluke/noapi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244893410,"owners_count":20527585,"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":[],"created_at":"2024-07-31T05:01:19.372Z","updated_at":"2025-03-22T01:31:03.602Z","avatar_url":"https://github.com/hiowenluke.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"\n# Noapi\n\nA high-performance and easy-to-use web API framework for [Node.js](https://nodejs.org). Noapi loads directory \"biz\" as a web API server, each file in it defines and handles an API, so that you can focus on writing business function code. Noapi is simple enough that you just take it \"out of the box\".\n\n## Install\n\n```sh\nnpm install noapi --save\n```\n\n## TRY IT! (in under 3 minutes)\n\n### 0. Initialize a demo project\n\n```sh\nmkdir ./noapi-demo \u0026\u0026 cd ./noapi-demo\nnpm init -y\nnpm install noapi --save\n```\n\nCreate the core directory \"**biz**\"\n\n```sh\nmkdir biz\n```\n\n### 1. Create a biz file\n\nCreate file \"./biz/say/hi.js\". It defines an api \"/say/hi\" and handles it. \n\n```js\nmodule.exports = async (name, age) =\u003e {\n    return {msg: `Hi, I am ${name}, ${age} years old.`};\n};\n```\n\n### 2. Create index.js\n\n```js\nrequire('noapi')();\n```\n\n### 3. Run\n\n```sh\nnode index.js\nServer default is listening on port 3000\n```\n\nVisit the url [http://localhost:3000/say/hi?age=100\u0026name=owen]() to see the result:\n\n```json\n{\n    \"success\": true,\n    \"data\": {\n        \"msg\": \"Hi, I am owen, 100 years old.\"\n    }\n}\n```\n\nThe order of the parameters in the url can be arbitrary.\n\n## Examples\n\n* [01 hello world](./examples/01-hello-world)\n* [02 complex url params](./examples/02-complex-url-params)\n* [03 returning an error](./examples/03-returning-an-error)\n* [04 throwing an error](./examples/04-throwing-an-error)\n* [05 api directory](./examples/05-api-directory)\n* [06 with database](./examples/06-with-database)\n* [07 static resources](./examples/07-static-resources)\n* [99 options](./examples/99-options)\n\n## Options\n\nIt can be omitted if it is the default value as below. \n\n```js\nconst name = 'default';\nconst dir = './biz';\nconst host = 'localhost';\nconst port = 3000; \nconst isSilence = false;\n\n// The number and order of parameters can be arbitrary\nnoapi(name, dir, host, port, isSilence);\n\n// It is equivalents to:\n//     const options = {\n//         name: 'default',\n//         dir: './biz',\n//         host: 'localhost',\n//         port: 3000,\n//         isSilence: true,\n//     };\n//\n//     noapi(options);\n```\n\nSee \"[examples/99-options](./examples/99-options)\" to learn about it.\n\n## Biz directory\n\nEach file in the biz directory defines and handles an API. All files in the biz directory make up the API list.\n\n```js\n/root\n    /biz\n        /say\n            hi.js       // api: /say/hi\n        about.js        // api: /about\n     \n    index.js    \n```\n\nIf there are some non-api files (only be used internally) in the biz directory, this will make the API list unclear. Then you should use the **api directory**, just create an empty file (or with the description of this api) to define an api. See \"[examples/05-api-directory](./examples/05-api-directory)\".\n\n```js\n/root\n    /api\n        /say\n            hi.js       // api: /say/hi\n        about.js        // api: /about\n\n    /biz\n        /__lib\n        /say\n            /__lib\n            hi.js   \n            tools.js    // non-api\n            check.js    // non-api\n        about.js       \n        init.js         // non-api\n        \n    index.js\n```\n\n## Performance\n\nNoapi is a high-performance web API framework, faster than [Koa](https://github.com/koajs/koa), [Express](https://github.com/expressjs/express). See [API Framework Performance PK](https://github.com/hiowenluke/api-frameworks-performance-pk)\n\n## Test\n\n```sh\ngit clone https://github.com/hiowenluke/noapi\ncd noapi\nnpm install\nnpm test\n```\n\n## License\n\n[MIT](LICENSE)\n\nCopyright (c) 2019, Owen Luke\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhiowenluke%2Fnoapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhiowenluke%2Fnoapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhiowenluke%2Fnoapi/lists"}