Skip to content

Commit 9314163

Browse files
committed
Initial commit
1 parent 3fdd0bd commit 9314163

27 files changed

+15006
-0
lines changed

.editorconfig

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
; Top-most .editorcofing file
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
indent_size = 2
8+
quote_type = single
9+
indent_style = space
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
13+
[*.{yml,yaml}]
14+
indent_size = 2
15+
16+
[*.md]
17+
trim_trailing_whitespace = false

.eslintrc.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module.exports = {
2+
env: {
3+
es2021: true,
4+
node: true,
5+
},
6+
extends: [
7+
'airbnb-base',
8+
],
9+
parser: '@typescript-eslint/parser',
10+
parserOptions: {
11+
ecmaVersion: 'latest',
12+
sourceType: 'module',
13+
},
14+
plugins: [
15+
'@typescript-eslint',
16+
],
17+
rules: {
18+
'import/extensions': 'off',
19+
'lines-between-class-members': [
20+
'error',
21+
'always',
22+
{ exceptAfterSingleLine: true },
23+
],
24+
'default-case': 'off',
25+
'max-len': 'off',
26+
},
27+
settings: {
28+
'import/resolver': {
29+
node: {
30+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
31+
},
32+
},
33+
},
34+
};

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text eol=lf

.github/dependabot.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
allow:
5+
- dependency-type: "production"
6+
- dependency-type: "development"
7+
directory: "/"
8+
commit-message:
9+
prefix: "⬆️ "
10+
include: "scope"
11+
schedule:
12+
interval: "daily"
13+
time: "07:00"
14+
timezone: "Europe/Berlin"

.github/workflows/ci.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: "CI"
2+
on: ["push", "pull_request"]
3+
jobs:
4+
Test:
5+
name: "Test Code (Node ${{ matrix.node }})"
6+
runs-on: "ubuntu-latest"
7+
8+
strategy:
9+
matrix:
10+
node: ["12", "16"]
11+
fail-fast: false
12+
13+
steps:
14+
- name: "Checkout Repository"
15+
uses: "actions/checkout@v2"
16+
17+
- name: "Set Up NodeJS"
18+
uses: "actions/setup-node@v2"
19+
with:
20+
node-version: ${{ matrix.node }}
21+
22+
- name: "Install Dependencies"
23+
run: "npm ci"
24+
25+
- name: "Lint Code"
26+
if: ${{ matrix.node == '16' }}
27+
run: "npx eslint -f .github/workflows/formatter.js src/**/*.ts || :"
28+
29+
- name: "Compile Code"
30+
run: "npx tsc"
31+
32+
- name: "Run Tests"
33+
run: "npm run test"

.github/workflows/formatter.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const path = require('path');
2+
3+
/**
4+
* Takes ESLint output and makes it GitHub-friendly
5+
* i.e. errors & warnings show up in GUIs
6+
*/
7+
module.exports = (results) => {
8+
for (const result of results) {
9+
for (const data of result.messages) {
10+
// Different parameters GitHub can show
11+
const severity = data.severity === 1 ? 'warning' : 'error';
12+
const file = path.relative(process.cwd(), result.filePath);
13+
const { line, column, message } = data;
14+
15+
console.log(`::${severity} file=${file},line=${line},col=${column}::${message}`);
16+
}
17+
}
18+
};

.github/workflows/web.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: "WEB"
2+
on:
3+
push:
4+
branches:
5+
- 'master'
6+
jobs:
7+
docgen:
8+
name: Web
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Setup git
12+
run: |
13+
git config --global user.name "FNAPIcomBot"
14+
git config --global user.email [email protected]
15+
16+
- name: Set Up NodeJS
17+
uses: actions/setup-node@v2
18+
with:
19+
node-version: 16
20+
21+
- name: Checkout Master Branch
22+
uses: actions/checkout@v2
23+
with:
24+
path: master
25+
26+
- name: Checkout Web Branch
27+
uses: actions/checkout@v2
28+
with:
29+
path: web
30+
ref: web
31+
32+
- name: Install Master Branch Dependencies
33+
working-directory: ./master
34+
run: npm ci
35+
36+
- name: Build Web Version
37+
working-directory: ./master
38+
run: npm run buildWeb
39+
40+
- uses: actions-ecosystem/action-regex-match@v2
41+
id: current_branch
42+
with:
43+
text: ${{ github.ref }}
44+
regex: '(?<=\/)(\w|\d|\.)+$'
45+
46+
- name: Commit And Push Web Version
47+
working-directory: ./web
48+
shell: bash
49+
env:
50+
CURRENT_BRANCH: ${{ steps.current_branch.outputs.match }}
51+
run: |
52+
git pull
53+
mv ../master/FNAPIcom.js ./FNAPIcom.js
54+
git add . -A
55+
git diff-index --quiet HEAD || git commit -m "Built for ${CURRENT_BRANCH}: ${GITHUB_SHA}"
56+
git push https://FNAPIcomBot:${{ secrets.BOT_PAT }}@github.com/ThisNils/FNAPIcom web

.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# TypeScript cache
5+
*.tsbuildinfo
6+
7+
# Build artifacts
8+
dist/
9+
FNAPIcom.js
10+
11+
# Code editors
12+
.vscode/
13+
.nova/
14+
.idea/
15+
16+
# Testing scripts
17+
test.js

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Nils S.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<a href="https://github.com/Fortnite-API/nodejs-wrapper"><img align="left" src="https://fortnite-api.com/assets/img/logo.png" height=128 width=128 /></a>
2+
3+
[![CI Status](https://github.com/Fortnite-API/nodejs-wrapper/actions/workflows/ci.yml/badge.svg)](https://github.com/Fortnite-API/nodejs-wrapper/actions/workflows/ci.yml)
4+
[![NPM Version](https://img.shields.io/npm/v/fnapicom.svg)](https://npmjs.com/package/fnapicom)
5+
[![NPM Downloads](https://img.shields.io/npm/dm/fnapicom.svg)](https://npmjs.com/package/fnapicom)
6+
[![MIT License](https://img.shields.io/npm/l/fnapicom.svg)](https://github.com/Fortnite-API/nodejs-wrapper/blob/master/LICENSE)
7+
[![Discord Server](https://discord.com/api/guilds/621452110558527502/widget.png)](https://discord.gg/hGzW8gSMCa)
8+
9+
A JavaScript / TypeScript wrapper for [Fortnite-API.com](https://fortnite-api.com/)
10+
11+
Note: This is the NodeJS version. You can find the browser version [here](https://github.com/Fortnite-API/nodejs-wrapper/tree/web)
12+
13+
<br />
14+
<hr />
15+
16+
<h2>Installation</h2>
17+
18+
```
19+
npm install fnapicom
20+
```
21+
22+
<h2>Usage example</h2>
23+
24+
```javascript
25+
const { Client, Language } = require('fnapicom');
26+
27+
const client = new Client({
28+
language: Language.English,
29+
apiKey: 'your-api-key',
30+
});
31+
32+
client.aesKeys()
33+
.then(console.log);
34+
```
35+
36+
<h2>Links</h2>
37+
38+
- [NPM](https://npmjs.com/package/fnapicom)
39+
- [Docs](https://dash.fortnite-api.com/)
40+
- [Discord](https://discord.gg/hGzW8gSMCa)
41+
42+
<h2>License</h2>
43+
MIT License
44+
45+
Copyright (c) 2022 Nils S.
46+
47+
Permission is hereby granted, free of charge, to any person obtaining a copy
48+
of this software and associated documentation files (the "Software"), to deal
49+
in the Software without restriction, including without limitation the rights
50+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
51+
copies of the Software, and to permit persons to whom the Software is
52+
furnished to do so, subject to the following conditions:
53+
54+
The above copyright notice and this permission notice shall be included in all
55+
copies or substantial portions of the Software.
56+
57+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
58+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
59+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
60+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
61+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
62+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
63+
SOFTWARE.

fetchEndpointStructs.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const axios = require('axios').default;
2+
const fs = require('fs').promises;
3+
const { version } = require('./package.json');
4+
5+
(async () => {
6+
const endpointStructs = await axios({
7+
method: 'GET',
8+
url: 'https://cdn.thisnils.de/fnapicom/autogeneratedEndpointStructs.ts',
9+
headers: {
10+
'User-Agent': `fnapicom/${version}`,
11+
},
12+
});
13+
14+
await fs.writeFile('./src/http/autogeneratedEndpointStructs.ts', endpointStructs.data);
15+
})();

index.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// client
2+
export { default as Client } from './src/client/Client';
3+
4+
// exceptions
5+
export { default as InvalidAPIKeyError } from './src/exceptions/InvalidAPIKeyError';
6+
export { default as MissingAPIKeyError } from './src/exceptions/MissingAPIKeyError';
7+
export { default as FortniteAPIError } from './src/exceptions/FortniteAPIError';
8+
9+
// structs
10+
export * from './resources/structs';
11+
export * from './src/http/httpStructs';
12+
export * from './src/http/autogeneratedEndpointStructs';
13+
14+
// enums
15+
export * from './resources/enums';

jest.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const config = {
2+
modulePathIgnorePatterns: ['<rootDir>/dist'],
3+
};
4+
5+
module.exports = config;

0 commit comments

Comments
 (0)