Skip to content

Commit 87071a5

Browse files
committed
Create olivetin auth function
1 parent e254295 commit 87071a5

3 files changed

Lines changed: 39 additions & 23 deletions

File tree

src/commands/create-minigame.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class UserCommand extends Command {
7474
);
7575

7676
const options = {
77-
hostname: "localhost:1337",
77+
hostname: "http://localhost:1337",
7878
path: "/api",
7979
method: "POST",
8080
headers: {
@@ -96,6 +96,7 @@ class UserCommand extends Command {
9696
res.on("end", () => {
9797
console.log("Response: ", JSON.parse(data));
9898
const Data = JSON.parse(data);
99+
console.log(Data);
99100
});
100101
})
101102
.on("error", (err) => {

src/lib/olivetin.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const https = require("https");
2+
const { olivetinUserName, olivetinPass } = require("../config.json");
3+
4+
const options = {
5+
hostname: "http://localhost:1337",
6+
path: "/api",
7+
method: "POST",
8+
headers: {
9+
"Content-Type": "application/json",
10+
Accept: "application/json",
11+
},
12+
};
13+
14+
const data = JSON.stringify({
15+
username: `${olivetinUserName}`,
16+
password: `${olivetinPass}`,
17+
});
18+
19+
export function login() {
20+
const req = https
21+
.request(options, (res) => {
22+
let data = "";
23+
res.on("data", (chunk) => {
24+
data += chunk;
25+
});
26+
res.on("end", () => {
27+
console.log(JSON.parse(data));
28+
});
29+
})
30+
.on("error", (err) => {
31+
console.log("Error: ", err.message);
32+
});
33+
}
34+
35+
module.exports = {
36+
login,
37+
};

src/lib/utils.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)