Compare commits
No commits in common. "974d86c2d98049927e6e6a817c6a32266d6dd1cc" and "2630a0c9ef6f2795b5ff9db3eb0c1f6ac9e81285" have entirely different histories.
974d86c2d9
...
2630a0c9ef
4 changed files with 0 additions and 50 deletions
|
@ -1,32 +0,0 @@
|
||||||
import { NewUser, User } from "../Types/Users";
|
|
||||||
|
|
||||||
// Defines all the methods that an instance of the API must implement
|
|
||||||
interface API {
|
|
||||||
/** Register a new user */
|
|
||||||
registerUser(user: NewUser): Promise<User>;
|
|
||||||
/** Remove a user */
|
|
||||||
removeUser(username: string): Promise<User>;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Export an instance of the API
|
|
||||||
export const api: API = {
|
|
||||||
async registerUser(user: NewUser): Promise<User> {
|
|
||||||
return fetch("/api/register", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
body: JSON.stringify(user),
|
|
||||||
}).then((res) => res.json() as Promise<User>);
|
|
||||||
},
|
|
||||||
|
|
||||||
async removeUser(username: string): Promise<User> {
|
|
||||||
return fetch("/api/userdelete", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
body: JSON.stringify(username),
|
|
||||||
}).then((res) => res.json() as Promise<User>);
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -1,3 +0,0 @@
|
||||||
# API
|
|
||||||
|
|
||||||
This file contains the high-level API interface and implementation.
|
|
|
@ -1,4 +0,0 @@
|
||||||
# Types
|
|
||||||
|
|
||||||
This directory contains TypeScript type definitions for the frontend.
|
|
||||||
This is primarily used by, but not limited to, the API responses and requests.
|
|
|
@ -1,11 +0,0 @@
|
||||||
// This is how the API responds
|
|
||||||
export interface User {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Used to create a new user
|
|
||||||
export interface NewUser {
|
|
||||||
name: string;
|
|
||||||
password: string;
|
|
||||||
}
|
|
Loading…
Reference in a new issue