项目作者: mabuonomo

项目描述 :
A boilerplate of a nodejs server, written in Typescript, with JWT authentication, TypeGraphQL and TypeORM
高级语言: TypeScript
项目地址: git://github.com/mabuonomo/yggdrasil-ts.git
创建时间: 2018-08-21T20:57:40Z
项目社区:https://github.com/mabuonomo/yggdrasil-ts

开源协议:GNU General Public License v3.0

下载


YGGDRASIL

A boilerplate of a nodejs server, written in Typescript, with JWT authentication, GraphQL and TypeORM

Run

First

  • Compile the ts files.

Run tests

  1. npm test

Run in Docker

  1. docker-compose build
  2. docker-compose up

Endpoints

There are two endpoints, /sign and /api.

Registration and Login (without JWT token)

The first, without JWT check validation, allow you to make a registration and a login

  1. http://localhost:3000/sign
  1. query login($loginInput: LoginInput!) {
  2. signIn(loginInput: $loginInput) {
  3. result,
  4. token,
  5. error,
  6. info {
  7. message
  8. }
  9. }
  10. }
  11. mutation register($newUser: UserInput!) {
  12. signUp(newUser: $newUser) {
  13. name
  14. }
  15. }
  1. Query variables:
  2. {
  3. "loginInput": {
  4. "email": "email@email.it",
  5. "password": "password"
  6. },
  7. "newUser": {
  8. "name": "user",
  9. "profile": {
  10. "email": "email@email.it"
  11. },
  12. "password": "password"
  13. }
  14. }
  1. Result Login:
  2. {
  3. "data": {
  4. "signIn": {
  5. "result": true,
  6. "token": "******",
  7. "error": null,
  8. "info": {
  9. "message": "Logged In Successfully"
  10. }
  11. }
  12. }
  13. }

API (need a JWT token)

The second endpoint need a JWT token that you can to get from login query.

  1. http://localhost:3000/api
  1. query getByEmail($email: String!) {
  2. getByEmail(email: $email) {
  3. name
  4. }
  5. }
  1. Query variables:
  2. {
  3. "email": "email@email.it"
  4. }
  1. Result:
  2. {
  3. "data": {
  4. "getByEmail": {
  5. "name": "user"
  6. }
  7. }
  8. }

FAQ

How I can test the endpoint /api?

Finally set the header field: “Authorization Bearer your_jwt_token

Thanks to