{"id":21411888,"url":"https://github.com/talha-t/neistion","last_synced_at":"2026-02-12T02:37:10.027Z","repository":{"id":32978705,"uuid":"146626055","full_name":"Talha-T/neistion","owner":"Talha-T","description":"Declare your APIs, instead of writing them. Neistion is a high level web framework wrapper.","archived":false,"fork":false,"pushed_at":"2022-12-09T06:21:35.000Z","size":743,"stargazers_count":2,"open_issues_count":12,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-17T20:48:41.804Z","etag":null,"topics":["api","express","nodejs","server","typescript","webframework"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/Talha-T.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-08-29T16:11:10.000Z","updated_at":"2021-08-27T09:31:00.000Z","dependencies_parsed_at":"2023-01-14T22:54:47.697Z","dependency_job_id":null,"html_url":"https://github.com/Talha-T/neistion","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/Talha-T%2Fneistion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Talha-T%2Fneistion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Talha-T%2Fneistion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Talha-T%2Fneistion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Talha-T","download_url":"https://codeload.github.com/Talha-T/neistion/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238478772,"owners_count":19479198,"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","express","nodejs","server","typescript","webframework"],"created_at":"2024-11-22T17:48:04.374Z","updated_at":"2026-02-12T02:37:10.002Z","avatar_url":"https://github.com/Talha-T.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"- [Neistion](#neistion)\n  - [Installation](#installation)\n  - [Example](#example)\n  - [API](#api)\n    - [new Neistion(app, [options])](#new-neistionapp-options)\n      - [app: IApp\u003cT\u003e](#app-iappt)\n      - [options: NeistionOptions](#options-neistionoptions)\n      - [api.start(port)](#apistartport)\n      - [api.setup()](#apisetup)\n      - [api.addApiCall(call)](#apiaddapicallcall)\n      - [api.addRoutesFromDirectory(routesDirectoryPath)](#apiaddroutesfromdirectoryroutesdirectorypath)\n  - [Missing something?](#missing-something)\n  - [Contact](#contact)\n\n# Neistion\n\n**Declare your APIs instead of writing them.**  \nNeistion comes with predefined parameter validation and sanitization, authorization and more you can think of. Supports multiple frameworks, and you can create your own framework wrapper easily.\n\n## Installation\n\n```sh\n$ npm install neistion --save\n```\n\nRemember to add these lines to tsconfig.json (if you are going to use decorators):\n\n```\n\"experimentalDecorators\": true,\n\"emitDecoratorMetadata\": true\n```\n\n## Example\n\n```ts\nimport { IncomingHttpHeaders } from \"http\";\nimport { Neistion, sandhandsProp, ExpressApp } from \"neistion\";\n\nclass RandomParameters {\n  @sandhandsProp\n  public min!: number;\n  @sandhandsProp\n  public max!: number;\n}\n\nconst api = new Neistion(new ExpressApp(), {\n  routes: [\n    {\n      route: \"/random\",\n      method: \"GET\",\n      parametersSchema: \"RandomParameters\",\n      call(parameters: RandomParameters) {\n        const { max, min } = parameters;\n        return Math.floor(Math.random() * (max - min)) + min;\n      },\n      verify(headers: IncomingHttpHeaders, parameters: RandomParameters) {\n        return parameters.max \u003e parameters.min;\n      }\n    }\n  ],\n  debug: true,\n  strictPropertyCheck: true,\n});\n\napi.start(3000);\n```\n\n![example](example.gif)\n\n## API\n\n### new Neistion(app, [options])\n\nReturns the main Neistion object, which empowers the API.\n\n### app: IApp\u003cT\u003e\n    This is the proxy between Neistion and your framework. Change this to change what framework is used in your API. You can easily implement your own proxy, check `src/proxy/` for that.\n\n    Currently, available options are `ExpressApp` and ~~`FastifyApp`~~\n\n### options: NeistionOptions\n\n- #### routes: [IApiRoute](#iapiroute)[]\n  This is where you define your **api calls** within options, so this should be defined even if it should be empty.\n  - #### IApiRoute\u003cPT\u003e\n    #### call: (parameters: PT) =\u003e Promise\u003cany\u003e | any\n    The function to be called for the API route. Runs last, after ~~`normalizeParameters`~~, ~~`transformParameters`~~ and [`verify`](#verify).\n    #### method: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\"\n    The method of the API call, as a string.\n    #### parametersSchema: ISandhandsSchema | string\n    This schema is used to validate incoming request parameters.  \n     Examples:\n    ```ts\n    {\n        key: String,\n        number: Number,\n        isCool: Boolean\n    }\n    ```\n    or, as a Typescript class using power of decorators:\n    ```ts\n    import { sandhandsProp } from \"neistion\";\n    class ApiParameterType {\n      @sandhandsProp\n      public key: string;\n    }\n    // ...,\n    parametersSchema: \"ApiParameterType\";\n    // Because we defined sandhandsProp decorator on property, we can just type the name. Otherwise, we should duplicat e it.\n    ```\n    #### perRouteMiddlewares: RequestHandler[]\n    An array of middlewares to be run only for this route.\n    #### route: string\n    The route string, used by express.\n    You can use dynamic routes too, whatever express supports as a route.\n    #### verify?: (headers: IncomingHttpHeaders, parameters: PT) =\u003e Promise\\\u003cboolean\u003e | boolean | Promise\\\u003cIStatusMessagePair\u003e | IStatusMessagePair\n    Takes in `headers` and `parameters` of the request, and returns one of the types above.\n    Use this for authentication.\n    #### verifyCallback?: (headers: IncomingHttpHeaders, parameters: IncomingParameters, returnCallback: (result: IStatusMessagePair | boolean) =\u003e void) =\u003e void\n    Same as `verify`, but waits for the callback instead. Designed to be used with old libraries, using callbacks.\n- #### debug?: boolean\n  Whether the library should log the debug messages or not.\n- #### express?: (express: Express) =\u003e Promise\\\u003cvoid\u003e\n  Takes express instance in. You can do anything with express you need here. Runs after defining routes.\n- #### json?: boolean\n  Whether JSON serialization should be made or not. If not, literal objects are written to requests.\n- #### strictPropertyCheck?: boolean\n  If set to true, parameter objects with extra properties will be an invalid parameter.\n\n#### api.start(port)\n\n    Starts the API up at the given port.\n\n#### api.setup()\n\n    Redefines the routes from scratch, depending on options.\n\n#### api.addApiCall(call)\n\n    Adds an API call to the route handlers. You do not need to `setup()` after this function.\n\n#### api.addRoutesFromDirectory(routesDirectoryPath)\n\n    Adds all modules inside given directory as routes to the API.\n    \n    api.addRoutesFromDirectory() // uses the default path, which is /routes\n\n    Example tree structure:\n    - routes\n        - random.js\n        - index.js\n \n    All of the files inside `routes` directory should implement IApiRoute, otherwise an error will be thrown.\n\n## Missing something?\n\nFeel free to open an issue for requests. They are welcome.\n\n## Contact\n\nImplicit#8954\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftalha-t%2Fneistion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftalha-t%2Fneistion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftalha-t%2Fneistion/lists"}