A progressive Node.js framework for building efficient and scalable server-side applications, heavily inspired by Angular.
A Nest TypeScript example repository. Test restful with JWT authorization and graphql (with authorization and subscription) on http://localhost:3001
$ yarn install
# development
$ yarn run start
# watch mode
$ yarn start:dev
# production mode
$ yarn start:prod
Or use VSCode+F5 to launch debugging mode.
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..."
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
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov