rename post to pool

This commit is contained in:
Michael Fatemi 2021-04-10 11:44:43 -04:00
parent b09bb33b95
commit dfc06182a4
3 changed files with 13 additions and 13 deletions

View File

@ -1,5 +1,5 @@
import { Router } from 'express'; import { Router } from 'express';
import { getGroupByID, getPostByID, getUserByID } from './data'; import { getGroupByID, getPoolByID, getUserByID } from './data';
export const router = Router(); export const router = Router();
@ -18,16 +18,16 @@ router.get('/user', (req, res) => {
} }
}); });
router.get('/post', (req, res) => { router.get('/pool', (req, res) => {
if (typeof req.query.postID != 'string') { if (typeof req.query.poolID != 'string') {
return; return;
} }
let postID = req.query.postID; let poolID = req.query.poolID;
let post = getPostByID(postID); let pool = getPoolByID(poolID);
if (post) { if (pool) {
res.json({ status: 'success', data: post }); res.json({ status: 'success', data: pool });
} else { } else {
res.json({ status: 'error', error: 'not_found' }); res.json({ status: 'error', error: 'not_found' });
} }

View File

@ -15,9 +15,9 @@ export const users: Record<string, Carpool.User> = {
export const groups: Record<string, Carpool.Group> = {}; export const groups: Record<string, Carpool.Group> = {};
/** /**
* Records posts by id * Records pools by id
*/ */
export const posts: Record<string, Carpool.Post> = {}; export const pools: Record<string, Carpool.Pool> = {};
/** /**
* *
@ -42,7 +42,7 @@ export function getGroupsWithUser(userID: string) {
*/ */
export function getPostsByUser(userID: string) { export function getPostsByUser(userID: string) {
let postIDs = []; let postIDs = [];
for (let post of Object.values(posts)) { for (let post of Object.values(pools)) {
if (post.author_id == userID) { if (post.author_id == userID) {
postIDs.push(post.id); postIDs.push(post.id);
} }
@ -55,8 +55,8 @@ export function getUserByID(userID: string): Carpool.User | undefined {
return users[userID]; return users[userID];
} }
export function getPostByID(postID: string): Carpool.Post | undefined { export function getPoolByID(poolID: string): Carpool.Pool | undefined {
return posts[postID]; return pools[poolID];
} }
export function getGroupByID(groupID: string): Carpool.Group | undefined { export function getGroupByID(groupID: string): Carpool.Group | undefined {

View File

@ -18,7 +18,7 @@ namespace Carpool {
export type Status = 'pending' | 'cancelled' | 'completed' | 'interrupted'; export type Status = 'pending' | 'cancelled' | 'completed' | 'interrupted';
export interface Post { export interface Pool {
id: string; id: string;
title: string; title: string;
description: string; description: string;