{"id":16387491,"url":"https://github.com/mastilver/node-annotation-parser","last_synced_at":"2025-03-23T04:31:29.195Z","repository":{"id":26347309,"uuid":"29796188","full_name":"mastilver/node-annotation-parser","owner":"mastilver","description":"a easy to use annotation parser for JavaScript","archived":false,"fork":false,"pushed_at":"2016-12-23T13:01:27.000Z","size":25,"stargazers_count":8,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T17:44:43.842Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/mastilver.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-01-24T23:47:42.000Z","updated_at":"2020-04-08T19:16:53.000Z","dependencies_parsed_at":"2022-09-14T03:31:41.145Z","dependency_job_id":null,"html_url":"https://github.com/mastilver/node-annotation-parser","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mastilver%2Fnode-annotation-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mastilver%2Fnode-annotation-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mastilver%2Fnode-annotation-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mastilver%2Fnode-annotation-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mastilver","download_url":"https://codeload.github.com/mastilver/node-annotation-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245056889,"owners_count":20553855,"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-10-11T04:26:40.845Z","updated_at":"2025-03-23T04:31:28.880Z","avatar_url":"https://github.com/mastilver.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-annotation-parser [![Build Status](https://travis-ci.org/mastilver/node-annotation-parser.svg?branch=master)](https://travis-ci.org/mastilver/node-annotation-parser) [![Coverage Status](https://coveralls.io/repos/mastilver/node-annotation-parser/badge.svg)](https://coveralls.io/r/mastilver/node-annotation-parser)\n\n### Presentation\n\nUnlike many other languages (C#, Java, PHP...), JavaScript doesn't handle annotation.\nThis module is here to help you correcting that.\n\n### Install\n\n`$ npm install --save annotation-parser`\n\n\n### Usage\n\n```\nannotationParser(filePath, callback)\n```\n\n\n### Exemple\n\ngiven this file (witch contains annotations) `controller.js`\n\n```\n/*\n    @routePrefix('api')\n*/\nmodule.exports = {\n\n    // @route('collection', 'GET')\n    collection: function(){\n\n    },\n\n    // @route('collection/{id}', 'GET')\n    index: function(){\n\n    },\n\u003e };\n```\n\n\nYou can then simply retrieve those annotations by doing so:\n\n```\n\nvar parser = require('annotation-parser');\n\nparser('controller.js', function(err, annotations){\n    console.log(annotations);\n\n    /*\n        {\n            module: {\n                name: 'controller',\n                annotations: {\n                    routePrefix: [\n                        ['api'],\n                    ],\n                },\n                ref: /* module reference */\n            },\n            functions: {\n                collection: {\n                    annotations: {\n                        route: [\n                            ['collection', 'GET']\n                        ],\n                    },\n                    ref: /* the collection function */\n                },\n                index: {\n                    annotations: {\n                        route: [\n                            ['collection/{id}', 'GET']\n                        ],\n                    },\n                    ref: /* the index function */\n                },\n            },\n        }\n    */\n})\n\n```\n\n\n### Inspiration\n\nMy first goal was to create an [MVC](https://aspnetwebstack.codeplex.com/wikipage?title=Attribute%20Routing%20in%20MVC%20and%20Web%20API) like router for Node.js, but I found it would be better to split this up.\n\nThere is already an [annotation parser](https://www.npmjs.com/package/annotation) for node but it didn't suit my needs.\n\n\n### Contributing\n\nWhen submiting your pull-request try to follow those guides:\n- https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github\n- https://medium.com/@vadimdemedes/making-your-first-contribution-de6576ddb190\n\n\n### Licence\n\nMIT © Thomas Sileghem\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmastilver%2Fnode-annotation-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmastilver%2Fnode-annotation-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmastilver%2Fnode-annotation-parser/lists"}