<repo_name>thiagonmiziara/NLW-Heat-Web<file_sep>/src/services/profileService.ts
import { api } from "./api";

type ProfileProps = {
  id: string;
  name: string;
  login: string;
  avatar_url: string;
};

export const profileService = async () => {
  const response = (await api.get<ProfileProps>("/profile")).data;

  return response;
};
<file_sep>/src/models/types.ts
export type MessageProps = {
  id: string;
  text: string;
  user: {
    name: string;
    avatar_url: string;
  };
};

export type UserProps = {
  id: string;
  name: string;
  login: string;
  avatar_url: string;
};

export type AuthContextProps = {
  user: UserProps | null;
  signInUrl: string;
  signOut: () => void;
};
<file_sep>/src/services/messages.ts
import { api } from "./api";

type MessageProps = {
  id: string;
  text: string;
  user: {
    name: string;
    avatar_url: string;
  };
};

export const getMessagesList = async () => {
  const response = (await api.get<MessageProps[]>("/messages/last3")).data;

  return response;
};

export const postMessage = async (message: string) => {
  const response = (await api.post("messages", { message })).data;

  return response;
};
<file_sep>/src/services/signInService.ts
import { api } from "./api";

type SignInServiceProps = {
  token: string;
  user: {
    id: string;
    avatar_url: string;
    name: string;
    login: string;
  };
};

export const signInService = async (githubCode: string) => {
  const response = await api.post<SignInServiceProps>("/authenticate", {
    code: githubCode,
  });

  return response.data;
};
