{"id":39036691,"url":"https://github.com/plopezm/decorated-express","last_synced_at":"2026-01-17T17:44:41.727Z","repository":{"id":57137259,"uuid":"116516461","full_name":"plopezm/decorated-express","owner":"plopezm","description":null,"archived":false,"fork":false,"pushed_at":"2018-02-21T21:54:40.000Z","size":60,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-08T23:52:39.134Z","etag":null,"topics":["decorations","express","rest","rest-api","typescript"],"latest_commit_sha":null,"homepage":null,"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/plopezm.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-01-06T21:21:45.000Z","updated_at":"2019-01-04T20:01:23.000Z","dependencies_parsed_at":"2022-09-01T03:01:21.889Z","dependency_job_id":null,"html_url":"https://github.com/plopezm/decorated-express","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/plopezm/decorated-express","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plopezm%2Fdecorated-express","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plopezm%2Fdecorated-express/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plopezm%2Fdecorated-express/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plopezm%2Fdecorated-express/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/plopezm","download_url":"https://codeload.github.com/plopezm/decorated-express/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plopezm%2Fdecorated-express/sbom","scorecard":{"id":737989,"data":{"date":"2025-08-11","repo":{"name":"github.com/plopezm/decorated-express","commit":"647a4c56b23a8d708afdf7518910b80768d753d1"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/9 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"20 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-rvg8-pwq2-xj7q","Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x","Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9","Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc","Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx","Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5","Warn: Project is vulnerable to: GHSA-8cf7-32gw-wr33","Warn: Project is vulnerable to: GHSA-hjrf-2m68-5959","Warn: Project is vulnerable to: GHSA-qwph-4952-7xr6","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w","Warn: Project is vulnerable to: GHSA-g6ww-v8xp-vmwg","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg","Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T16:28:25.978Z","repository_id":57137259,"created_at":"2025-08-22T16:28:25.978Z","updated_at":"2025-08-22T16:28:25.978Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28513975,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T13:38:16.342Z","status":"ssl_error","status_checked_at":"2026-01-17T13:37:44.060Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["decorations","express","rest","rest-api","typescript"],"created_at":"2026-01-17T17:44:41.642Z","updated_at":"2026-01-17T17:44:41.717Z","avatar_url":"https://github.com/plopezm.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# decorated-express\n\nThis library wraps an express application into a typescript class and provides decorators to ease restful developments. If you want to check an example application implemented using this library, please go [node-auth-typescript](https://github.com/plopezm/node-auth-typescript)\n\n# Installing @plopezm/decorated-express\n\n```\n  npm install express --save\n  npm install @types/express --save-dev\n  npm install @plopezm/decorated-express --save\n```\n\n# How to use it\n\nUsing this library is really easy:\n\n1. We have to define a resource:\n\n```\nimport * as express from \"express\";\nimport { GET, POST } from \"@plopezm/decorated-express\";\nimport { UserService } from \"../services/user-service\";\n\n// This paths will be the prefixx path to all methods\n@RoutePath('/tests')\nexport class UserResource {\n\n    userService: UserService;\n\n    constructor(){        \n      this.userService = new UserService();\n    }\n\n    // This path is the specific path for this method\n    @GET(\"/hello\")\n    helloworld(req: express.Request, res: express.Response, next: Function){\n        res.json({\n            message: 'Hello World!'\n        });\n    }\n\n    @GET(\"/users/:username\")\n    findUser(req: express.Request, res: express.Response, next: Function){\n        let id = req.params.username;\n        let user = this.userService.get(id);\n        res.json(user);\n    }\n\n    @POST(\"/users\")\n    createUser(req: express.Request, res: express.Response, next: Function) {\n        let user = this.userService.create(req.body);\n        res.json(user);\n    }\n\n}\n\n```\n\n2. In index.js create a server a add this resource:\n\n```\nimport * as express from 'express';\nimport * as mongoose from 'mongoose';\nimport * as bodyParser from 'body-parser';\nimport * as logger from \"morgan\";\n\nimport { Server } from \"@plopezm/decorated-express\";\n\n// Creates a new instance of a express server\nlet server = Server.bootstrap(express());\n// Config method allows us to set the desired middleware to be used\nserver.config(logger(\"dev\"),\n            bodyParser.json(),\n            bodyParser.urlencoded({extended: true}));\n// Register our decorated resources\nserver.registerResource(UserResource);\n// Server starts in the path '/api/v1'\nserver.start('/api/v1', 8080);\n\n```\n\nThe resource path is /tests and server path is /api/v1, so in order to call /hello method, we have to request localhost:8080/api/v1/tests/hello.\n\n\n# Adding resource middlewares\n\nProbably you would like to add some other middlewares to a specific resource in order to add security, logger, etc. This can be done using annotation @Middlewares(...). It is possible to add as many middlewares as you want.\n\n```\n// Declaring our example middlewares\nfunction sayHelloWorldMiddleware(req: express.Request, res: express.Response, next: Function) {\n    console.log(\"Hello world middleware 1\");\n    next();\n}\n\nfunction sayHelloWorldMiddleware2(req: express.Request, res: express.Response, next: Function) {\n    console.log(\"Hello world middleware 2\");\n    next();\n}\n\nexport class UserResource {\n\n    userService: UserService;\n\n    constructor(){        \n      this.userService = new UserService();\n    }\n\n    @GET(\"/hello\")\n    @Middlewares(sayHelloWorldMiddleware, sayHelloWorldMiddleware2)\n    helloworld(req: express.Request, res: express.Response, next: Function){\n        res.json({\n            message: 'Hello World!'\n        });\n    }\n\n    ...\n```\n# Setting Basic authentication\n\nThis library provides a way to manage automatically HTTP Basic Authentication using @BasicAuth annotation\n\n```\nimport { GET, POST, DELETE, PUT, Middlewares, BasicAuth, AuthenticationData } from \"@plopezm/decorated-express\";\n\nclass Resource {\n\n    static isUserValid(user: string, passwd: string): boolean{\n       return user === \"testing\" \u0026\u0026 password === \"testing\"   \n    }\n\n    @GET(\"/users/:username\")\n    @BasicAuth(Resource.isUserValid)\n    findUser(req: express.Request, res: express.Response, next: Function){\n        let authentication: AuthenticationData = res.locals.auth;\n        ...\n    }\n}\n\n```\n\nAuthenticationData interface provides the user credentials\n\n```\nexport interface BasicData {\n    username: string;\n    passwd: string;\n}\n\nexport interface JWTData {\n    payload: any;\n}\n\nexport interface AuthenticationData {\n    basic?: BasicData;\n    jwt?: JWTData;\n}\n```\n\n# Setting JWT authentication\n\nJWT authentication has been implemented using jsonwebtoken library. Using @JWTAuth() annotation is it possible to enable JWT authentication for a resource.\n\nWe have to decide the algorithm type that we are going to use, for more information you can read [jsonwebtoken](https://github.com/auth0/node-jsonwebtoken). Anyway I am going to explain how to use some security methods.\n\n### Supported signature algorithms\n\nSignature algorithm. Could be one of these values :\n\n* - HS256:    HMAC using SHA-256 hash algorithm (default)\n* - HS384:    HMAC using SHA-384 hash algorithm\n* - HS512:    HMAC using SHA-512 hash algorithm\n* - RS256:    RSASSA using SHA-256 hash algorithm\n* - RS384:    RSASSA using SHA-384 hash algorithm\n* - RS512:    RSASSA using SHA-512 hash algorithm\n* - ES256:    ECDSA using P-256 curve and SHA-256 hash algorithm\n* - ES384:    ECDSA using P-384 curve and SHA-384 hash algorithm\n* - ES512:    ECDSA using P-521 curve and SHA-512 hash algorithm\n* - none:     No digital signature or MAC value included\n\n\n### Setting JWT authentication with HMAC\n\nCreating a valid token with HMAC requires only a symmetric password. Using the following function:\n\n```\n    export class JWTFactory {\n        static generateToken(secret: string, payload: any, options: SignOptions = {expiresIn: 1440}): any\n    }\n```\n\nExample usage:\n\n```\n    let signOptions: SignOptions = {\n            expiresIn: 10\n    };\n    let token = JWTFactory.generateToken(\"testing\", {username: res.locals.auth.basic}, signOptions);\n```\n\nIn order to authenticate a token the client MUST send the token in the Authorization header as 'Bearer' type. The framework will check that header in order to check the token validity.\n\nJWTAuth annotation definition:\n\n```\n    function JWTAuth(cert: string, options?: VerifyOptions)\n```\n\nExample:\n\n```\n    class Resource {\n        @GET(\"/users/:username\")\n        @JWTAuth(\"secret\")\n        // OR \n        //@JWTAuth(\"secret\", {algorithm: 'HS512'})\n        protectedMethod(req: express.Request, res: express.Response, next: Function) {\n            let jwtPayload: JWTData = res.locals.auth.jwt.payload;\n            ...\n        }\n    }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplopezm%2Fdecorated-express","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplopezm%2Fdecorated-express","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplopezm%2Fdecorated-express/lists"}