Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/muthuri-dev/authentication-authorization-nestjs

Performing auth using nestjs
https://github.com/muthuri-dev/authentication-authorization-nestjs

authentication authorization graphql guard nestjs-backend passport-jwt passport-local

Last synced: 29 minutes ago
JSON representation

Performing auth using nestjs

Awesome Lists containing this project

README

        


Nest Logo

A progressive guide on nestjs authentication and authorization


## Description

The repo covers mostly on authenticaton and authorization using passportjs and jwt

## Installation

```bash
$ npm install
```

## Running the app

```bash
# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod
```

## Test

```bash
# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov
```

### schema structure

```bash
input CreateUserInput {
password: String!
username: String!
}

type Login {
access_token: String!
user: User!
}

input LoginDto {
password: String!
username: String!
}

type Mutation {
createUser(userDto: CreateUserInput!): User!
login(loginDto: LoginDto!): Login!
signup(signupDto: LoginDto!): User!
}

type Query {
user(username: String!): User!
users: [User!]!
}

type User {
id: Int!
username: String!
}
```

### connecting graphql

```bash
@Module({
imports: [
GraphQLModule.forRoot({
driver: ApolloDriver,
autoSchemaFile: join(process.cwd(), 'src/schema.gql'),
sortSchema: true,
}),
UsersModule,
AuthModule,
],
providers: [ConfigService],
})
export class AppModule {}

```

## Stay in touch

- Author - [Kennedy Muthuri](https://muthuri.vercel.app/)

## License

Nest is [MIT licensed](LICENSE).