Skip to content

Commit 3fd44ed

Browse files
author
Juan Daniel
committed
refactor: rename file server, remove literal string using Backtick & remove unused file import
1 parent 5d3431d commit 3fd44ed

5 files changed

Lines changed: 6 additions & 8 deletions

File tree

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { HTTPDataSource } from "apollo-datasource-http";
22
import { LanyardAPIData } from "./interfaces";
33
import { Pool } from "undici";
4+
import { API_URL } from "./constants";
45

5-
const pool = new Pool("https://api.lanyard.rest");
6+
const pool = new Pool(API_URL);
67

78
export default class LanyardAPI extends HTTPDataSource {
89
constructor() {
9-
super("https://api.lanyard.rest", {
10+
super(API_URL, {
1011
pool,
1112
clientOptions: {
1213
bodyTimeout: 5000,
@@ -16,6 +17,6 @@ export default class LanyardAPI extends HTTPDataSource {
1617
}
1718

1819
async getUser(user: string): Promise<LanyardAPIData> {
19-
return (await this.get("/v1/users/" + user)) as unknown as LanyardAPIData;
20+
return (await this.get(`/v1/users/${user}`)) as unknown as LanyardAPIData;
2021
}
2122
}

src/interfaces.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import LanyardAPI from "./DataSource";
2-
31
export interface LanyardAPIData {
42
success: boolean;
53
data: Data;

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import server from "./Server";
1+
import server from "./server";
22

33
server
44
.listen(8080)

src/resolvers/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import LanyardAPI from "../DataSource";
21
import { LanyardAPIData } from "../interfaces";
32

43
const Query = {

src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ApolloServer } from "apollo-server";
2-
import LanyardAPI from "./DataSource";
2+
import LanyardAPI from "./data-source";
33
import resolvers from "./resolvers";
44
import typeDefs from "./schema";
55

0 commit comments

Comments
 (0)