Skip to content

Commit

Permalink
refactor(constants): export default 지양
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubinquitous committed Mar 9, 2024
1 parent be4b7e1 commit 654dc8d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
4 changes: 1 addition & 3 deletions constants/authority.constant.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const authority = {
export const authority = {
ADMIN: "ADMIN",
READONLY: "BANNED",
USER: "USER",
};

export default authority;
4 changes: 1 addition & 3 deletions constants/exception.constant.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const exception = {
export const exception = {
code: {
IMG_400_1: "IMG-400-1",
DOCS_404_1: "DOCS-404-1",
Expand All @@ -20,5 +20,3 @@ const exception = {
SERVER_ERROR: 500,
},
};

export default exception;
4 changes: 4 additions & 0 deletions constants/token.constant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const TOKEN = {
ACCESS: "access_token",
REFRESH: "refresh_token",
} as const;
25 changes: 25 additions & 0 deletions storage/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
type LocalStorageKey = "access_token" | "refresh_token" | "autoComplete";

export class Storage {
private static isWindowAvailable() {
return typeof window !== "undefined";
}

static getItem(key: LocalStorageKey) {
if (typeof window !== "undefined") return localStorage.getItem(key);
}

static setItem(key: LocalStorageKey, value: string) {
if (typeof window === "undefined") return;
localStorage.setItem(key, value);
}

static delItem(key: LocalStorageKey) {
if (typeof window === "undefined") return;
localStorage.removeItem(key);
}

static clear() {
if (this.isWindowAvailable()) localStorage.clear();
}
}

0 comments on commit 654dc8d

Please sign in to comment.