Skip to content

Commit 66b22c8

Browse files
committed
feat: add europe support
1 parent 2811683 commit 66b22c8

File tree

6 files changed

+94
-25
lines changed

6 files changed

+94
-25
lines changed

.github/workflows/cd.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Deployment
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
name: Build and create release
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Install Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 20.12.2
24+
registry-url: "https://registry.npmjs.org"
25+
26+
- uses: pnpm/action-setup@v2
27+
name: Install pnpm
28+
id: pnpm-install
29+
with:
30+
run_install: false
31+
32+
- name: Install dependencies
33+
run: pnpm install --no-frozen-lockfile
34+
35+
- name: Build project
36+
run: pnpm run build
37+
38+
- name: Publish package on NPM
39+
run: pnpm publish --access public --no-git-checks
40+
41+
env:
42+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Designed with ❤️ for the Albion community.
2323
```javascript
2424
import { AlbionSDK } from "albion-sdk"
2525

26-
const api = new AlbionSDK("NA")
26+
const api = new AlbionSDK("Americas")
2727

2828
api
2929
.search("man")

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "albion-sdk",
33
"description": "Albion Online API SDK",
4-
"version": "0.7.0",
4+
"version": "0.8.0",
55
"license": "MIT",
66
"author": "Cody Tenney",
77
"repository": {

src/config.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
export const NA_API_URL = "https://gameinfo.albiononline.com/api/gameinfo";
2-
export const SGP_API_URL = "https://gameinfo-sgp.albiononline.com/api/gameinfo";
3-
export const NA_STATUS_URL = "https://serverstatus.albiononline.com";
4-
export const SGP_STATUS_URL = "https://serverstatus-sgp.albiononline.com";
1+
export const AMERICAS_API_URL =
2+
"https://gameinfo.albiononline.com/api/gameinfo";
3+
export const ASIA_API_URL =
4+
"https://gameinfo-sgp.albiononline.com/api/gameinfo";
5+
export const EUROPE_API_URL =
6+
"https://gameinfo-ams.albiononline.com/api/gameinfo";
7+
8+
export const AMERICAS_STATUS_URL = "https://serverstatus.albiononline.com";
9+
export const ASIA_STATUS_URL = "https://serverstatus-sgp.albiononline.com";
10+
export const EUROPE_STATUS_URL = "https://serverstatus-ams.albiononline.com";
11+
512
export const RENDER_API_URL = "https://render.albiononline.com/v1";

src/sdk.ts

+24-12
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import {
2-
NA_API_URL,
3-
NA_STATUS_URL,
2+
AMERICAS_API_URL,
3+
AMERICAS_STATUS_URL,
4+
ASIA_API_URL,
5+
ASIA_STATUS_URL,
6+
EUROPE_API_URL,
7+
EUROPE_STATUS_URL,
48
RENDER_API_URL,
5-
SGP_API_URL,
6-
SGP_STATUS_URL,
79
} from "./config.ts";
810
import { _internal_fetch, _internal_fetch_status } from "./fetch.ts";
911
import type {
@@ -39,18 +41,28 @@ export class AlbionSDK {
3941
constructor(server: Server) {
4042
if (server === undefined) {
4143
throw new Error(
42-
"You must specify an Albion Online server, either 'NA' for North America or 'SGP' for South East Asia",
44+
"You must specify an Albion Online server, either 'Americas', 'Asia', or 'Europe'",
4345
);
4446
}
4547

46-
if (server !== "NA" && server !== "SGP") {
47-
throw new Error(
48-
"Invalid server, please use 'NA' for North America or 'SGP' for South East Asia",
49-
);
48+
switch (server) {
49+
case "Americas":
50+
this._apiURL = AMERICAS_API_URL;
51+
this._statusURL = AMERICAS_STATUS_URL;
52+
break;
53+
case "Asia":
54+
this._apiURL = ASIA_API_URL;
55+
this._statusURL = ASIA_STATUS_URL;
56+
break;
57+
case "Europe":
58+
this._apiURL = EUROPE_API_URL;
59+
this._statusURL = EUROPE_STATUS_URL;
60+
break;
61+
default:
62+
throw new Error(
63+
"Invalid server specifier, please use 'Americas', 'Asia', or 'Europe'",
64+
);
5065
}
51-
52-
this._apiURL = server === "NA" ? NA_API_URL : SGP_API_URL;
53-
this._statusURL = server === "NA" ? NA_STATUS_URL : SGP_STATUS_URL;
5466
}
5567

5668
private async _fetch<T>(

src/types.ts

+15-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
import type {
2-
NA_API_URL,
3-
NA_STATUS_URL,
4-
SGP_API_URL,
5-
SGP_STATUS_URL,
2+
AMERICAS_API_URL,
3+
AMERICAS_STATUS_URL,
4+
ASIA_API_URL,
5+
ASIA_STATUS_URL,
6+
EUROPE_API_URL,
7+
EUROPE_STATUS_URL,
68
} from "./config.ts";
79

8-
export type Server = "NA" | "SGP";
10+
export type Server = "Americas" | "Asia" | "Europe";
911

10-
export type ServerAPIURL = typeof NA_API_URL | typeof SGP_API_URL;
12+
export type ServerAPIURL =
13+
| typeof AMERICAS_API_URL
14+
| typeof ASIA_API_URL
15+
| typeof EUROPE_API_URL;
1116

12-
export type ServerStatusURL = typeof NA_STATUS_URL | typeof SGP_STATUS_URL;
17+
export type ServerStatusURL =
18+
| typeof AMERICAS_STATUS_URL
19+
| typeof ASIA_STATUS_URL
20+
| typeof EUROPE_STATUS_URL;
1321

1422
export type StandardTimeRange = "week" | "month" | "lastWeek" | "lastMonth";
1523

0 commit comments

Comments
 (0)