Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/grimmer0125/nestjs-example

More integration example: https://github.com/grimmer0125/full-stack-example
https://github.com/grimmer0125/nestjs-example

Last synced: 1 day ago
JSON representation

More integration example: https://github.com/grimmer0125/full-stack-example

Awesome Lists containing this project

README

        


Nest Logo

[travis-image]: https://api.travis-ci.org/nestjs/nest.svg?branch=master
[travis-url]: https://travis-ci.org/nestjs/nest
[linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux
[linux-url]: https://travis-ci.org/nestjs/nest

A progressive Node.js framework for building efficient and scalable server-side applications, heavily inspired by Angular.



NPM Version
Package License
NPM Downloads
Travis
Linux
Coverage
Gitter
Backers on Open Collective
Sponsors on Open Collective



## Description

A [Nest](https://github.com/nestjs/nest) TypeScript example repository. Test restful with JWT authorization and graphql (with authorization and subscription) on http://localhost:3001

## Installation

```bash
$ yarn install
```

## Running the app

```bash
# development
$ yarn run start

# watch mode
$ yarn start:dev

# production mode
$ yarn start:prod
```

Or use VSCode+F5 to launch debugging mode.

## Try restful and graphql

### In terminal

Login to get token:

```
$ curl -X POST http://localhost:3001/auth/login -d '{"username": "john", "password": "changeme"}' -H "Content-Type: application/json"
```

Try using auth token to get profile:

```
$ curl http://localhost:3001/profile -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2Vybm..."
```

### In playground

Open `http://localhost:3001/graphql`, test following graphql commands.

```
query whoami {
whoAmI {
id
firstName
lastName
}
}

subscription commentAdded{
commentAdded {
id
author
}
}

mutation addComment{
addComment(comment:"test", postId:7) {
id
author
}
}

# paste the token from terminal
header:
{
"authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImpvaG4iLCJzdWIiOjEsImlhdCI6MTU5NDgwNTc3MCwiZXhwIjoxNTk5OTg5NzcwfQ.yzjP-Y36P3__ED_RpfwkVIRdypGAGoXz9iDdta-KFB4"
}
```

## Unit Tests and & End To End Tests

```bash
# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

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