Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mabuonomo/yggdrasil-ts
A boilerplate of a nodejs server, written in Typescript, with JWT authentication, TypeGraphQL and TypeORM
https://github.com/mabuonomo/yggdrasil-ts
graphql jwt jwt-authentication nodejs server typegraphql typeorm typescript
Last synced: about 2 months ago
JSON representation
A boilerplate of a nodejs server, written in Typescript, with JWT authentication, TypeGraphQL and TypeORM
- Host: GitHub
- URL: https://github.com/mabuonomo/yggdrasil-ts
- Owner: mabuonomo
- License: gpl-3.0
- Created: 2018-08-21T20:57:40.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-12T01:42:23.000Z (almost 2 years ago)
- Last Synced: 2023-03-07T20:51:58.043Z (almost 2 years ago)
- Topics: graphql, jwt, jwt-authentication, nodejs, server, typegraphql, typeorm, typescript
- Language: TypeScript
- Homepage:
- Size: 1.92 MB
- Stars: 10
- Watchers: 3
- Forks: 0
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## YGGDRASIL
A boilerplate of a nodejs server, written in Typescript, with JWT authentication, GraphQL and TypeORM## Run
### First
* Compile the ts files.### Run tests
```bash
npm test
```### Run in Docker
```bash
docker-compose build
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
```
http://localhost:3000/sign
```
```graphql
query login($loginInput: LoginInput!) {
signIn(loginInput: $loginInput) {
result,
token,
error,
info {
message
}
}
}mutation register($newUser: UserInput!) {
signUp(newUser: $newUser) {
name
}
}
```
```json
Query variables:
{
"loginInput": {
"email": "[email protected]",
"password": "password"
},
"newUser": {
"name": "user",
"profile": {
"email": "[email protected]"
},
"password": "password"
}
}
```
```json
Result Login:
{
"data": {
"signIn": {
"result": true,
"token": "******",
"error": null,
"info": {
"message": "Logged In Successfully"
}
}
}
}
```### API (need a JWT token)
The second endpoint need a JWT token that you can to get from login query.```
http://localhost:3000/api
``````graphql
query getByEmail($email: String!) {
getByEmail(email: $email) {
name
}
}
```
```json
Query variables:
{
"email": "[email protected]"
}
```
```json
Result:
{
"data": {
"getByEmail": {
"name": "user"
}
}
}
```## FAQ
How I can test the endpoint /api?* If you use a browser you need a Header Modifier extension.
* In alternative you can use Postman (https://www.getpostman.com) or Insomnia (https://insomnia.rest). Insomnia supports natively graphql application (and GraphiQL explorer).
Finally set the header field: "Authorization Bearer _your_jwt_token_"
## Thanks to
* NodeJS https://nodejs.org
* TypeGraphql https://github.com/19majkel94/type-graphql
* TypeOrm https://github.com/typeorm/typeorm
* JWT https://jwt.io/
* GraphQL http://graphql.github.io/