Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: include type definitions #435

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

20 changes: 0 additions & 20 deletions .eslintrc

This file was deleted.

2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:

- run: npm run lint

- run: npm run types

- run: npm test

- run: npx semantic-release
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ jobs:

- run: npm run lint

- run: npm run types

- run: npm test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ tmp/**/*
coverage
.vscode
.nyc_output/
.tap/
.tap/
types/
19 changes: 0 additions & 19 deletions .prettierrc

This file was deleted.

3 changes: 3 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import config from "@eik/eslint-config";

export default config;
29 changes: 13 additions & 16 deletions examples/auth.post.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
/* eslint-disable no-console */
/* eslint-disable import/no-extraneous-dependencies */

import FormData from 'form-data';
import fetch from 'node-fetch';
import FormData from "form-data";
import fetch from "node-fetch";

const authenticate = async (address) => {
const formData = new FormData();
formData.append('key', 'change_me');
const formData = new FormData();
formData.append("key", "change_me");

const res = await fetch(`${address}/auth/login`, {
method: 'POST',
body: formData,
headers: formData.getHeaders(),
});
const res = await fetch(`${address}/auth/login`, {
method: "POST",
body: formData,
headers: formData.getHeaders(),
});

const body = await res.json();
const body = await res.json();

console.log(body);
}
console.log(body);
};

authenticate('http://localhost:4001');
authenticate("http://localhost:4001");
89 changes: 43 additions & 46 deletions examples/map.alias.delete.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,49 @@
/* eslint-disable no-console */
/* eslint-disable import/no-extraneous-dependencies */

import FormData from 'form-data';
import fetch from 'node-fetch';
import FormData from "form-data";
import fetch from "node-fetch";

const authenticate = async (address) => {
const formData = new FormData();
formData.append('key', 'change_me');
const formData = new FormData();
formData.append("key", "change_me");

const res = await fetch(`${address}/auth/login`, {
method: 'POST',
body: formData,
headers: formData.getHeaders(),
});
const res = await fetch(`${address}/auth/login`, {
method: "POST",
body: formData,
headers: formData.getHeaders(),
});

return res.json();
}
return res.json();
};

const del = async (address) => {
const auth = await authenticate(address);

const headers = {
'Authorization': `Bearer ${auth.token}`
};

const res = await fetch(`${address}/map/buzz/v4`, {
method: 'DELETE',
headers,
})

let result = {};
switch (res.status) {
case 204:
result = { status: res.status, message: 'Deleted' };
break;
case 401:
result = { status: res.status, message: 'Unauthorized' };
break;
case 404:
result = { status: res.status, message: 'Not found' };
break;
case 502:
result = { status: res.status, message: 'Writing file failed' };
break;
default:
result = { status: res.status };
}
console.log(result);
}

del('http://localhost:4001');
const auth = await authenticate(address);

const headers = {
Authorization: `Bearer ${auth.token}`,
};

const res = await fetch(`${address}/map/buzz/v4`, {
method: "DELETE",
headers,
});

let result = {};
switch (res.status) {
case 204:
result = { status: res.status, message: "Deleted" };
break;
case 401:
result = { status: res.status, message: "Unauthorized" };
break;
case 404:
result = { status: res.status, message: "Not found" };
break;
case 502:
result = { status: res.status, message: "Writing file failed" };
break;
default:
result = { status: res.status };
}
console.log(result);
};

del("http://localhost:4001");
13 changes: 5 additions & 8 deletions examples/map.alias.get.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/* eslint-disable no-console */
/* eslint-disable import/no-extraneous-dependencies */
import fetch from "node-fetch";

import fetch from 'node-fetch';

fetch('http://localhost:4001/map/buzz/v4', {
method: 'GET',
fetch("http://localhost:4001/map/buzz/v4", {
method: "GET",
})
.then(res => res.json())
.then(json => console.log(json));
.then((res) => res.json())
.then((json) => console.log(json));
96 changes: 48 additions & 48 deletions examples/map.alias.post.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
/* eslint-disable no-console */
/* eslint-disable import/no-extraneous-dependencies */

import FormData from 'form-data';
import fetch from 'node-fetch';
import FormData from "form-data";
import fetch from "node-fetch";

const authenticate = async (address) => {
const formData = new FormData();
formData.append('key', 'change_me');
const formData = new FormData();
formData.append("key", "change_me");

const res = await fetch(`${address}/auth/login`, {
method: 'POST',
body: formData,
headers: formData.getHeaders(),
});
const res = await fetch(`${address}/auth/login`, {
method: "POST",
body: formData,
headers: formData.getHeaders(),
});

return res.json();
}
return res.json();
};

const post = async (address) => {
const auth = await authenticate(address);

const formData = new FormData();
formData.append('version', '4.4.2');

const headers = {'Authorization': `Bearer ${auth.token}`, ...formData.getHeaders()};

const res = await fetch(`${address}/map/buzz/v4`, {
method: 'POST',
body: formData,
headers,
})

let result = {};
switch (res.status) {
case 200:
result = await res.json();
break;
case 401:
result = { status: res.status, message: 'Unauthorized' };
break;
case 404:
result = { status: res.status, message: 'Not found' };
break;
case 502:
result = { status: res.status, message: 'Writing file failed' };
break;
default:
result = { status: res.status };
}
console.log(result);
}

post('http://localhost:4001');
const auth = await authenticate(address);

const formData = new FormData();
formData.append("version", "4.4.2");

const headers = {
Authorization: `Bearer ${auth.token}`,
...formData.getHeaders(),
};

const res = await fetch(`${address}/map/buzz/v4`, {
method: "POST",
body: formData,
headers,
});

let result = {};
switch (res.status) {
case 200:
result = await res.json();
break;
case 401:
result = { status: res.status, message: "Unauthorized" };
break;
case 404:
result = { status: res.status, message: "Not found" };
break;
case 502:
result = { status: res.status, message: "Writing file failed" };
break;
default:
result = { status: res.status };
}
console.log(result);
};

post("http://localhost:4001");
Loading