From dfc06182a4701189d630cf53481f027c1ae1cb7f Mon Sep 17 00:00:00 2001 From: Michael Fatemi Date: Sat, 10 Apr 2021 11:44:43 -0400 Subject: [PATCH] rename post to pool --- src/api.ts | 14 +++++++------- src/data.ts | 10 +++++----- src/types.ts | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/api.ts b/src/api.ts index 77922fa..dbfc7ba 100644 --- a/src/api.ts +++ b/src/api.ts @@ -1,5 +1,5 @@ import { Router } from 'express'; -import { getGroupByID, getPostByID, getUserByID } from './data'; +import { getGroupByID, getPoolByID, getUserByID } from './data'; export const router = Router(); @@ -18,16 +18,16 @@ router.get('/user', (req, res) => { } }); -router.get('/post', (req, res) => { - if (typeof req.query.postID != 'string') { +router.get('/pool', (req, res) => { + if (typeof req.query.poolID != 'string') { return; } - let postID = req.query.postID; - let post = getPostByID(postID); + let poolID = req.query.poolID; + let pool = getPoolByID(poolID); - if (post) { - res.json({ status: 'success', data: post }); + if (pool) { + res.json({ status: 'success', data: pool }); } else { res.json({ status: 'error', error: 'not_found' }); } diff --git a/src/data.ts b/src/data.ts index 9916b4d..36b3426 100644 --- a/src/data.ts +++ b/src/data.ts @@ -15,9 +15,9 @@ export const users: Record = { export const groups: Record = {}; /** - * Records posts by id + * Records pools by id */ -export const posts: Record = {}; +export const pools: Record = {}; /** * @@ -42,7 +42,7 @@ export function getGroupsWithUser(userID: string) { */ export function getPostsByUser(userID: string) { let postIDs = []; - for (let post of Object.values(posts)) { + for (let post of Object.values(pools)) { if (post.author_id == userID) { postIDs.push(post.id); } @@ -55,8 +55,8 @@ export function getUserByID(userID: string): Carpool.User | undefined { return users[userID]; } -export function getPostByID(postID: string): Carpool.Post | undefined { - return posts[postID]; +export function getPoolByID(poolID: string): Carpool.Pool | undefined { + return pools[poolID]; } export function getGroupByID(groupID: string): Carpool.Group | undefined { diff --git a/src/types.ts b/src/types.ts index e0e9966..04aab7a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -18,7 +18,7 @@ namespace Carpool { export type Status = 'pending' | 'cancelled' | 'completed' | 'interrupted'; - export interface Post { + export interface Pool { id: string; title: string; description: string;