Skip to content
This repository has been archived by the owner on Dec 28, 2018. It is now read-only.

Commit

Permalink
Merge pull request #25 from SkYNewZ/develop
Browse files Browse the repository at this point in the history
## Description

:warning: Adding Oauth2 support, so you can [send me an email](mailto:quentin@lemairepro.fr) in order to obtain credentials for using this API :warning: 

* Update [docker-compose.yml](https://github.com/SkYNewZ/rest-fornite-api/blob/master/docker-compose.yml) file to getting started with this API
* [Feature] adding JWT authentification 🔒
* [Feature] rewrite tests files to correspond to
* [Fix] remove some useless features
* [Feature] update documentation
* [Feature] Use a database for oauth accounts
* [Fix] Some dependencies updates
* [Fix] Stop using redis
  • Loading branch information
SkYNewZ committed Apr 3, 2018
2 parents a68c790 + 169c39d commit db381ca
Show file tree
Hide file tree
Showing 22 changed files with 4,103 additions and 486 deletions.
9 changes: 9 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
LOGIN_EMAIL=
LOGIN_PASSWORD=
OAUTH_EPIC_LAUNCHER=
OAUTH_FORTNITE=
PGHOST=
PGPORT=
PGDATABASE=
PGUSER=
PGPASSWORD=
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ notifications:

services:
- docker
- redis-server

cache:
directories:
Expand All @@ -25,7 +24,7 @@ install:
- npm install

script:
- REDIS_HOST=localhost npm test
- npm test

after_success:
- npm run coverage
Expand Down
48 changes: 20 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Thanks to [qlaffont](https://github.com/qlaffont/fortnite-api) for doing this AP

You can found SwaggerUI here https://skynewz-api-fortnite.herokuapp.com/api-docs

## Authentification JWT
:warning: **This API is now with JWT authentification. [Send me an e-mail ](mailto:quentin@lemairepro.fr) to obtain a login and password in order to use this with a valid token** :warning:
For all the `/api` routes, you need to set the `Authorization; Bearer <token>` header.

## INIT

To setup this module, you need to have an account on Epic Games. After that you need to get 2 dedicated headers from Fortnite.
Expand All @@ -30,55 +34,43 @@ How to get these headers ?

---

## Start as docker container

### With REDIS

If you want to use a [Redis](https://hub.docker.com/_/redis/), use this [docker-compose.yml for example](https://github.com/SkYNewZ/rest-fornite-api/blob/master/docker-compose.yml) **replacing environements variables values by yours**.

### Without REDIS

```bash
$ docker run -d --restart=always \
-e LOGIN_EMAIL=EMAIL ACCOUNT \
-e LOGIN_PASSWORD=PASSWORD \
-e OAUTH_EPIC_LAUNCHER=CLIENT LAUNCHER TOKEN \
-e OAUTH_FORTNITE=FORTNITE CLIENT TOKEN \
-p 3000:3000
skynewz/fortnite-api
```

This will listening on port 3000. You can check at http://localhost:3000/check
## Start with docker :whale:

> **Note:**
> You can can the option -e PORT=1234 in order to use a custom port
You can use this [docker-compose.yml](https://github.com/SkYNewZ/rest-fornite-api/blob/master/docker-compose.yml) **replacing environements variables values by yours**. in order to startup this API.
Just download this file and `docker-compose up`

## Start with nodejs

### Requirements

* Nodejs >= 8.9
> **Note:**
> You can can the option environements variable PORT=1234 in order to use a custom port
* Rename `.env.example` to `.env` and set your values for the environements variables :
```
LOGIN_EMAIL=Your epic games account
LOGIN_PASSWORD=Your epic games password
OAUTH_EPIC_LAUNCHER=See init part
OAUTH_FORTNITE=See init part
PGHOST=Postgres host
PGPORT=Postgres port
PGDATABASE=Postgres database
PGUSER=Postgres user
PGPASSWORD=Postgres password
```

### Start in developement mode

```bash
$ git clone https://github.com/SkYNewZ/rest-fornite-api
$ cd rest-fornite-api
# write a .env file with you credentials from abose
$ vim .env
# Run
$ npm run start-dev
$ npm run dev
```

### Start in production mode

```bash
$ git clone https://github.com/SkYNewZ/rest-fornite-api
$ cd rest-fornite-api
# write a .env file with you credentials from abose
$ vim .env
# build the TypeScript
$ npm run build
# Run
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.2
3.1.0
28 changes: 22 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,29 @@ services:
restart: always
ports:
- "3000:3000"
depends_on:
- cache
- database
environment:
- LOGIN_EMAIL=fake@mail.me
- LOGIN_PASSWORD=pass
# replace XXXXX by your values
- LOGIN_EMAIL=XXXXX
- LOGIN_PASSWORD=XXXXX
- OAUTH_EPIC_LAUNCHER=XXXXX
- OAUTH_FORTNITE=XXXXX
- REDIS_HOST=cache
- REDIS_PASSWORD=XXXXX
- PGHOST=database
- PGPORT=5432
- PGDATABASE=fortnite-api
- PGUSER=postgres
- PGPASSWORD=secretpassword

cache:
image: redis
database:
image: postgres
# you should stay comment this line for prevent useless open port on your server
# ports:
# - 5432:5432
environment:
- POSTGRES_PASSWORD=secretpassword
- POSTGRES_DB=fortnite-api
volumes:
# if you want to persist data
- ./postgres:/var/lib/postgresql/data
48 changes: 20 additions & 28 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

You can found SwaggerUI here https://skynewz-api-fortnite.herokuapp.com/api-docs

## Authentification JWT
:warning: **This API is now with JWT authentification. [Send me an e-mail ](mailto:quentin@lemairepro.fr) to obtain a login and password in order to use this with a valid token** :warning:
For all the `/api` routes, you need to set the `Authorization; Bearer <token>` header.

## INIT

To setup this module, you need to have an account on Epic Games. After that you need to get 2 dedicated headers from Fortnite.
Expand All @@ -26,55 +30,43 @@ How to get these headers ?

---

## Start as docker container

### With REDIS

If you want to use a [Redis](https://hub.docker.com/_/redis/), use this [docker-compose.yml for example](https://github.com/SkYNewZ/rest-fornite-api/blob/master/docker-compose.yml) **replacing environements variables values by yours**.

### Without REDIS

```bash
$ docker run -d --restart=always \
-e LOGIN_EMAIL=EMAIL ACCOUNT \
-e LOGIN_PASSWORD=PASSWORD \
-e OAUTH_EPIC_LAUNCHER=CLIENT LAUNCHER TOKEN \
-e OAUTH_FORTNITE=FORTNITE CLIENT TOKEN \
-p 3000:3000
skynewz/fortnite-api
```

This will listening on port 3000. You can check at http://localhost:3000/check
## Start with docker :whale:

> **Note:**
> You can can the option -e PORT=1234 in order to use a custom port
You can use this [docker-compose.yml](https://github.com/SkYNewZ/rest-fornite-api/blob/master/docker-compose.yml) **replacing environements variables values by yours**. in order to startup this API.
Just download this file and `docker-compose up`

## Start with nodejs

### Requirements

* Nodejs >= 8.9
> **Note:**
> You can can the option environements variable PORT=1234 in order to use a custom port
* Rename `.env.example` to `.env` and set your values for the environements variables :
```
LOGIN_EMAIL=Your epic games account
LOGIN_PASSWORD=Your epic games password
OAUTH_EPIC_LAUNCHER=See init part
OAUTH_FORTNITE=See init part
PGHOST=Postgres host
PGPORT=Postgres port
PGDATABASE=Postgres database
PGUSER=Postgres user
PGPASSWORD=Postgres password
```

### Start in developement mode

```bash
$ git clone https://github.com/SkYNewZ/rest-fornite-api
$ cd rest-fornite-api
# write a .env file with you credentials from abose
$ vim .env
# Run
$ npm run start-dev
$ npm run dev
```

### Start in production mode

```bash
$ git clone https://github.com/SkYNewZ/rest-fornite-api
$ cd rest-fornite-api
# write a .env file with you credentials from abose
$ vim .env
# build the TypeScript
$ npm run build
# Run
Expand Down
6 changes: 6 additions & 0 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"watch": ["src"],
"ext": "ts",
"ignore": ["src/**/*.spec.ts"],
"exec": "./node_modules/.bin/ts-node src/index.ts"
}

0 comments on commit db381ca

Please sign in to comment.