{"id":27737180,"url":"https://github.com/mejanh/auth-practice","last_synced_at":"2026-05-09T07:02:20.245Z","repository":{"id":42799625,"uuid":"271767315","full_name":"MejanH/auth-practice","owner":"MejanH","description":"JWT Authentication with Typescript, Express, Sqlite, TypeORM, Bcrypt in Nodejs","archived":false,"fork":false,"pushed_at":"2022-12-22T16:56:00.000Z","size":549,"stargazers_count":0,"open_issues_count":12,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-28T14:56:39.050Z","etag":null,"topics":["bcrypt","expressjs","nodejs","sqlite","typeorm","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/MejanH.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":"2020-06-12T10:05:11.000Z","updated_at":"2020-06-18T16:58:52.000Z","dependencies_parsed_at":"2023-01-30T14:10:13.355Z","dependency_job_id":null,"html_url":"https://github.com/MejanH/auth-practice","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MejanH/auth-practice","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MejanH%2Fauth-practice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MejanH%2Fauth-practice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MejanH%2Fauth-practice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MejanH%2Fauth-practice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MejanH","download_url":"https://codeload.github.com/MejanH/auth-practice/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MejanH%2Fauth-practice/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263671748,"owners_count":23494028,"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":["bcrypt","expressjs","nodejs","sqlite","typeorm","typescript"],"created_at":"2025-04-28T14:53:55.256Z","updated_at":"2026-05-09T07:02:15.217Z","avatar_url":"https://github.com/MejanH.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JWT Authentication with TypeORM, Express, Sqlite\n\n## Working with authentication\n\n\u003e To get the jwt token type username \u0026 password like the sc below and send post req\n\n![Getting Token via username \u0026 password](./src/public/get-token.png)\n\n\u003e To pass the authentication fill the Headers like the sc below with auth(name) \u0026 token(value)\n\u003e\n\u003e ![Getting Token via username \u0026 password](./src/public/logged-in.png)\n\n## Steps to seed a default admin user\n\nNow, let’s create our first migration\n\n    typeorm migration:create -n CreateAdminUser\n\nThen, we are going to modifie the generated file:\n\n    import { MigrationInterface, QueryRunner, getRepository } from \"typeorm\";\n    import { User } from \"../entity/User\";\n\n    export class CreateAdminUser1547919837483 implements MigrationInterface {\n    public async up(queryRunner: QueryRunner): Promise\u003cany\u003e {\n        let user = new User();\n        user.username = \"admin\";\n        user.password = \"admin\";\n        user.hashPassword();\n        user.role = \"ADMIN\";\n        const userRepository = getRepository(User);\n        await userRepository.save(user);\n    }\n\n    public async down(queryRunner: QueryRunner): Promise\u003cany\u003e {}\n    }\n\nNow we start the server, so the synchronize tool can generate our database tables.\n\n    npm start\n\nNow we can run the migration, to insert the first admin user.\n\n    npm run migration:run\n\n## Source Links\n\nBlog: https://medium.com/javascript-in-plain-english/creating-a-rest-api-with-jwt-authentication-and-role-based-authorization-using-typescript-fbfa3cab22a4\n\nGithub: https://github.com/andregardi/jwt-express-typeorm\n\n## Steps to run this project:\n\n1. Run `npm i` command\n2. Setup database settings inside `ormconfig.json` file\n3. Run `npm start` command\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmejanh%2Fauth-practice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmejanh%2Fauth-practice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmejanh%2Fauth-practice/lists"}