{"id":16681663,"url":"https://github.com/udamir/adminjs-fastify","last_synced_at":"2025-05-14T15:30:33.848Z","repository":{"id":42071953,"uuid":"410674416","full_name":"udamir/adminjs-fastify","owner":"udamir","description":"Fastify plugin for AdminJS","archived":false,"fork":false,"pushed_at":"2022-04-13T22:49:00.000Z","size":78,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-05-02T02:02:12.750Z","etag":null,"topics":["admin","admin-panel","adminjs","fastify-plugin"],"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/udamir.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":"2021-09-26T22:14:18.000Z","updated_at":"2022-10-20T07:23:18.000Z","dependencies_parsed_at":"2022-08-12T04:01:24.204Z","dependency_job_id":null,"html_url":"https://github.com/udamir/adminjs-fastify","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/udamir%2Fadminjs-fastify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/udamir%2Fadminjs-fastify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/udamir%2Fadminjs-fastify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/udamir%2Fadminjs-fastify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/udamir","download_url":"https://codeload.github.com/udamir/adminjs-fastify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253843196,"owners_count":21972872,"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":["admin","admin-panel","adminjs","fastify-plugin"],"created_at":"2024-10-12T14:04:56.281Z","updated_at":"2025-05-14T15:30:31.232Z","avatar_url":"https://github.com/udamir.png","language":"TypeScript","readme":"# Fastify plugin for AdminJS\n\nThis is a plugin which integrates [AdminJS](https://github.com/SoftwareBrothers/adminjs) to [fastify](https://github.com/fastify/fastify/) framework.\n\n## AdminJS\n\nAdminJS is an automatic admin interface which can be plugged into your application. You, as a developer, provide database models (like posts, comments, stores, products or whatever else your application uses), and AdminJS generates UI which allows you (or other trusted users) to manage content.\n\nCheck out the example application with mongo and postgres models here: https://adminjs-example-app-staging.herokuapp.com/admin\n\nOr visit [AdminJS](https://github.com/SoftwareBrothers/adminjs) github page.\n\n# Usage\n\n## Installation\n\n```sh\nnpm install adminjs-fastify\n```\n\n## Import plugin\n```ts\nimport { adminRoute } from \"adminjs-fastify\"\n```\n\nIt exposes `adminjs` plugin, which can be registered to a given url in the API. \n\n## Example without an authentication\n\n```ts\nimport { adminRoute } from \"adminjs-fastify\"\nimport AdminJS from 'adminjs'\nimport fastify from \"fastify\"\n\nconst app = fastify()\n\nconst adminJs = new AdminJS({\n  databases: [],\n  rootPath: '/admin' // prefix for adminJS routes\n})\n\napp.register(adminRoute, { admin: adminJs })\n\napp.listen(8080, () =\u003e console.log('AdminJS is running under localhost:8080/admin'))\n```\n\nCheck example project sources in `examples` folder.\n\n## Using build in authentication\n\nTo protect the routes with a session authentication, you can use `auth` parameter to plugin\n\n```ts\napp.register(adminRoute, { \n  admin: adminJs, \n  auth: {\n    authenticate: async (email, password) =\u003e {\n      if (ADMIN.password === password \u0026\u0026 ADMIN.email === email) {\n        return ADMIN\n      }\n      return null\n    },\n    cookiePassword: \"a secret with minimum length of 32 characters\",\n  }\n})\n```\n\nNote! To use authentication in production environment, there is a need to configure @fastify/session for production build. It can be achieved by passing options to `sessionOptions` parameter. Read more on [fastify/session Github page](https://github.com/fastify/session)\n\n## Plugin options documentation\n\nPlugin can be pre-configured with following options:\n\n```ts\n  type AdminRouterOptions = {\n    /**\n     * instance of {@link AdminJS}\n     */\n    admin: AdminJS\n\n    /** \n     * authentication parameters\n     */\n    auth?: {\n      /**\n       * cookie secret - minimum length of 32 characters\n       */\n      cookiePassword: string\n\n      /**\n       * cookie name\n       * @default: \"adminJS\"\n       */\n      cookieName?: string\n\n      /**\n       * secure cookie \n       * @default: false\n       */\n      cookieSecure?: boolean\n\n      /**\n       * authentication check function\n       * @return: user data or null\n       */\n      authenticate: (email: string, password: string) =\u003e unknown | null\n    }\n\n    /**\n     * multipart options - pass through params to fastify-multipart plugin\n     */ \n    multipartOptions?: FastifyMultipartBaseOptions\n\n    /**\n     * session options - pass through params to @fastify/session plugin\n     */ \n    sessionOptions?: FastifySessionPlugin.Options\n  })\n```\n\n# License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fudamir%2Fadminjs-fastify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fudamir%2Fadminjs-fastify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fudamir%2Fadminjs-fastify/lists"}